hexsha stringlengths 40 40 | size int64 19 11.4M | ext stringclasses 13
values | lang stringclasses 1
value | max_stars_repo_path stringlengths 3 270 | max_stars_repo_name stringlengths 5 110 | max_stars_repo_head_hexsha stringlengths 40 40 | max_stars_repo_licenses listlengths 1 9 | max_stars_count float64 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 3 270 | max_issues_repo_name stringlengths 5 116 | max_issues_repo_head_hexsha stringlengths 40 78 | max_issues_repo_licenses listlengths 1 9 | max_issues_count float64 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 3 270 | max_forks_repo_name stringlengths 5 116 | max_forks_repo_head_hexsha stringlengths 40 78 | max_forks_repo_licenses listlengths 1 9 | max_forks_count float64 1 105k ⌀ | max_forks_repo_forks_event_min_datetime stringlengths 24 24 ⌀ | max_forks_repo_forks_event_max_datetime stringlengths 24 24 ⌀ | content stringlengths 19 11.4M | avg_line_length float64 1.93 229k | max_line_length int64 12 688k | alphanum_fraction float64 0.07 0.99 | matches listlengths 1 10 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
11b06694631310e5f28fc22cb23f2b01d3afee7f | 621 | cpp | C++ | 22_Algorithms/SoftUni_Algorithms/01_Recursion/CPP_RecursionLab/01_RecursiveArraySum/01_RecursiveArraySum.cpp | Knightwalker/Knowledgebase | 00c6dea5e52c0d2b0fe0dc3b7b5c298d445f0161 | [
"MIT"
] | null | null | null | 22_Algorithms/SoftUni_Algorithms/01_Recursion/CPP_RecursionLab/01_RecursiveArraySum/01_RecursiveArraySum.cpp | Knightwalker/Knowledgebase | 00c6dea5e52c0d2b0fe0dc3b7b5c298d445f0161 | [
"MIT"
] | null | null | null | 22_Algorithms/SoftUni_Algorithms/01_Recursion/CPP_RecursionLab/01_RecursiveArraySum/01_RecursiveArraySum.cpp | Knightwalker/Knowledgebase | 00c6dea5e52c0d2b0fe0dc3b7b5c298d445f0161 | [
"MIT"
] | null | null | null | #include <iostream>
#include <sstream>
#include <string>
#include <vector>
using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;
using std::istringstream;
static int Sum(vector<int> & vect, int index);
int main()
{
string input = ""; getline(cin, input);
istringstream ss(input);
vector<int> numbersVect;
int number = 0;
while (ss >> number) {
numbersVect.push_back(number);
}
int sum = Sum(numbersVect, 0);
cout << sum << endl;
}
static int Sum(vector<int> & vect, int index) {
if (index == vect.size()) {
return 0;
}
return vect[index] + Sum(vect, index + 1);
} | 16.342105 | 47 | 0.658615 | [
"vector"
] |
11b5db34705cc4aaf73507898db68d47c08e7013 | 9,144 | cpp | C++ | video/ScreamCongestionController.cpp | UnigramDev/libtgvoip | e44c281d03b17a59fb4999f172be9a2814ba964f | [
"Unlicense"
] | 3 | 2019-09-05T09:42:24.000Z | 2022-02-22T18:46:00.000Z | video/ScreamCongestionController.cpp | UnigramDev/libtgvoip | e44c281d03b17a59fb4999f172be9a2814ba964f | [
"Unlicense"
] | null | null | null | video/ScreamCongestionController.cpp | UnigramDev/libtgvoip | e44c281d03b17a59fb4999f172be9a2814ba964f | [
"Unlicense"
] | 1 | 2019-03-04T21:02:42.000Z | 2019-03-04T21:02:42.000Z | //
// Created by Grishka on 25/02/2019.
//
#include <algorithm>
#include <math.h>
#include "ScreamCongestionController.h"
#include "../logging.h"
#include "../VoIPController.h"
using namespace tgvoip;
using namespace tgvoip::video;
namespace{
/*static*/ constexpr float QDELAY_TARGET_LO=0.1f; // seconds
/*static*/ constexpr float QDELAY_TARGET_HI=0.4f; // seconds
/*static*/ constexpr float QDELAY_WEIGHT=0.1f;
/*static*/ constexpr float QDELAY_TREND_TH=0.2f;
/*static*/ constexpr uint32_t MIN_CWND=3000; // bytes
/*static*/ constexpr float MAX_BYTES_IN_FLIGHT_HEAD_ROOM=1.1f;
/*static*/ constexpr float GAIN=1.0f;
/*static*/ constexpr float BETA_LOSS=0.9f;
/*static*/ constexpr float BETA_ECN=0.9f;
/*static*/ constexpr float BETA_R=0.9f;
/*static*/ constexpr uint32_t MSS=1024;
/*static*/ constexpr float RATE_ADJUST_INTERVAL=0.2f;
/*static*/ constexpr uint32_t TARGET_BITRATE_MIN=50*1024; // bps
/*static*/ constexpr uint32_t TARGET_BITRATE_MAX=500*1024; // bps
/*static*/ constexpr uint32_t RAMP_UP_SPEED=200000; // bps/s
/*static*/ constexpr float PRE_CONGESTION_GUARD=0.1f;
/*static*/ constexpr float TX_QUEUE_SIZE_FACTOR=1.0f;
/*static*/ constexpr float RTP_QDELAY_TH=0.02f; // seconds
/*static*/ constexpr float TARGET_RATE_SCALE_RTP_QDELAY=0.95f;
/*static*/ constexpr float QDELAY_TREND_LO=0.2f;
/*static*/ constexpr float T_RESUME_FAST_INCREASE=5.0f; // seconds
/*static*/ constexpr uint32_t RATE_PACE_MIN=50000; // bps
}
ScreamCongestionController::ScreamCongestionController() : qdelayTarget(QDELAY_TARGET_LO), cwnd(MIN_CWND) {
}
void ScreamCongestionController::UpdateVariables(float qdelay){
float qdelayFraction=qdelay/qdelayTarget;
qdelayFractionAvg=(1.0f-QDELAY_WEIGHT)*qdelayFractionAvg+qdelayFraction*QDELAY_WEIGHT;
qdelayFractionHist.Add(qdelayFraction);
float avg=qdelayFractionHist.Average();
float r1=0.0, r0=0.0;
for(int i=(int)qdelayFractionHist.Size()-1;i>=0;i--){
float v=qdelayFractionHist[i]-avg;
r0+=v*v;
}
for(int i=(int)qdelayFractionHist.Size()-1;i>=1;i--){
float v1=qdelayFractionHist[i]-avg;
float v2=qdelayFractionHist[i-1]-avg;
r1+=v1*v2;
}
float a=r1/r0;
qdelayTrend=std::min(1.0f, std::max(0.0f, a*qdelayFractionAvg));
qdelayTrendMem=std::max(0.99f*qdelayTrendMem, qdelayTrend);
if(qdelayTrend>QDELAY_TREND_LO){
lastTimeQDelayTrendWasGreaterThanLo=VoIPController::GetCurrentTime();
}
}
void ScreamCongestionController::UpdateCWnd(float qdelay){
if(inFastIncrease){
if(qdelayTrend>=QDELAY_TREND_TH){
inFastIncrease=false;
}else{
if((float)bytesInFlight*1.5f+bytesNewlyAcked>cwnd){
LOGD("HERE");
cwnd+=bytesNewlyAcked;
}
return;
}
}
float offTarget=(qdelayTarget-qdelay)/qdelayTarget;
float gain=GAIN;
float cwndDelta=gain*offTarget*bytesNewlyAcked*MSS/(float)cwnd;
if(offTarget>0 && (float)bytesInFlight*1.25f+bytesNewlyAcked<=cwnd){
cwndDelta=0.0;
}
cwnd+=cwndDelta;
cwnd=std::min(cwnd, (uint32_t)(maxBytesInFlight*MAX_BYTES_IN_FLIGHT_HEAD_ROOM));
cwnd=std::max(cwnd, MIN_CWND);
}
void ScreamCongestionController::AdjustQDelayTarget(float qdelay){
float qdelayNorm=qdelay/QDELAY_TARGET_LO;
qdelayNormHist.Add(qdelayNorm);
float qdelayNormAvg=qdelayNormHist.Average();
float qdelayNormVar=0.0;
for(uint32_t i=0;i<qdelayNormHist.Size();i++){
float tmp=qdelayNormHist[i]-qdelayNormAvg;
qdelayNormVar+=tmp*tmp;
}
qdelayNormVar/=qdelayNormHist.Size();
float newTarget=qdelayNormAvg+sqrt(qdelayNormVar);
newTarget*=QDELAY_TARGET_LO;
if(lossEventRate>0.002f){
qdelayTarget=1.5f*newTarget;
}else{
if(qdelayNormVar<0.2f){
qdelayTarget=newTarget;
}else{
if(newTarget<QDELAY_TARGET_LO){
qdelayTarget=std::max(qdelayTarget*0.5f, newTarget);
}else{
qdelayTarget*=0.9;
}
}
}
qdelayTarget=std::min(QDELAY_TARGET_HI, qdelayTarget);
qdelayTarget=std::max(QDELAY_TARGET_LO, qdelayTarget);
}
void ScreamCongestionController::AdjustBitrate(){
if(lossPending){
lossPending=false;
targetBitrate=std::max((uint32_t)(BETA_R*(float)targetBitrate), TARGET_BITRATE_MIN);
return;
}
float rampUpSpeed=std::min(RAMP_UP_SPEED, targetBitrate/2);
float scale=(float)(targetBitrate-targetBitrateLastMax)/(float)targetBitrateLastMax;
scale=std::max(0.2f, std::min(1.0f, (scale*4)*(scale*4)));
float currentRate=std::max(rateTransmit, rateAck);
if(inFastIncrease){
float increment=(rampUpSpeed*RATE_ADJUST_INTERVAL)*scale;
targetBitrate+=increment;
}else{
float deltaRate=currentRate*(1.0f-PRE_CONGESTION_GUARD*qdelayTrend)-TX_QUEUE_SIZE_FACTOR*(float)rtpQueueSize;
if(deltaRate>0.0f){
deltaRate*=scale;
deltaRate=std::min(deltaRate, rampUpSpeed*RATE_ADJUST_INTERVAL);
}
targetBitrate+=deltaRate;
float rtpQueueDelay=(float)rtpQueueSize/currentRate;
if(rtpQueueDelay>RTP_QDELAY_TH){
targetBitrate=(uint32_t)((float)targetBitrate*TARGET_RATE_SCALE_RTP_QDELAY);
}
}
float rateMediaLimit=std::max(currentRate, std::max(rateMedia, rateMediaMedian));
rateMediaLimit*=(2.0-qdelayTrendMem);
targetBitrate=std::min(targetBitrate, (uint32_t)rateMediaLimit);
targetBitrate=std::min(TARGET_BITRATE_MAX, std::max(TARGET_BITRATE_MIN, targetBitrate));
}
void ScreamCongestionController::CalculateSendWindow(float qdelay){
if(qdelay<=qdelayTarget)
sendWnd=cwnd+MSS-bytesInFlight;
else
sendWnd=cwnd-bytesInFlight;
}
void ScreamCongestionController::ProcessAcks(float oneWayDelay, uint32_t bytesNewlyAcked, uint32_t lossCount, double rtt){
if(prevOneWayDelay!=0.0f){
double currentTime=VoIPController::GetCurrentTime();
float qdelay=oneWayDelay-prevOneWayDelay;
sRTT=(float)rtt;
bytesInFlight-=bytesNewlyAcked;
rtpQueueSize-=(bytesNewlyAcked*8);
UpdateBytesInFlightHistory();
bytesAcked+=bytesNewlyAcked;
//LOGV("Scream: qdelay = %f, newly acked = %u, in flight = %u, losses = %u", qdelay, bytesNewlyAcked, bytesInFlight, lossCount);
if(currentTime-lastVariablesUpdateTime>=0.050){
lastVariablesUpdateTime=currentTime;
UpdateVariables(qdelay);
}
if(currentTime-lastRateAdjustmentTime>=RATE_ADJUST_INTERVAL){
lastRateAdjustmentTime=currentTime;
AdjustBitrate();
//LOGV("Scream: target bitrate = %u", targetBitrate);
}
if(lossCount>prevLossCount && currentTime>ignoreLossesUntil){
LOGD("Scream: loss detected");
ignoreLossesUntil=currentTime+rtt;
LOGD("ignoring losses for %f", rtt);
inFastIncrease=false;
cwnd=std::max(MIN_CWND, (uint32_t)(cwnd*BETA_LOSS));
AdjustQDelayTarget(qdelay);
CalculateSendWindow(qdelay);
lossPending=true;
lastTimeQDelayTrendWasGreaterThanLo=currentTime;
}else{
this->bytesNewlyAcked+=bytesNewlyAcked;
if(currentTime-lastCWndUpdateTime>=0.15){
lastCWndUpdateTime=currentTime;
UpdateCWnd(qdelay);
//LOGI("Scream: cwnd = %u", cwnd);
this->bytesNewlyAcked=0;
}
AdjustQDelayTarget(qdelay);
CalculateSendWindow(qdelay);
if(!inFastIncrease){
if(currentTime-lastTimeQDelayTrendWasGreaterThanLo>=T_RESUME_FAST_INCREASE){
inFastIncrease=true;
}
}
}
prevLossCount=lossCount;
}
prevOneWayDelay=oneWayDelay;
}
void ScreamCongestionController::ProcessPacketSent(uint32_t size){
bytesInFlight+=size;
rtpQueueSize+=(size*8);
bytesSent+=size;
double currentTime=VoIPController::GetCurrentTime();
if(currentTime-rateTransmitUpdateTime>=0.2){
rateTransmit=(float)(bytesSent*8)/(float)(currentTime-rateTransmitUpdateTime);
rateAck=(float)(bytesAcked*8)/(float)(currentTime-rateTransmitUpdateTime);
rateTransmitUpdateTime=currentTime;
bytesSent=0;
bytesAcked=0;
//LOGV("rateTransmit %f, rateAck %f", rateTransmit, rateAck);
}
UpdateBytesInFlightHistory();
}
void ScreamCongestionController::ProcessPacketLost(uint32_t size){
bytesInFlight-=size;
rtpQueueSize-=(size*8);
UpdateBytesInFlightHistory();
}
double ScreamCongestionController::GetPacingInterval(){
float paceBitrate=std::max((float)RATE_PACE_MIN, cwnd*8.0f/sRTT);
//LOGV("RTT=%f cwnd=%u paceBitrate=%f fastIncrease=%d", sRTT, cwnd, paceBitrate, inFastIncrease);
double pacingInterval=rtpSize*8.0f/paceBitrate;
return std::min(0.010, pacingInterval);
}
void ScreamCongestionController::UpdateBytesInFlightHistory(){
double currentTime=VoIPController::GetCurrentTime();
ValueSample now={bytesInFlight, currentTime};
bytesInFlightHistory.push_back(now);
uint32_t max=0;
for(std::vector<ValueSample>::iterator i=bytesInFlightHistory.begin();i!=bytesInFlightHistory.end();){
if(currentTime-i->time>=5.0){
i=bytesInFlightHistory.erase(i);
}else{
max=std::max(max, i->sample);
++i;
}
}
maxBytesInFlight=max;
}
void ScreamCongestionController::UpdateMediaRate(uint32_t frameSize){
bytesMedia+=frameSize;
double currentTime=VoIPController::GetCurrentTime();
if(currentTime-rateMediaUpdateTime>=0.5){
rateMedia=(float)(bytesMedia*8)/(float)(currentTime-rateMediaUpdateTime);
bytesMedia=0;
rateMediaUpdateTime=currentTime;
LOGV("rateMedia %f", rateMedia);
rateMediaHistory.Add(rateMedia);
rateMediaMedian=rateMediaHistory.NonZeroAverage();
}
}
uint32_t ScreamCongestionController::GetBitrate(){
return targetBitrate;
}
| 32.892086 | 133 | 0.757218 | [
"vector"
] |
11b6194b34ef388a15ae674cac437f50d7ee0ea0 | 2,103 | cpp | C++ | Phoenix3D/PX2Graphics/PX2VertexShader.cpp | PheonixFoundation/Phoenix3D | bfb2e3757bf61ac461aeeda9216bf8c8fdf76d99 | [
"BSL-1.0"
] | 36 | 2016-04-24T01:40:38.000Z | 2022-01-18T07:32:26.000Z | Phoenix3D/PX2Graphics/PX2VertexShader.cpp | PheonixFoundation/Phoenix3D | bfb2e3757bf61ac461aeeda9216bf8c8fdf76d99 | [
"BSL-1.0"
] | null | null | null | Phoenix3D/PX2Graphics/PX2VertexShader.cpp | PheonixFoundation/Phoenix3D | bfb2e3757bf61ac461aeeda9216bf8c8fdf76d99 | [
"BSL-1.0"
] | 16 | 2016-06-13T08:43:51.000Z | 2020-09-15T13:25:58.000Z | // PX2VertexShader.cpp
#include "PX2VertexShader.hpp"
#include "PX2Renderer.hpp"
using namespace PX2;
PX2_IMPLEMENT_RTTI(PX2, Shader, VertexShader);
PX2_IMPLEMENT_STREAM(VertexShader);
PX2_IMPLEMENT_FACTORY(VertexShader);
PX2_IMPLEMENT_DEFAULT_NAMES(Shader, VertexShader);
PX2_IMPLEMENT_DEFAULT_STREAM(Shader, VertexShader);
VertexShader::Profile VertexShader::msProfile = VertexShader::VP_NONE;
//----------------------------------------------------------------------------
VertexShader::VertexShader (const std::string& programName, int numInputs,
int numOutputs, int numConstants, int numSamplers, bool profileOwner)
:
Shader(programName, numInputs, numOutputs, numConstants, numSamplers,
profileOwner)
{
}
//----------------------------------------------------------------------------
VertexShader::~VertexShader ()
{
Renderer::UnbindAll(this);
}
//----------------------------------------------------------------------------
void VertexShader::SetProfile (Profile profile)
{
msProfile = profile;
}
//----------------------------------------------------------------------------
VertexShader::Profile VertexShader::GetProfile ()
{
return msProfile;
}
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
// Property
//----------------------------------------------------------------------------
void VertexShader::RegistProperties ()
{
Shader::RegistProperties();
AddPropertyClass("VertexShader");
std::vector<std::string> profiles;
profiles.push_back("VP_NONE");
profiles.push_back("VP_VS_1_1");
profiles.push_back("VP_VS_2_0");
profiles.push_back("VP_VS_3_0");
profiles.push_back("VP_ARBVP1");
profiles.push_back("VP_OPENGLES2");
AddPropertyEnum("Profile", (int)GetProfile(), profiles, false);
}
//----------------------------------------------------------------------------
void VertexShader::OnPropertyChanged (const PropertyObject &obj)
{
Shader::OnPropertyChanged(obj);
}
//---------------------------------------------------------------------------- | 33.380952 | 78 | 0.515454 | [
"vector"
] |
11c091fe5ec3f46b71af192bed7bf5374ae719fb | 20,460 | cc | C++ | lib/Support/OslScop.cc | hanchenye/polymer | 38e0230473756fbcbc5c4306f65ecd06901b3096 | [
"MIT"
] | null | null | null | lib/Support/OslScop.cc | hanchenye/polymer | 38e0230473756fbcbc5c4306f65ecd06901b3096 | [
"MIT"
] | null | null | null | lib/Support/OslScop.cc | hanchenye/polymer | 38e0230473756fbcbc5c4306f65ecd06901b3096 | [
"MIT"
] | null | null | null | //===- OslScop.cc -----------------------------------------------*- C++ -*-===//
//
// This file implements the C++ wrapper for the Scop struct in OpenScop.
//
//===----------------------------------------------------------------------===//
#include "polymer/Support/OslScop.h"
#include "polymer/Support/ScatteringUtils.h"
#include "polymer/Support/ScopStmt.h"
#include "osl/osl.h"
#include "mlir/Dialect/Affine/Analysis/AffineAnalysis.h"
#include "mlir/Dialect/Affine/Analysis/AffineStructures.h"
#include "mlir/Dialect/Affine/IR/AffineOps.h"
#include "mlir/Dialect/Affine/IR/AffineValueMap.h"
#include "mlir/Dialect/Func/IR/FuncOps.h"
#include "mlir/IR/Attributes.h"
#include "mlir/IR/BuiltinOps.h"
#include "mlir/IR/Operation.h"
#include "mlir/IR/Value.h"
#include "mlir/Support/LogicalResult.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/SetVector.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/FormatVariadic.h"
#include "llvm/Support/raw_ostream.h"
#include <vector>
using namespace polymer;
using namespace mlir;
using namespace llvm;
#define DEBUG_TYPE "oslscop"
/// Create osl_vector from a STL vector. Since the input vector is of type
/// int64_t, we can safely assume the osl_vector we will generate has 64 bits
/// precision. The input vector doesn't contain the e/i indicator.
static void getOslVector(bool isEq, llvm::ArrayRef<int64_t> vec,
osl_vector_p *oslVec) {
*oslVec = osl_vector_pmalloc(64, vec.size() + 1);
// Set the e/i field.
osl_int_t val;
val.dp = isEq ? 0 : 1;
(*oslVec)->v[0] = val;
// Set the rest of the vector.
for (int i = 0, e = vec.size(); i < e; i++) {
osl_int_t val;
val.dp = vec[i];
(*oslVec)->v[i + 1] = val;
}
}
/// Get the statement given by its index.
static osl_statement_p getOslStatement(osl_scop_p scop, unsigned index) {
osl_statement_p stmt = scop->statement;
for (unsigned i = 0; i <= index; i++) {
// stmt accessed in the linked list before counting to index should not be
// NULL.
assert(stmt && "index exceeds the range of statements in scop.");
if (i == index)
return stmt;
stmt = stmt->next;
}
return nullptr;
}
OslScop::OslScop() {
scatTreeRoot = std::make_unique<ScatTreeNode>();
scop = osl_scop_malloc();
// Initialize string buffer for language.
OSL_strdup(scop->language, "C");
// Use the default interface registry
osl_interface_p registry = osl_interface_get_default_registry();
scop->registry = osl_interface_clone(registry);
}
OslScop::OslScop(osl_scop *scop)
: scop(scop), scatTreeRoot{std::make_unique<ScatTreeNode>()} {}
OslScop::~OslScop() { osl_scop_free(scop); }
void OslScop::print() { osl_scop_print(stdout, scop); }
bool OslScop::validate() {
// TODO: do we need to check the scoplib compatibility?
return osl_scop_integrity_check(scop);
}
void OslScop::createStatement() {
osl_statement_p stmt = osl_statement_malloc();
osl_statement_add(&(scop->statement), stmt);
}
void OslScop::addRelation(int target, int type, int numRows, int numCols,
int numOutputDims, int numInputDims, int numLocalDims,
int numParams, llvm::ArrayRef<int64_t> eqs,
llvm::ArrayRef<int64_t> inEqs) {
// Here we preset the precision to 64.
osl_relation_p rel = osl_relation_pmalloc(64, numRows, numCols);
rel->type = type;
rel->nb_output_dims = numOutputDims;
rel->nb_input_dims = numInputDims;
rel->nb_local_dims = numLocalDims;
rel->nb_parameters = numParams;
// The number of columns in the given equalities and inequalities, which is
// one less than the number of columns in the OSL representation (missing e/i
// indicator).
size_t numColsInEqs = numCols - 1;
assert(eqs.size() % numColsInEqs == 0 &&
"Number of elements in the eqs should be an integer multiply of "
"numColsInEqs");
size_t numEqs = eqs.size() / numColsInEqs;
// Replace those allocated vector elements in rel.
for (int i = 0; i < numRows; i++) {
osl_vector_p vec;
if (i >= static_cast<int>(numEqs)) {
auto inEq = llvm::ArrayRef<int64_t>(&inEqs[(i - numEqs) * numColsInEqs],
numColsInEqs);
getOslVector(false, inEq, &vec);
} else {
auto eq = llvm::ArrayRef<int64_t>(&eqs[i * numColsInEqs], numColsInEqs);
getOslVector(true, eq, &vec);
}
// Replace the vector content of the i-th row by the contents in
// constraints.
osl_relation_replace_vector(rel, vec, i);
}
LLVM_DEBUG({
dbgs() << "Newly created relation: ";
osl_relation_dump(stderr, rel);
});
// Append the newly created relation to a target linked list, or simply set it
// to a relation pointer, which is indicated by the target argument.
if (target == 0) {
// Simply assign the newly created relation to the context field.
scop->context = rel;
} else {
// Get the pointer to the statement.
osl_statement_p stmt = getOslStatement(scop, target - 1);
// Depending on the type of the relation, we decide which field of the
// statement we should set.
if (type == OSL_TYPE_DOMAIN) {
stmt->domain = rel;
} else if (type == OSL_TYPE_SCATTERING) {
stmt->scattering = rel;
} else if (type == OSL_TYPE_ACCESS || type == OSL_TYPE_WRITE ||
type == OSL_TYPE_READ) {
osl_relation_list_p relList = osl_relation_list_malloc();
relList->elt = rel;
osl_relation_list_add(&(stmt->access), relList);
}
}
}
void OslScop::addContextRelation(FlatAffineValueConstraints cst) {
// Project out the dim IDs in the context with only the symbol IDs left.
SmallVector<mlir::Value, 8> dimValues;
cst.getValues(0, cst.getNumDimIds(), &dimValues);
for (mlir::Value dimValue : dimValues)
cst.projectOut(dimValue);
if (cst.getNumDimAndSymbolIds() > 0)
cst.removeIndependentConstraints(0, cst.getNumDimAndSymbolIds());
SmallVector<int64_t, 8> eqs, inEqs;
// createConstraintRows(cst, eqs);
// createConstraintRows(cst, inEqs, /*isEq=*/false);
unsigned numCols = 2 + cst.getNumSymbolIds();
unsigned numEntries = inEqs.size() + eqs.size();
assert(numEntries % (numCols - 1) == 0 &&
"Total number of entries should be divisible by the number of columns "
"(excluding e/i)");
unsigned numRows = (inEqs.size() + eqs.size()) / (numCols - 1);
// Create the context relation.
addRelation(0, OSL_TYPE_CONTEXT, numRows, numCols, 0, 0, 0,
cst.getNumSymbolIds(), eqs, inEqs);
}
void OslScop::addDomainRelation(int stmtId, FlatAffineValueConstraints &cst) {
SmallVector<int64_t, 8> eqs, inEqs;
createConstraintRows(cst, eqs);
createConstraintRows(cst, inEqs, /*isEq=*/false);
addRelation(stmtId + 1, OSL_TYPE_DOMAIN, cst.getNumConstraints(),
cst.getNumCols() + 1, cst.getNumDimIds(), 0, cst.getNumLocalIds(),
cst.getNumSymbolIds(), eqs, inEqs);
}
void OslScop::addScatteringRelation(int stmtId,
mlir::FlatAffineValueConstraints &cst,
llvm::ArrayRef<mlir::Operation *> ops) {
// First insert the enclosing ops into the scat tree.
SmallVector<unsigned, 8> scats;
scatTreeRoot->insertScopStmt(ops, scats);
// Elements (N of them) in `scattering` are constants, and there are IVs
// interleaved them. Therefore, we have 2N - 1 number of scattering
// equalities.
unsigned numScatEqs = scats.size() * 2 - 1;
// Columns include new scattering dimensions and those from the domain.
unsigned numScatCols = numScatEqs + cst.getNumCols() + 1;
// Create equalities and inequalities.
std::vector<int64_t> eqs, inEqs;
// Initialize contents for equalities.
eqs.resize(numScatEqs * (numScatCols - 1));
for (unsigned j = 0; j < numScatEqs; j++) {
// Initializing scattering dimensions by setting the diagonal to -1.
for (unsigned k = 0; k < numScatEqs; k++)
eqs[j * (numScatCols - 1) + k] = -static_cast<int64_t>(k == j);
// Relating the loop IVs to the scattering dimensions. If it's the odd
// equality, set its scattering dimension to the loop IV; otherwise, it's
// scattering dimension will be set in the following constant section.
for (unsigned k = 0; k < cst.getNumDimIds(); k++)
eqs[j * (numScatCols - 1) + k + numScatEqs] =
(j % 2) ? (k == (j / 2)) : 0;
// TODO: consider the parameters that may appear in the scattering
// dimension.
for (unsigned k = 0; k < cst.getNumLocalIds() + cst.getNumSymbolIds(); k++)
eqs[j * (numScatCols - 1) + k + numScatEqs + cst.getNumDimIds()] = 0;
// Relating the constants (the last column) to the scattering dimensions.
eqs[j * (numScatCols - 1) + numScatCols - 2] = (j % 2) ? 0 : scats[j / 2];
}
// Then put them into the scop as a SCATTERING relation.
addRelation(stmtId + 1, OSL_TYPE_SCATTERING, numScatEqs, numScatCols,
numScatEqs, cst.getNumDimIds(), cst.getNumLocalIds(),
cst.getNumSymbolIds(), eqs, inEqs);
}
void OslScop::addAccessRelation(int stmtId, bool isRead, mlir::Value memref,
AffineValueMap &vMap,
FlatAffineValueConstraints &domain) {
FlatAffineValueConstraints cst;
// Insert the address dims and put constraints in it.
createAccessRelationConstraints(vMap, cst, domain);
// Create a new dim of memref and set its value to its corresponding ID.
memRefIdMap.try_emplace(memref, memRefIdMap.size() + 1);
cst.insertDimId(0, memref);
cst.addBound(mlir::FlatAffineConstraints::BoundType::EQ, 0,
memRefIdMap[memref]);
// cst.setIdToConstant(0, memRefIdMap[memref]);
SmallVector<int64_t, 8> eqs, inEqs;
createConstraintRows(cst, eqs);
createConstraintRows(cst, inEqs, /*isEq=*/false);
for (unsigned i = 0; i < eqs.size(); i++)
eqs[i] = -eqs[i];
LLVM_DEBUG({
dbgs() << "Resolved access constraints: \n";
cst.dump();
});
// Then put them into the scop as an ACCESS relation.
// Number of access indices + 1 for the memref ID.
unsigned numOutputDims = vMap.getNumResults() + 1;
unsigned numInputDims = cst.getNumDimIds() - numOutputDims;
addRelation(stmtId + 1, isRead ? OSL_TYPE_READ : OSL_TYPE_WRITE,
cst.getNumConstraints(), cst.getNumCols() + 1, numOutputDims,
numInputDims, cst.getNumLocalIds(), cst.getNumSymbolIds(), eqs,
inEqs);
}
void OslScop::addGeneric(int target, llvm::StringRef tag,
llvm::StringRef content) {
osl_generic_p generic = osl_generic_malloc();
// Add interface.
osl_interface_p interface = osl_interface_lookup(scop->registry, tag.data());
generic->interface = osl_interface_nclone(interface, 1);
// Add content
char *buf;
OSL_malloc(buf, char *, (content.size() * sizeof(char) + 10));
OSL_strdup(buf, content.data());
generic->data = interface->sread(&buf);
if (target == 0) {
// Add to Scop extension.
osl_generic_add(&(scop->extension), generic);
} else if (target == -1) {
// Add to Scop parameters.
osl_generic_add(&(scop->parameters), generic);
} else {
// Add to statement.
osl_statement_p stmt = getOslStatement(scop, target - 1);
osl_generic_add(&(stmt->extension), generic);
}
}
void OslScop::addExtensionGeneric(llvm::StringRef tag,
llvm::StringRef content) {
addGeneric(0, tag, content);
}
void OslScop::addParametersGeneric(llvm::StringRef tag,
llvm::StringRef content) {
addGeneric(-1, tag, content);
}
void OslScop::addStatementGeneric(int stmtId, llvm::StringRef tag,
llvm::StringRef content) {
addGeneric(stmtId + 1, tag, content);
}
/// We determine whether the name refers to a symbol by looking up the parameter
/// list of the scop.
bool OslScop::isSymbol(llvm::StringRef name) {
osl_generic_p parameters = scop->parameters;
if (!parameters)
return false;
assert(parameters->next == NULL &&
"Should only exist one parameters generic object.");
assert(osl_generic_has_URI(parameters, OSL_URI_STRINGS) &&
"Parameters should be of strings interface.");
// TODO: cache this result, otherwise we need O(N) each time calling this API.
osl_strings_p parameterNames =
reinterpret_cast<osl_strings_p>(parameters->data);
unsigned numParameters = osl_strings_size(parameterNames);
for (unsigned i = 0; i < numParameters; i++)
if (name.equals(parameterNames->string[i]))
return true;
return false;
}
LogicalResult OslScop::getStatement(unsigned index,
osl_statement **stmt) const {
// TODO: cache all the statements.
osl_statement_p curr = scop->statement;
if (!curr)
return failure();
for (unsigned i = 0; i < index; i++) {
curr = curr->next;
if (!curr)
return failure();
}
*stmt = curr;
return success();
}
unsigned OslScop::getNumStatements() const {
return osl_statement_number(scop->statement);
}
osl_generic_p OslScop::getExtension(llvm::StringRef tag) const {
osl_generic_p ext = scop->extension;
osl_interface_p interface = osl_interface_lookup(scop->registry, tag.data());
while (ext) {
if (osl_interface_equal(ext->interface, interface))
return ext;
ext = ext->next;
}
return nullptr;
}
void OslScop::addParameterNames() {
std::string body;
llvm::raw_string_ostream ss(body);
SmallVector<std::string, 8> names;
for (const auto &it : symbolTable)
if (isParameterSymbol(it.first()))
names.push_back(std::string(it.first()));
std::sort(names.begin(), names.end());
for (const auto &s : names)
ss << s << " ";
addParametersGeneric("strings", body);
}
void OslScop::addScatnamesExtension() {
std::string body;
llvm::raw_string_ostream ss(body);
unsigned numScatnames = scatTreeRoot->getDepth();
numScatnames = (numScatnames - 2) * 2 + 1;
for (unsigned i = 0; i < numScatnames; i++)
ss << formatv("c{0}", i + 1) << " ";
addExtensionGeneric("scatnames", body);
}
void OslScop::addArraysExtension() {
std::string body;
llvm::raw_string_ostream ss(body);
unsigned numArraySymbols = 0;
for (const auto &it : symbolTable)
if (isArraySymbol(it.first())) {
ss << it.first().drop_front() << " " << it.first() << " ";
numArraySymbols++;
}
addExtensionGeneric("arrays",
std::string(formatv("{0} {1}", numArraySymbols, body)));
}
void OslScop::addBodyExtension(int stmtId, const ScopStmt &stmt) {
std::string body;
llvm::raw_string_ostream ss(body);
SmallVector<mlir::Operation *, 8> forOps;
stmt.getEnclosingOps(forOps, /*forOnly=*/true);
unsigned numIVs = forOps.size();
ss << numIVs << " ";
llvm::DenseMap<mlir::Value, unsigned> ivToId;
for (unsigned i = 0; i < numIVs; i++) {
mlir::AffineForOp forOp = cast<mlir::AffineForOp>(forOps[i]);
// forOp.dump();
ivToId[forOp.getInductionVar()] = i;
}
for (unsigned i = 0; i < numIVs; i++)
ss << "i" << i << " ";
mlir::func::CallOp caller = stmt.getCaller();
mlir::FuncOp callee = stmt.getCallee();
ss << "\n" << callee.getName() << "(";
SmallVector<std::string, 8> ivs;
llvm::SetVector<unsigned> visited;
for (unsigned i = 0; i < caller.getNumOperands(); i++) {
mlir::Value operand = caller.getOperand(i);
if (ivToId.find(operand) != ivToId.end()) {
ivs.push_back(std::string(formatv("i{0}", ivToId[operand])));
visited.insert(ivToId[operand]);
}
}
for (unsigned i = 0; i < numIVs; i++)
if (!visited.contains(i)) {
visited.insert(i);
ivs.push_back(std::string(formatv("i{0}", i)));
}
for (unsigned i = 0; i < ivs.size(); i++) {
ss << ivs[i];
if (i != ivs.size() - 1)
ss << ", ";
}
// for (unsigned i = 0; i < numIVs; i++) {
// ss << "i" << i;
// if (i != numIVs - 1)
// ss << ", ";
// }
ss << ")";
addGeneric(stmtId + 1, "body", body);
}
void OslScop::initializeSymbolTable(mlir::FuncOp f,
FlatAffineValueConstraints *cst) {
symbolTable.clear();
unsigned numDimIds = cst->getNumDimIds();
unsigned numSymbolIds = cst->getNumDimAndSymbolIds() - numDimIds;
SmallVector<mlir::Value, 8> dimValues, symbolValues;
cst->getValues(0, numDimIds, &dimValues);
cst->getValues(numDimIds, cst->getNumDimAndSymbolIds(), &symbolValues);
// Setup the symbol table.
for (unsigned i = 0; i < numDimIds; i++) {
std::string sym(formatv("i{0}", i));
symbolTable.insert(std::make_pair(sym, dimValues[i]));
valueTable.insert(std::make_pair(dimValues[i], sym));
}
for (unsigned i = 0; i < numSymbolIds; i++) {
std::string sym(formatv("P{0}", i));
symbolTable.insert(std::make_pair(sym, symbolValues[i]));
valueTable.insert(std::make_pair(symbolValues[i], sym));
}
for (const auto &it : memRefIdMap) {
std::string sym(formatv("A{0}", it.second));
symbolTable.insert(std::make_pair(sym, it.first));
valueTable.insert(std::make_pair(it.first, sym));
}
// constants
unsigned numConstants = 0;
for (mlir::Value arg : f.getBody().begin()->getArguments()) {
if (valueTable.find(arg) == valueTable.end()) {
std::string sym(formatv("C{0}", numConstants++));
symbolTable.insert(std::make_pair(sym, arg));
valueTable.insert(std::make_pair(arg, sym));
}
}
// Setup relative fields in the OpenScop representation.
// Parameter names
addParameterNames();
// Scat names
addScatnamesExtension();
// Array names
addArraysExtension();
}
bool OslScop::isParameterSymbol(llvm::StringRef name) const {
return name.startswith("P");
}
bool OslScop::isDimSymbol(llvm::StringRef name) const {
return name.startswith("i");
}
bool OslScop::isArraySymbol(llvm::StringRef name) const {
return name.startswith("A");
}
bool OslScop::isConstantSymbol(llvm::StringRef name) const {
return name.startswith("C");
}
void OslScop::createConstraintRows(FlatAffineValueConstraints &cst,
SmallVectorImpl<int64_t> &rows, bool isEq) {
unsigned numRows = isEq ? cst.getNumEqualities() : cst.getNumInequalities();
unsigned numDimIds = cst.getNumDimIds();
unsigned numLocalIds = cst.getNumLocalIds();
unsigned numSymbolIds = cst.getNumSymbolIds();
for (unsigned i = 0; i < numRows; i++) {
// Get the row based on isEq.
auto row = isEq ? cst.getEquality(i) : cst.getInequality(i);
unsigned numCols = row.size();
if (i == 0)
rows.resize(numRows * numCols);
// Dims stay at the same positions.
for (unsigned j = 0; j < numDimIds; j++)
rows[i * numCols + j] = row[j];
// Output local ids before symbols.
for (unsigned j = 0; j < numLocalIds; j++)
rows[i * numCols + j + numDimIds] = row[j + numDimIds + numSymbolIds];
// Output symbols in the end.
for (unsigned j = 0; j < numSymbolIds; j++)
rows[i * numCols + j + numDimIds + numLocalIds] = row[j + numDimIds];
// Finally outputs the constant.
rows[i * numCols + numCols - 1] = row[numCols - 1];
}
}
void OslScop::createAccessRelationConstraints(
mlir::AffineValueMap &vMap, mlir::FlatAffineValueConstraints &cst,
mlir::FlatAffineValueConstraints &domain) {
cst.reset();
cst.mergeAndAlignIdsWithOther(0, &domain);
LLVM_DEBUG({
dbgs() << "Building access relation.\n"
<< " + Domain:\n";
domain.dump();
});
SmallVector<mlir::Value, 8> idValues;
domain.getAllValues(&idValues);
llvm::SetVector<mlir::Value> idValueSet;
for (auto val : idValues)
idValueSet.insert(val);
for (auto operand : vMap.getOperands())
if (!idValueSet.contains(operand)) {
llvm::errs() << "Operand missing: ";
operand.dump();
}
// The results of the affine value map, which are the access addresses, will
// be placed to the leftmost of all columns.
assert(cst.composeMap(&vMap).succeeded());
}
OslScop::SymbolTable *OslScop::getSymbolTable() { return &symbolTable; }
OslScop::ValueTable *OslScop::getValueTable() { return &valueTable; }
OslScop::MemRefToId *OslScop::getMemRefIdMap() { return &memRefIdMap; }
OslScop::ScopStmtMap *OslScop::getScopStmtMap() { return &scopStmtMap; }
OslScop::ScopStmtNames *OslScop::getScopStmtNames() { return &scopStmtNames; }
| 33 | 80 | 0.650782 | [
"object",
"vector"
] |
11c97666042b1c0938d2c2f0e3833d07ed15201c | 29,449 | cpp | C++ | src/backends/backendsCommon/test/layerTests/L2NormalizationTestImpl.cpp | sahilbandar/armnn | 249950645b7bc0593582182097c7e2f1d6d97442 | [
"MIT"
] | 856 | 2018-03-09T17:26:23.000Z | 2022-03-24T21:31:33.000Z | src/backends/backendsCommon/test/layerTests/L2NormalizationTestImpl.cpp | sahilbandar/armnn | 249950645b7bc0593582182097c7e2f1d6d97442 | [
"MIT"
] | 623 | 2018-03-13T04:40:42.000Z | 2022-03-31T09:45:17.000Z | src/backends/backendsCommon/test/layerTests/L2NormalizationTestImpl.cpp | sahilbandar/armnn | 249950645b7bc0593582182097c7e2f1d6d97442 | [
"MIT"
] | 284 | 2018-03-09T23:05:28.000Z | 2022-03-29T14:42:28.000Z | //
// Copyright © 2017 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
#include "L2NormalizationTestImpl.hpp"
#include <QuantizeHelper.hpp>
#include <ResolveType.hpp>
#include <armnnUtils/TensorUtils.hpp>
#include <armnnUtils/Permute.hpp>
#include <backendsCommon/test/TensorCopyUtils.hpp>
#include <backendsCommon/test/WorkloadTestUtils.hpp>
#include <test/TensorHelpers.hpp>
#include <numeric>
namespace
{
template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>>
LayerTestResult<T, 4> L2NormalizationTestImpl(
armnn::IWorkloadFactory& workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
const armnn::ITensorHandleFactory& tensorHandleFactory,
const armnn::TensorShape& inputOutputTensorShape,
float scale,
int32_t offset,
const std::vector<float>& inputValues,
float outScale,
int32_t outOffset,
std::vector<float>& expectedOutputValues,
const armnn::DataLayout layout,
float epsilon = 1e-12f)
{
IgnoreUnused(memoryManager);
const armnn::TensorInfo inputTensorInfo(inputOutputTensorShape, ArmnnType, scale, offset);
const armnn::TensorInfo outputTensorInfo(inputOutputTensorShape, ArmnnType, outScale, outOffset);
// at this point if we require it permute the input data
const armnn::PermutationVector NCHWToNHWC = { 0, 3, 1, 2 };
std::vector<float> inputData = inputValues;
if (layout == armnn::DataLayout::NHWC)
{
std::vector<float> tmp(inputData.size());
armnnUtils::Permute(inputTensorInfo.GetShape(), NCHWToNHWC, inputData.data(), tmp.data(), sizeof(float));
inputData = tmp;
}
auto inputTensor = armnnUtils::QuantizedVector<T>(inputData,
inputTensorInfo.GetQuantizationScale(),
inputTensorInfo.GetQuantizationOffset());
std::vector<T> actualOutput(outputTensorInfo.GetNumElements());
if (layout == armnn::DataLayout::NHWC)
{
std::vector<float> tmp(expectedOutputValues.size());
armnnUtils::Permute(inputTensorInfo.GetShape(), NCHWToNHWC, expectedOutputValues.data(), tmp.data(),
sizeof(float));
expectedOutputValues = tmp;
}
std::vector<T> expectedOutputData = armnnUtils::QuantizedVector<T>(expectedOutputValues,
outputTensorInfo.GetQuantizationScale(),
outputTensorInfo.GetQuantizationOffset());
std::unique_ptr<armnn::ITensorHandle> inputHandle = tensorHandleFactory.CreateTensorHandle(inputTensorInfo);
std::unique_ptr<armnn::ITensorHandle> outputHandle = tensorHandleFactory.CreateTensorHandle(outputTensorInfo);
armnn::L2NormalizationQueueDescriptor descriptor;
descriptor.m_Parameters.m_Eps = epsilon;
descriptor.m_Parameters.m_DataLayout = layout;
armnn::WorkloadInfo info;
AddInputToWorkload(descriptor, info, inputTensorInfo, inputHandle.get());
AddOutputToWorkload(descriptor, info, outputTensorInfo, outputHandle.get());
std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateL2Normalization(descriptor, info);
inputHandle->Allocate();
outputHandle->Allocate();
CopyDataToITensorHandle(inputHandle.get(), inputTensor.data());
workload->PostAllocationConfigure();
ExecuteWorkload(*workload, memoryManager);
CopyDataFromITensorHandle(actualOutput.data(), outputHandle.get());
return LayerTestResult<T, 4>(actualOutput,
expectedOutputData,
outputHandle->GetShape(),
outputTensorInfo.GetShape());
}
float CalcInvL2Norm(std::initializer_list<float> elements)
{
const float reduction = std::accumulate(elements.begin(), elements.end(), 0.0f,
[](float acc, float element) { return acc + element * element; });
return 1.0f / sqrtf(reduction);
}
template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>>
LayerTestResult<T, 4> L2NormalizationEpsilonTestCommon(
armnn::IWorkloadFactory& workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
const armnn::ITensorHandleFactory& tensorHandleFactory,
float scale,
int32_t offset,
float outScale,
int32_t outOffset,
const armnn::DataLayout layout,
float epsilon)
{
// Width: 1
// Height: 1
// Channels: 3
// BatchSize: 1
unsigned int numberOfBatches = 1;
unsigned int numberOfChannels = 3;
unsigned int height = 1;
unsigned int width = 1;
const armnn::TensorShape inputOutputShape = armnnUtils::GetTensorShape(
numberOfBatches, numberOfChannels, height, width, layout);
// 0.0000001^2 + 0.00000002^2 + 0.00000003^2 < 1e-12
std::vector<float> inputValues
{
// Batch 0, Channel 0, Height (1) x Width (1)
0.00000001f,
// Batch 0, Channel 1, Height (1) x Width (1)
0.00000002f,
// Batch 0, Channel 2, Height (1) x Width (1)
0.00000003f,
};
const float approxInvL2Norm = 1.f / sqrtf(epsilon);
std::vector<float> expectedOutputValues
{
// Batch 0, Channel 0, Height (1) x Width (1)
0.00000001f * approxInvL2Norm,
0.00000002f * approxInvL2Norm,
0.00000003f * approxInvL2Norm,
};
return L2NormalizationTestImpl<ArmnnType>(
workloadFactory,
memoryManager,
tensorHandleFactory,
inputOutputShape,
scale,
offset,
inputValues,
outScale,
outOffset,
expectedOutputValues,
layout,
epsilon);
}
template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>>
LayerTestResult<T, 4> L2Normalization1dTestCommon(
armnn::IWorkloadFactory& workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
const armnn::ITensorHandleFactory& tensorHandleFactory,
float scale,
int32_t offset,
float outScale,
int32_t outOffset,
const armnn::DataLayout layout)
{
// Width: 1
// Height: 1
// Channels: 10
// BatchSize: 1
unsigned int numberOfBatches = 1;
unsigned int numberOfChannels = 10;
unsigned int height = 1;
unsigned int width = 1;
const armnn::TensorShape inputOutputShape = armnnUtils::GetTensorShape(
numberOfBatches, numberOfChannels, height, width, layout);
std::vector<float> inputValues
{
// Batch 0, Channel 0, Height (1) x Width (1)
1.0f,
// Batch 0, Channel 1, Height (1) x Width (1)
2.0f,
// Batch 0, Channel 2, Height (1) x Width (1)
3.0f,
// Batch 0, Channel 3, Height (1) x Width (1)
4.0f,
// Batch 0, Channel 4, Height (1) x Width (1)
5.0f,
// Batch 0, Channel 5, Height (1) x Width (1)
6.0f,
// Batch 0, Channel 6, Height (1) x Width (1)
7.0f,
// Batch 0, Channel 7, Height (1) x Width (1)
8.0f,
// Batch 0, Channel 8, Height (1) x Width (1)
9.0f,
// Batch 0, Channel 9, Height (1) x Width (1)
10.0f
};
const float approxInvL2Norm = 0.050964719f;
std::vector<float> expectedOutputValues
{
// Batch 0, Channel 0, Height (1) x Width (1)
1.0f * approxInvL2Norm,
2.0f * approxInvL2Norm,
3.0f * approxInvL2Norm,
4.0f * approxInvL2Norm,
5.0f * approxInvL2Norm,
6.0f * approxInvL2Norm,
7.0f * approxInvL2Norm,
8.0f * approxInvL2Norm,
9.0f * approxInvL2Norm,
10.0f * approxInvL2Norm
};
return L2NormalizationTestImpl<ArmnnType>(
workloadFactory,
memoryManager,
tensorHandleFactory,
inputOutputShape,
scale,
offset,
inputValues,
outScale,
outOffset,
expectedOutputValues,
layout);
}
template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>>
LayerTestResult<T, 4> L2Normalization2dTestCommon(
armnn::IWorkloadFactory& workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
const armnn::ITensorHandleFactory& tensorHandleFactory,
float scale,
int32_t offset,
float outScale,
int32_t outOffset,
const armnn::DataLayout layout)
{
// Width: 5
// Height: 1
// Channels: 2
// BatchSize: 1
unsigned int numberOfBatches = 1;
unsigned int numberOfChannels = 2;
unsigned int height = 1;
unsigned int width = 5;
const armnn::TensorShape inputOutputShape = armnnUtils::GetTensorShape(
numberOfBatches, numberOfChannels, height, width, layout);
std::vector<float> inputValues
{
// Batch 0, Channel 0, Height (1) x Width (5)
1.0f, 3.0f, 5.0f, 7.0f, 9.0f,
// Batch 0, Channel 1, Height (1) x Width (5)
2.0f, 4.0f, 6.0f, 8.0f, 10.0f
};
std::vector<float> expectedOutputValues
{
// Batch 0, Channel 0, Height (1) x Width (5)
1.0f * CalcInvL2Norm({ 1.0f, 2.0f }),
3.0f * CalcInvL2Norm({ 3.0f, 4.0f }),
5.0f * CalcInvL2Norm({ 5.0f, 6.0f }),
7.0f * CalcInvL2Norm({ 7.0f, 8.0f }),
9.0f * CalcInvL2Norm({ 9.0f, 10.0f }),
// Batch 0, Channel 1, Height (1) x Width (5)
2.0f * CalcInvL2Norm({ 1.0f, 2.0f }),
4.0f * CalcInvL2Norm({ 3.0f, 4.0f }),
6.0f * CalcInvL2Norm({ 5.0f, 6.0f }),
8.0f * CalcInvL2Norm({ 7.0f, 8.0f }),
10.0f * CalcInvL2Norm({ 9.0f, 10.0f })
};
return L2NormalizationTestImpl<ArmnnType>(
workloadFactory,
memoryManager,
tensorHandleFactory,
inputOutputShape,
scale,
offset,
inputValues,
outScale,
outOffset,
expectedOutputValues,
layout);
}
template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>>
LayerTestResult<T, 4> L2Normalization3dTestCommon(
armnn::IWorkloadFactory& workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
const armnn::ITensorHandleFactory& tensorHandleFactory,
float scale,
int32_t offset,
float outScale,
int32_t outOffset,
const armnn::DataLayout layout)
{
// Width: 3
// Height: 4
// Channels: 2
// BatchSize: 1
unsigned int numberOfBatches = 1;
unsigned int numberOfChannels = 2;
unsigned int height = 4;
unsigned int width = 3;
const armnn::TensorShape inputOutputShape = armnnUtils::GetTensorShape(
numberOfBatches, numberOfChannels, height, width, layout);
std::vector<float> inputValues
{
// Batch 0, Channel 0, Height (4) x Width (3)
119.0f, 21.0f, 150.0f,
149.0f, 32.0f, 179.0f,
15.0f, 227.0f, 141.0f,
147.0f, 199.0f, 220.0f,
// Batch 0, Channel 1, Height (4) x Width (3)
110.0f, 140.0f, 73.0f,
211.0f, 212.0f, 89.0f,
24.0f, 138.0f, 188.0f,
162.0f, 12.0f, 161.0f
};
std::vector<float> expectedOutputValues
{
// Batch 0, Channel 0, Height (4) x Width (3)
119.0f * CalcInvL2Norm({ 119.0f, 110.0f }),
21.0f * CalcInvL2Norm({ 21.0f, 140.0f }),
150.0f * CalcInvL2Norm({ 150.0f, 73.0f }),
149.0f * CalcInvL2Norm({ 149.0f, 211.0f }),
32.0f * CalcInvL2Norm({ 32.0f, 212.0f }),
179.0f * CalcInvL2Norm({ 179.0f, 89.0f }),
15.0f * CalcInvL2Norm({ 15.0f, 24.0f }),
227.0f * CalcInvL2Norm({ 227.0f, 138.0f }),
141.0f * CalcInvL2Norm({ 141.0f, 188.0f }),
147.0f * CalcInvL2Norm({ 147.0f, 162.0f }),
199.0f * CalcInvL2Norm({ 199.0f, 12.0f }),
220.0f * CalcInvL2Norm({ 220.0f, 161.0f }),
// Batch 0, Channel 1, Height (4) x Width (3)
110.0f * CalcInvL2Norm({ 119.0f, 110.0f }),
140.0f * CalcInvL2Norm({ 21.0f, 140.0f }),
73.0f * CalcInvL2Norm({ 150.0f, 73.0f }),
211.0f * CalcInvL2Norm({ 149.0f, 211.0f }),
212.0f * CalcInvL2Norm({ 32.0f, 212.0f }),
89.0f * CalcInvL2Norm({ 179.0f, 89.0f }),
24.0f * CalcInvL2Norm({ 15.0f, 24.0f }),
138.0f * CalcInvL2Norm({ 227.0f, 138.0f }),
188.0f * CalcInvL2Norm({ 141.0f, 188.0f }),
162.0f * CalcInvL2Norm({ 147.0f, 162.0f }),
12.0f * CalcInvL2Norm({ 199.0f, 12.0f }),
161.0f * CalcInvL2Norm({ 220.0f, 161.0f })
};
return L2NormalizationTestImpl<ArmnnType>(
workloadFactory,
memoryManager,
tensorHandleFactory,
inputOutputShape,
scale,
offset,
inputValues,
outScale,
outOffset,
expectedOutputValues,
layout);
}
template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>>
LayerTestResult<T, 4> L2Normalization4dTestCommon(
armnn::IWorkloadFactory& workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
const armnn::ITensorHandleFactory& tensorHandleFactory,
float scale,
int32_t offset,
float outScale,
int32_t outOffset,
const armnn::DataLayout layout)
{
// Width: 3
// Height: 4
// Channels: 3
// BatchSize: 2
unsigned int numberOfBatches = 2;
unsigned int numberOfChannels = 3;
unsigned int height = 4;
unsigned int width = 3;
const armnn::TensorShape inputOutputShape = armnnUtils::GetTensorShape(
numberOfBatches, numberOfChannels, height, width, layout);
std::vector<float> inputValues
{
// Batch 0, Channel 0, Height (4) x Width (3)
235.0f, 46.0f, 178.0f,
100.0f, 123.0f, 19.0f,
172.0f, 74.0f, 250.0f,
6.0f, 195.0f, 80.0f,
// Batch 0, Channel 1, Height (4) x Width (3)
113.0f, 95.0f, 202.0f,
77.0f, 114.0f, 71.0f,
122.0f, 246.0f, 166.0f,
82.0f, 28.0f, 37.0f,
// Batch 0, Channel 2, Height (4) x Width (3)
56.0f, 170.0f, 162.0f,
194.0f, 89.0f, 254.0f,
12.0f, 209.0f, 200.0f,
1.0f, 64.0f, 54.0f,
// Batch 1, Channel 0, Height (4) x Width (3)
67.0f, 90.0f, 49.0f,
7.0f, 163.0f, 18.0f,
25.0f, 117.0f, 103.0f,
247.0f, 59.0f, 189.0f,
// Batch 1, Channel 1, Height (4) x Width (3)
239.0f, 104.0f, 199.0f,
17.0f, 124.0f, 153.0f,
222.0f, 217.0f, 75.0f,
32.0f, 126.0f, 21.0f,
// Batch 1, Channel 2, Height (4) x Width (3)
97.0f, 145.0f, 215.0f,
115.0f, 116.0f, 238.0f,
226.0f, 16.0f, 132.0f,
92.0f, 125.0f, 88.0f
};
std::vector<float> expectedOutputValues
{
// Batch 0, Channel 0, Height (4) x Width (3)
235.0f * CalcInvL2Norm({ 235.0f, 113.0f, 56.0f }),
46.0f * CalcInvL2Norm({ 46.0f, 95.0f, 170.0f }),
178.0f * CalcInvL2Norm({ 178.0f, 202.0F, 162.0f }),
100.0f * CalcInvL2Norm({ 100.0f, 77.0f, 194.0f }),
123.0f * CalcInvL2Norm({ 123.0f, 114.0f, 89.0f }),
19.0f * CalcInvL2Norm({ 19.0f, 71.0f, 254.0f }),
172.0f * CalcInvL2Norm({ 172.0f, 122.0f, 12.0f }),
74.0f * CalcInvL2Norm({ 74.0f, 246.0f, 209.0f }),
250.0f * CalcInvL2Norm({ 250.0f, 166.0f, 200.0f }),
6.0f * CalcInvL2Norm({ 6.0f, 82.0f, 1.0f }),
195.0f * CalcInvL2Norm({ 195.0f, 28.0f, 64.0f }),
80.0f * CalcInvL2Norm({ 80.0f, 37.0f, 54.0f }),
// Batch 0, Channel 1, Height (4) x Width (3)
113.0f * CalcInvL2Norm({ 235.0f, 113.0f, 56.0f }),
95.0f * CalcInvL2Norm({ 46.0f, 95.0f, 170.0f }),
202.0f * CalcInvL2Norm({ 178.0f, 202.0F, 162.0f }),
77.0f * CalcInvL2Norm({ 100.0f, 77.0f, 194.0f }),
114.0f * CalcInvL2Norm({ 123.0f, 114.0f, 89.0f }),
71.0f * CalcInvL2Norm({ 19.0f, 71.0f, 254.0f }),
122.0f * CalcInvL2Norm({ 172.0f, 122.0f, 12.0f }),
246.0f * CalcInvL2Norm({ 74.0f, 246.0f, 209.0f }),
166.0f * CalcInvL2Norm({ 250.0f, 166.0f, 200.0f }),
82.0f * CalcInvL2Norm({ 6.0f, 82.0f, 1.0f }),
28.0f * CalcInvL2Norm({ 195.0f, 28.0f, 64.0f }),
37.0f * CalcInvL2Norm({ 80.0f, 37.0f, 54.0f }),
// Batch 0, Channel 2, Height (4) x Width (3)
56.0f * CalcInvL2Norm({ 235.0f, 113.0f, 56.0f }),
170.0f * CalcInvL2Norm({ 46.0f, 95.0f, 170.0f }),
162.0f * CalcInvL2Norm({ 178.0f, 202.0F, 162.0f }),
194.0f * CalcInvL2Norm({ 100.0f, 77.0f, 194.0f }),
89.0f * CalcInvL2Norm({ 123.0f, 114.0f, 89.0f }),
254.0f * CalcInvL2Norm({ 19.0f, 71.0f, 254.0f }),
12.0f * CalcInvL2Norm({ 172.0f, 122.0f, 12.0f }),
209.0f * CalcInvL2Norm({ 74.0f, 246.0f, 209.0f }),
200.0f * CalcInvL2Norm({ 250.0f, 166.0f, 200.0f }),
1.0f * CalcInvL2Norm({ 6.0f, 82.0f, 1.0f }),
64.0f * CalcInvL2Norm({ 195.0f, 28.0f, 64.0f }),
54.0f * CalcInvL2Norm({ 80.0f, 37.0f, 54.0f }),
// Batch 1, Channel 0, Height (4) x Width (3)
67.0f * CalcInvL2Norm({ 67.0f, 239.0f, 97.0f }),
90.0f * CalcInvL2Norm({ 90.0f, 104.0f, 145.0f }),
49.0f * CalcInvL2Norm({ 49.0f, 199.0f, 215.0f }),
7.0f * CalcInvL2Norm({ 7.0f, 17.0f, 115.0f }),
163.0f * CalcInvL2Norm({ 163.0f, 124.0f, 116.0f }),
18.0f * CalcInvL2Norm({ 18.0f, 153.0f, 238.0f }),
25.0f * CalcInvL2Norm({ 25.0f, 222.0f, 226.0f }),
117.0f * CalcInvL2Norm({ 117.0f, 217.0f, 16.0f }),
103.0f * CalcInvL2Norm({ 103.0f, 75.0f, 132.0f }),
247.0f * CalcInvL2Norm({ 247.0f, 32.0f, 92.0f }),
59.0f * CalcInvL2Norm({ 59.0f, 126.0f, 125.0f }),
189.0f * CalcInvL2Norm({ 189.0f, 21.0f, 88.0f }),
// Batch 1, Channel 1, Height (4) x Width (3)
239.0f * CalcInvL2Norm({ 67.0f, 239.0f, 97.0f }),
104.0f * CalcInvL2Norm({ 90.0f, 104.0f, 145.0f }),
199.0f * CalcInvL2Norm({ 49.0f, 199.0f, 215.0f }),
17.0f * CalcInvL2Norm({ 7.0f, 17.0f, 115.0f }),
124.0f * CalcInvL2Norm({ 163.0f, 124.0f, 116.0f }),
153.0f * CalcInvL2Norm({ 18.0f, 153.0f, 238.0f }),
222.0f * CalcInvL2Norm({ 25.0f, 222.0f, 226.0f }),
217.0f * CalcInvL2Norm({ 117.0f, 217.0f, 16.0f }),
75.0f * CalcInvL2Norm({ 103.0f, 75.0f, 132.0f }),
32.0f * CalcInvL2Norm({ 247.0f, 32.0f, 92.0f }),
126.0f * CalcInvL2Norm({ 59.0f, 126.0f, 125.0f }),
21.0f * CalcInvL2Norm({ 189.0f, 21.0f, 88.0f }),
// Batch 1, Channel 2, Height (4) x Width (3)
97.0f * CalcInvL2Norm({ 67.0f, 239.0f, 97.0f }),
145.0f * CalcInvL2Norm({ 90.0f, 104.0f, 145.0f }),
215.0f * CalcInvL2Norm({ 49.0f, 199.0f, 215.0f }),
115.0f * CalcInvL2Norm({ 7.0f, 17.0f, 115.0f }),
116.0f * CalcInvL2Norm({ 163.0f, 124.0f, 116.0f }),
238.0f * CalcInvL2Norm({ 18.0f, 153.0f, 238.0f }),
226.0f * CalcInvL2Norm({ 25.0f, 222.0f, 226.0f }),
16.0f * CalcInvL2Norm({ 117.0f, 217.0f, 16.0f }),
132.0f * CalcInvL2Norm({ 103.0f, 75.0f, 132.0f }),
92.0f * CalcInvL2Norm({ 247.0f, 32.0f, 92.0f }),
125.0f * CalcInvL2Norm({ 59.0f, 126.0f, 125.0f }),
88.0f * CalcInvL2Norm({ 189.0f, 21.0f, 88.0f })
};
return L2NormalizationTestImpl<ArmnnType>(
workloadFactory,
memoryManager,
tensorHandleFactory,
inputOutputShape,
scale,
offset,
inputValues,
outScale,
outOffset,
expectedOutputValues,
layout);
}
} // anonymous namespace
LayerTestResult<float, 4> L2NormalizationDefaultEpsilonTest(
armnn::IWorkloadFactory& workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
const armnn::ITensorHandleFactory& tensorHandleFactory,
const armnn::DataLayout layout)
{
// Dummy descriptor to get the default value of epsilon.
armnn::L2NormalizationDescriptor descriptor;
return L2NormalizationEpsilonTestCommon<armnn::DataType::Float32>(
workloadFactory,
memoryManager,
tensorHandleFactory,
0.f,
0,
0.f,
0,
layout,
descriptor.m_Eps);
}
LayerTestResult<float, 4> L2NormalizationNonDefaultEpsilonTest(
armnn::IWorkloadFactory& workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
const armnn::ITensorHandleFactory& tensorHandleFactory,
const armnn::DataLayout layout)
{
return L2NormalizationEpsilonTestCommon<armnn::DataType::Float32>(
workloadFactory,
memoryManager,
tensorHandleFactory,
0.f,
0,
0.f,
0,
layout,
1e-9f);
}
LayerTestResult<float, 4> L2Normalization1dTest(
armnn::IWorkloadFactory& workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
const armnn::ITensorHandleFactory& tensorHandleFactory,
const armnn::DataLayout layout)
{
return L2Normalization1dTestCommon<armnn::DataType::Float32>(
workloadFactory,
memoryManager,
tensorHandleFactory,
0.f,
0,
0.f,
0,
layout);
}
LayerTestResult<int16_t, 4> L2Normalization1dInt16Test(
armnn::IWorkloadFactory& workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
const armnn::ITensorHandleFactory& tensorHandleFactory,
const armnn::DataLayout layout)
{
return L2Normalization1dTestCommon<armnn::DataType::QSymmS16>(
workloadFactory,
memoryManager,
tensorHandleFactory,
1.f,
0,
1.f,
0,
layout);
}
LayerTestResult<uint8_t, 4> L2Normalization1dUint8Test(
armnn::IWorkloadFactory& workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
const armnn::ITensorHandleFactory& tensorHandleFactory,
const armnn::DataLayout layout)
{
return L2Normalization1dTestCommon<armnn::DataType::QAsymmU8>(
workloadFactory,
memoryManager,
tensorHandleFactory,
1.f,
0,
1.f / 128,
128,
layout);
}
LayerTestResult<float, 4> L2Normalization2dTest(
armnn::IWorkloadFactory& workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
const armnn::ITensorHandleFactory& tensorHandleFactory,
const armnn::DataLayout layout)
{
return L2Normalization2dTestCommon<armnn::DataType::Float32>(
workloadFactory,
memoryManager,
tensorHandleFactory,
0.f,
0,
0.f,
0,
layout);
}
LayerTestResult<int16_t, 4> L2Normalization2dInt16Test(
armnn::IWorkloadFactory& workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
const armnn::ITensorHandleFactory& tensorHandleFactory,
const armnn::DataLayout layout)
{
return L2Normalization1dTestCommon<armnn::DataType::QSymmS16>(
workloadFactory,
memoryManager,
tensorHandleFactory,
1.f,
0,
1.f,
0,
layout);
}
LayerTestResult<uint8_t, 4> L2Normalization2dUint8Test(
armnn::IWorkloadFactory& workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
const armnn::ITensorHandleFactory& tensorHandleFactory,
const armnn::DataLayout layout)
{
return L2Normalization1dTestCommon<armnn::DataType::QAsymmU8>(
workloadFactory,
memoryManager,
tensorHandleFactory,
1.f,
0,
1.f / 128,
128,
layout);
}
LayerTestResult<float, 2> L2Normalization2dShapeTest(
armnn::IWorkloadFactory& workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
const armnn::ITensorHandleFactory& tensorHandleFactory)
{
const armnn::DataLayout layout = armnn::DataLayout::NHWC;
const armnn::TensorShape inputOutputTensorShape = armnn::TensorShape({ 5, 2 });
std::vector<float> inputData
{
1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f, 8.f, 9.f, 10.f
};
std::vector<float> expectedOutputData
{
1.0f * CalcInvL2Norm({ 1.0f, 2.0f }),
2.0f * CalcInvL2Norm({ 1.0f, 2.0f }),
3.0f * CalcInvL2Norm({ 3.0f, 4.0f }),
4.0f * CalcInvL2Norm({ 3.0f, 4.0f }),
5.0f * CalcInvL2Norm({ 5.0f, 6.0f }),
6.0f * CalcInvL2Norm({ 5.0f, 6.0f }),
7.0f * CalcInvL2Norm({ 7.0f, 8.0f }),
8.0f * CalcInvL2Norm({ 7.0f, 8.0f }),
9.0f * CalcInvL2Norm({ 9.0f, 10.0f }),
10.0f * CalcInvL2Norm({ 9.0f, 10.0f })
};
const armnn::TensorInfo inputTensorInfo(inputOutputTensorShape, armnn::DataType::Float32, 0.f, 0);
const armnn::TensorInfo outputTensorInfo(inputOutputTensorShape, armnn::DataType::Float32, 0.f, 0);
std::vector<float> actualOutput(outputTensorInfo.GetNumElements());
std::unique_ptr<armnn::ITensorHandle> inputHandle = tensorHandleFactory.CreateTensorHandle(inputTensorInfo);
std::unique_ptr<armnn::ITensorHandle> outputHandle = tensorHandleFactory.CreateTensorHandle(outputTensorInfo);
armnn::L2NormalizationQueueDescriptor descriptor;
descriptor.m_Parameters.m_Eps = 1e-12f;
descriptor.m_Parameters.m_DataLayout = layout;
armnn::WorkloadInfo info;
AddInputToWorkload(descriptor, info, inputTensorInfo, inputHandle.get());
AddOutputToWorkload(descriptor, info, outputTensorInfo, outputHandle.get());
std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateL2Normalization(descriptor, info);
inputHandle->Allocate();
outputHandle->Allocate();
CopyDataToITensorHandle(inputHandle.get(), inputData.data());
workload->PostAllocationConfigure();
ExecuteWorkload(*workload, memoryManager);
CopyDataFromITensorHandle(actualOutput.data(), outputHandle.get());
return LayerTestResult<float, 2>(actualOutput,
expectedOutputData,
outputHandle->GetShape(),
outputTensorInfo.GetShape());
}
LayerTestResult<float, 4> L2Normalization3dTest(
armnn::IWorkloadFactory& workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
const armnn::ITensorHandleFactory& tensorHandleFactory,
const armnn::DataLayout layout)
{
return L2Normalization3dTestCommon<armnn::DataType::Float32>(
workloadFactory,
memoryManager,
tensorHandleFactory,
0.f,
0,
0.f,
0,
layout);
}
LayerTestResult<int16_t, 4> L2Normalization3dInt16Test(
armnn::IWorkloadFactory& workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
const armnn::ITensorHandleFactory& tensorHandleFactory,
const armnn::DataLayout layout)
{
return L2Normalization1dTestCommon<armnn::DataType::QSymmS16>(
workloadFactory,
memoryManager,
tensorHandleFactory,
1.f,
0,
1.f,
0,
layout);
}
LayerTestResult<uint8_t, 4> L2Normalization3dUint8Test(
armnn::IWorkloadFactory& workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
const armnn::ITensorHandleFactory& tensorHandleFactory,
const armnn::DataLayout layout)
{
return L2Normalization1dTestCommon<armnn::DataType::QAsymmU8>(
workloadFactory,
memoryManager,
tensorHandleFactory,
1.f,
0,
1.f / 128,
128,
layout);
}
LayerTestResult<float, 4> L2Normalization4dTest(
armnn::IWorkloadFactory& workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
const armnn::ITensorHandleFactory& tensorHandleFactory,
const armnn::DataLayout layout)
{
return L2Normalization4dTestCommon<armnn::DataType::Float32>(
workloadFactory,
memoryManager,
tensorHandleFactory,
0.f,
0,
0.f,
0,
layout);
}
LayerTestResult<int16_t, 4> L2Normalization4dInt16Test(
armnn::IWorkloadFactory& workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
const armnn::ITensorHandleFactory& tensorHandleFactory,
const armnn::DataLayout layout)
{
return L2Normalization1dTestCommon<armnn::DataType::QSymmS16>(
workloadFactory,
memoryManager,
tensorHandleFactory,
1.f,
0,
1.f,
0,
layout);
}
LayerTestResult<uint8_t, 4> L2Normalization4dUint8Test(
armnn::IWorkloadFactory& workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager,
const armnn::ITensorHandleFactory& tensorHandleFactory,
const armnn::DataLayout layout)
{
return L2Normalization1dTestCommon<armnn::DataType::QAsymmU8>(
workloadFactory,
memoryManager,
tensorHandleFactory,
1.f,
0,
1.f / 128,
128,
layout);
}
| 34.163573 | 114 | 0.618934 | [
"vector"
] |
11cdae7dfb2c5f491e6a08580f8432f5fdc3752c | 8,317 | cpp | C++ | Graphics/GraphicsEngine/src/BottomLevelASBase.cpp | Nuclearfossil/DiligentCore | d2ac85cc32d470fc46b9e27f83175e9cc87b2e50 | [
"Apache-2.0"
] | null | null | null | Graphics/GraphicsEngine/src/BottomLevelASBase.cpp | Nuclearfossil/DiligentCore | d2ac85cc32d470fc46b9e27f83175e9cc87b2e50 | [
"Apache-2.0"
] | null | null | null | Graphics/GraphicsEngine/src/BottomLevelASBase.cpp | Nuclearfossil/DiligentCore | d2ac85cc32d470fc46b9e27f83175e9cc87b2e50 | [
"Apache-2.0"
] | null | null | null | /*
* Copyright 2019-2020 Diligent Graphics LLC
* Copyright 2015-2019 Egor Yusov
*
* 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.
*
* In no event and under no legal theory, whether in tort (including negligence),
* contract, or otherwise, unless required by applicable law (such as deliberate
* and grossly negligent acts) or agreed to in writing, shall any Contributor be
* liable for any damages, including any direct, indirect, special, incidental,
* or consequential damages of any character arising as a result of this License or
* out of the use or inability to use the software (including but not limited to damages
* for loss of goodwill, work stoppage, computer failure or malfunction, or any and
* all other commercial damages or losses), even if such Contributor has been advised
* of the possibility of such damages.
*/
#include "BottomLevelASBase.hpp"
namespace Diligent
{
void ValidateBottomLevelASDesc(const BottomLevelASDesc& Desc) noexcept(false)
{
#define LOG_BLAS_ERROR_AND_THROW(...) LOG_ERROR_AND_THROW("Description of a bottom-level AS '", (Desc.Name ? Desc.Name : ""), "' is invalid: ", ##__VA_ARGS__)
if (Desc.CompactedSize > 0)
{
if (Desc.pTriangles != nullptr || Desc.pBoxes != nullptr)
LOG_BLAS_ERROR_AND_THROW("If non-zero CompactedSize is specified, pTriangles and pBoxes must both be null.");
if (Desc.Flags != RAYTRACING_BUILD_AS_NONE)
LOG_BLAS_ERROR_AND_THROW("If non-zero CompactedSize is specified, Flags must be RAYTRACING_BUILD_AS_NONE.");
}
else
{
if (!((Desc.BoxCount != 0) ^ (Desc.TriangleCount != 0)))
LOG_BLAS_ERROR_AND_THROW("Exactly one of BoxCount (", Desc.BoxCount, ") and TriangleCount (", Desc.TriangleCount, ") must be non-zero.");
if (Desc.pBoxes == nullptr && Desc.BoxCount > 0)
LOG_BLAS_ERROR_AND_THROW("BoxCount is ", Desc.BoxCount, ", but pBoxes is null.");
if (Desc.pTriangles == nullptr && Desc.TriangleCount > 0)
LOG_BLAS_ERROR_AND_THROW("TriangleCount is ", Desc.TriangleCount, ", but pTriangles is null.");
if ((Desc.Flags & RAYTRACING_BUILD_AS_PREFER_FAST_TRACE) != 0 && (Desc.Flags & RAYTRACING_BUILD_AS_PREFER_FAST_BUILD) != 0)
LOG_BLAS_ERROR_AND_THROW("RAYTRACING_BUILD_AS_PREFER_FAST_TRACE and RAYTRACING_BUILD_AS_PREFER_FAST_BUILD flags are mutually exclusive.");
for (Uint32 i = 0; i < Desc.TriangleCount; ++i)
{
const auto& tri = Desc.pTriangles[i];
if (tri.GeometryName == nullptr)
LOG_BLAS_ERROR_AND_THROW("pTriangles[", i, "].GeometryName must not be null.");
if (tri.VertexValueType != VT_FLOAT32 && tri.VertexValueType != VT_FLOAT16 && tri.VertexValueType != VT_INT16)
LOG_BLAS_ERROR_AND_THROW("pTriangles[", i, "].VertexValueType (", GetValueTypeString(tri.VertexValueType),
") is invalid. Only the following values are allowed: VT_FLOAT32, VT_FLOAT16, VT_INT16.");
if (tri.VertexComponentCount != 2 && tri.VertexComponentCount != 3)
LOG_BLAS_ERROR_AND_THROW("pTriangles[", i, "].VertexComponentCount (", Uint32{tri.VertexComponentCount}, ") is invalid. Only 2 or 3 are allowed.");
if (tri.MaxVertexCount == 0)
LOG_BLAS_ERROR_AND_THROW("pTriangles[", i, "].MaxVertexCount must be greater than 0.");
if (tri.MaxPrimitiveCount == 0)
LOG_BLAS_ERROR_AND_THROW("pTriangles[", i, "].MaxPrimitiveCount must be greater than 0.");
if (tri.IndexType == VT_UNDEFINED)
{
if (tri.MaxVertexCount != tri.MaxPrimitiveCount * 3)
LOG_BLAS_ERROR_AND_THROW("pTriangles[", i, "].MaxVertexCount (", tri.MaxVertexCount,
") must be equal to MaxPrimitiveCount * 3 (", tri.MaxPrimitiveCount * 3, ").");
}
else
{
if (tri.IndexType != VT_UINT32 && tri.IndexType != VT_UINT16)
LOG_BLAS_ERROR_AND_THROW("pTriangles[", i, "].IndexType (", GetValueTypeString(tri.VertexValueType),
") must be VT_UINT16 or VT_UINT32.");
}
}
for (Uint32 i = 0; i < Desc.BoxCount; ++i)
{
const auto& box = Desc.pBoxes[i];
if (box.GeometryName == nullptr)
LOG_BLAS_ERROR_AND_THROW("pBoxes[", i, "].GeometryName must not be null.");
if (box.MaxBoxCount == 0)
LOG_BLAS_ERROR_AND_THROW("pBoxes[", i, "].MaxBoxCount must be greater than 0.");
}
}
#undef LOG_BLAS_ERROR_AND_THROW
}
void CopyBLASGeometryDesc(const BottomLevelASDesc& SrcDesc,
BottomLevelASDesc& DstDesc,
FixedLinearAllocator& MemPool,
const BLASNameToIndex* pSrcNameToIndex,
BLASNameToIndex& DstNameToIndex) noexcept(false)
{
if (SrcDesc.pTriangles != nullptr)
{
MemPool.AddSpace<decltype(*SrcDesc.pTriangles)>(SrcDesc.TriangleCount);
for (Uint32 i = 0; i < SrcDesc.TriangleCount; ++i)
MemPool.AddSpaceForString(SrcDesc.pTriangles[i].GeometryName);
MemPool.Reserve();
auto* pTriangles = MemPool.CopyArray(SrcDesc.pTriangles, SrcDesc.TriangleCount);
// Copy strings
for (Uint32 i = 0; i < SrcDesc.TriangleCount; ++i)
{
const auto* SrcGeoName = SrcDesc.pTriangles[i].GeometryName;
pTriangles[i].GeometryName = MemPool.CopyString(SrcGeoName);
Uint32 ActualIndex = INVALID_INDEX;
if (pSrcNameToIndex)
{
auto iter = pSrcNameToIndex->find(SrcGeoName);
VERIFY_EXPR(iter != pSrcNameToIndex->end());
ActualIndex = iter->second.ActualIndex;
}
bool IsUniqueName = DstNameToIndex.emplace(SrcGeoName, BLASGeomIndex{i, ActualIndex}).second;
if (!IsUniqueName)
LOG_ERROR_AND_THROW("Geometry name '", SrcGeoName, "' is not unique");
}
DstDesc.pTriangles = pTriangles;
DstDesc.TriangleCount = SrcDesc.TriangleCount;
DstDesc.pBoxes = nullptr;
DstDesc.BoxCount = 0;
}
else if (SrcDesc.pBoxes != nullptr)
{
MemPool.AddSpace<decltype(*SrcDesc.pBoxes)>(SrcDesc.BoxCount);
for (Uint32 i = 0; i < SrcDesc.BoxCount; ++i)
MemPool.AddSpaceForString(SrcDesc.pBoxes[i].GeometryName);
MemPool.Reserve();
auto* pBoxes = MemPool.CopyArray(SrcDesc.pBoxes, SrcDesc.BoxCount);
// Copy strings
for (Uint32 i = 0; i < SrcDesc.BoxCount; ++i)
{
const auto* SrcGeoName = SrcDesc.pBoxes[i].GeometryName;
pBoxes[i].GeometryName = MemPool.CopyString(SrcGeoName);
Uint32 ActualIndex = INVALID_INDEX;
if (pSrcNameToIndex)
{
auto iter = pSrcNameToIndex->find(SrcGeoName);
VERIFY_EXPR(iter != pSrcNameToIndex->end());
ActualIndex = iter->second.ActualIndex;
}
bool IsUniqueName = DstNameToIndex.emplace(SrcGeoName, BLASGeomIndex{i, ActualIndex}).second;
if (!IsUniqueName)
LOG_ERROR_AND_THROW("Geometry name '", SrcGeoName, "' is not unique");
}
DstDesc.pBoxes = pBoxes;
DstDesc.BoxCount = SrcDesc.BoxCount;
DstDesc.pTriangles = nullptr;
DstDesc.TriangleCount = 0;
}
else
{
LOG_ERROR_AND_THROW("Either pTriangles or pBoxes must not be null");
}
}
} // namespace Diligent
| 43.544503 | 163 | 0.623061 | [
"geometry"
] |
11ced18b8d8b4fd97d540ae9d1e41291330acfe2 | 6,100 | cc | C++ | src/envoy/transcoding/filter.cc | PiotrSikora/proxy | 36ac1b134dc833ab38ba7024d43e21767286227c | [
"Apache-2.0"
] | null | null | null | src/envoy/transcoding/filter.cc | PiotrSikora/proxy | 36ac1b134dc833ab38ba7024d43e21767286227c | [
"Apache-2.0"
] | null | null | null | src/envoy/transcoding/filter.cc | PiotrSikora/proxy | 36ac1b134dc833ab38ba7024d43e21767286227c | [
"Apache-2.0"
] | null | null | null | /* Copyright 2017 Istio Authors. 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 "src/envoy/transcoding/filter.h"
#include "google/protobuf/descriptor.h"
#include "google/protobuf/descriptor.pb.h"
#include "google/protobuf/message.h"
#include "google/protobuf/util/type_resolver.h"
#include "google/protobuf/util/type_resolver_util.h"
#include "server/config/network/http_connection_manager.h"
using google::protobuf::FileDescriptor;
using google::protobuf::FileDescriptorSet;
using google::protobuf::DescriptorPool;
namespace Envoy {
namespace Grpc {
namespace Transcoding {
const std::string kTypeUrlPrefix{"type.googleapis.com"};
const std::string kGrpcContentType{"application/grpc"};
const std::string kJsonContentType{"application/json"};
const Http::LowerCaseString kTeHeader{"te"};
const std::string kTeTrailers{"trailers"};
Instance::Instance(Config& config) : config_(config) {}
Http::FilterHeadersStatus Instance::decodeHeaders(Http::HeaderMap& headers,
bool end_stream) {
log().debug("Transcoding::Instance::decodeHeaders");
const google::protobuf::MethodDescriptor* method;
auto status = config_.CreateTranscoder(headers, &request_in_, &response_in_,
transcoder_, method);
if (status.ok()) {
headers.removeContentLength();
headers.insertContentType().value(kGrpcContentType);
headers.insertPath().value("/" + method->service()->full_name() + "/" +
method->name());
headers.insertMethod().value(std::string("POST"));
headers.addStatic(kTeHeader, kTeTrailers);
if (end_stream) {
log().debug("header only request");
request_in_.Finish();
Buffer::OwnedImpl data;
ReadToBuffer(transcoder_->RequestOutput(), data);
if (data.length()) {
decoder_callbacks_->addDecodedData(data);
}
}
} else {
log().debug("No transcoding" + status.ToString());
}
return Http::FilterHeadersStatus::Continue;
}
Http::FilterDataStatus Instance::decodeData(Buffer::Instance& data,
bool end_stream) {
log().debug("Transcoding::Instance::decodeData");
if (transcoder_) {
request_in_.Move(data);
ReadToBuffer(transcoder_->RequestOutput(), data);
// TODO: Check RequesStatus
}
return Http::FilterDataStatus::Continue;
}
Http::FilterTrailersStatus Instance::decodeTrailers(Http::HeaderMap& trailers) {
log().debug("Transcoding::Instance::decodeTrailers");
if (transcoder_) {
request_in_.Finish();
Buffer::OwnedImpl data;
ReadToBuffer(transcoder_->RequestOutput(), data);
if (data.length()) {
decoder_callbacks_->addDecodedData(data);
}
}
return Http::FilterTrailersStatus::Continue;
}
void Instance::setDecoderFilterCallbacks(
Http::StreamDecoderFilterCallbacks& callbacks) {
decoder_callbacks_ = &callbacks;
}
Http::FilterHeadersStatus Instance::encodeHeaders(Http::HeaderMap& headers,
bool end_stream) {
log().debug("Transcoding::Instance::encodeHeaders");
if (transcoder_) {
headers.insertContentType().value(kJsonContentType);
}
return Http::FilterHeadersStatus::Continue;
}
Http::FilterDataStatus Instance::encodeData(Buffer::Instance& data,
bool end_stream) {
log().debug("Transcoding::Instance::encodeData");
if (transcoder_) {
response_in_.Move(data);
if (end_stream) {
response_in_.Finish();
}
ReadToBuffer(transcoder_->ResponseOutput(), data);
// TODO: Check ResponseStatus
}
return Http::FilterDataStatus::Continue;
}
Http::FilterTrailersStatus Instance::encodeTrailers(Http::HeaderMap& trailers) {
log().debug("Transcoding::Instance::encodeTrailers");
if (transcoder_) {
response_in_.Finish();
Buffer::OwnedImpl data;
ReadToBuffer(transcoder_->ResponseOutput(), data);
if (data.length()) {
encoder_callbacks_->addEncodedData(data);
}
}
return Http::FilterTrailersStatus::Continue;
}
void Instance::setEncoderFilterCallbacks(
Http::StreamEncoderFilterCallbacks& callbacks) {
encoder_callbacks_ = &callbacks;
}
bool Instance::ReadToBuffer(google::protobuf::io::ZeroCopyInputStream* stream,
Buffer::Instance& data) {
const void* out;
int size;
while (stream->Next(&out, &size)) {
data.add(out, size);
if (size == 0) {
return true;
}
}
return false;
}
} // namespace Transcoding
} // namespace Grpc
namespace Server {
namespace Configuration {
class TranscodingConfig : public HttpFilterConfigFactory {
public:
HttpFilterFactoryCb tryCreateFilterFactory(
HttpFilterType type, const std::string& name, const Json::Object& config,
const std::string&, Server::Instance& server) override {
if (type != HttpFilterType::Both || name != "transcoding") {
return nullptr;
}
Grpc::Transcoding::ConfigSharedPtr transcoding_config{
new Grpc::Transcoding::Config(config)};
return [transcoding_config](
Http::FilterChainFactoryCallbacks& callbacks) -> void {
std::shared_ptr<Grpc::Transcoding::Instance> instance =
std::make_shared<Grpc::Transcoding::Instance>(*transcoding_config);
callbacks.addStreamFilter(Http::StreamFilterSharedPtr(instance));
};
}
};
static RegisterHttpFilterConfigFactory<TranscodingConfig> register_;
} // namespace Configuration
} // namespace Server
} // namespace Envoy
| 30.049261 | 80 | 0.686885 | [
"object"
] |
11cefa7e7eb49df6bf8493f4bd3baa4a11891c1d | 2,033 | cpp | C++ | scenes/TestScene.cpp | aciokler/opengl-model-viewer-test | 002009bf11bae4111d9fac6df241b29136000fda | [
"MIT"
] | null | null | null | scenes/TestScene.cpp | aciokler/opengl-model-viewer-test | 002009bf11bae4111d9fac6df241b29136000fda | [
"MIT"
] | null | null | null | scenes/TestScene.cpp | aciokler/opengl-model-viewer-test | 002009bf11bae4111d9fac6df241b29136000fda | [
"MIT"
] | null | null | null | //
// TestScene.cpp
// OpenGLOtherTest
//
// Created by Abraham-mac on 7/1/14.
// Copyright (c) 2014 Abraham-mac. All rights reserved.
//
#include "TestScene.h"
#include "../shapes/Cube.h"
#include "../shapes/Mesh.h"
#include "../shapes/ObjMeshExperiment.h"
#include "../shapes/TestMesh.h"
#include <unistd.h>
void TestScene::prepareScene()
{
char * buf = new char[256];
//std::cout << "current directory " << getcwd( buf, 256) << std::endl;
//Cube * cube = new Cube();
//Shape * mesh = new ObjMeshExperiment("Lara_Croft.obj");//new ObjMeshExperiment("Lara_Croft.obj");//new ObjMeshExperiment("monkeySphere.obj");//new ObjMeshExperiment( "monkeyLowPoly.obj" );//new Mesh( "cubeGroupBasic.obj" );//new TestMesh();//new Mesh( "cube.obj" );///new TestMesh();//new Mesh( "simplePlane.obj" );//new Mesh( "simplePlaneGroups.obj" );//new Mesh( "simpleGroup.obj" );//new Mesh( "groupTest.obj" );//new Mesh( "cube.obj" ); //new Mesh( "groupTest.obj" ); new Mesh( "sls_amg_scaled.obj" ); /*new Mesh( "STI_scaled.obj" ); ( "Aventador.obj" ); //( "Porshe_911_GT2.obj" );*/
//Shape * mesh = new ObjMeshExperiment("data/shark.obj");
//Shape * mesh2 = new ObjMeshExperiment("AventadorTriangulated.obj");
//Shape * mesh = new ObjMeshExperiment("UVplane.obj");
//Shape * mesh3 = new ObjMeshExperiment("Triss.obj");
//Shape * mesh4 = new ObjMeshExperiment("Porshe_911_GT2.obj");
Shape * mesh4 = new ObjMeshExperiment("../models/groupTest.obj");
//printf("mesh addresses VBO[POSITIONS_BUFF]: %d, VBO[INDEX_BUFF]: %d, VAO[0]: %d\n", mesh->getVBOPointer(Shape::POSITIONS_BUFF), mesh->getVBOPointer(Shape::INDEX_BUFF), mesh->getVAOPointer(0) );
//printf("mesh2 addresses VBO[POSITIONS_BUFF]: %d, VBO[INDEX_BUFF]: %d, VAO[0]: %d\n", mesh2->getVBOPointer(Shape::POSITIONS_BUFF), mesh2->getVBOPointer(Shape::INDEX_BUFF), mesh2->getVAOPointer(0) );
//objects.push_back( mesh );
//objects.push_back( mesh2 );
//objects.push_back(mesh3);
objects.push_back(mesh4);
}
| 50.825 | 594 | 0.665027 | [
"mesh",
"shape"
] |
11d3c7cfe27e0fc9e21fcef6c8ad35adba3e2cf3 | 5,551 | hpp | C++ | Axis/System/Include/Axis/Event.hpp | SimmyPeet/Axis | a58c073d13f74d0224fbfca34a4dcd4b9d0c6726 | [
"Apache-2.0"
] | 1 | 2022-01-23T14:51:51.000Z | 2022-01-23T14:51:51.000Z | Axis/System/Include/Axis/Event.hpp | SimmyPeet/Axis | a58c073d13f74d0224fbfca34a4dcd4b9d0c6726 | [
"Apache-2.0"
] | null | null | null | Axis/System/Include/Axis/Event.hpp | SimmyPeet/Axis | a58c073d13f74d0224fbfca34a4dcd4b9d0c6726 | [
"Apache-2.0"
] | 1 | 2022-01-10T21:01:54.000Z | 2022-01-10T21:01:54.000Z | /// \copyright Simmypeet - Copyright (C)
/// This file is subject to the terms and conditions defined in
/// file 'LICENSE', which is part of this source code package.
#ifndef AXIS_SYSTEM_EVENT_HPP
#define AXIS_SYSTEM_EVENT_HPP
#pragma once
#include "Function.hpp"
#include "HashMap.hpp"
#include "Trait.hpp"
namespace Axis
{
namespace System
{
/// \brief Defines an event notification class. When event is raised it will
/// notify all handlers whose interest in this event.
template <class T>
class Event;
/// \brief Defines an event notification class. When event is raised it will
/// notify all handlers that subscribed to this event.
template <class ReturnType, class... Args>
class Event<ReturnType(Args...)>
{
public:
/// \brief Default constructor
Event() noexcept = default;
/// \brief Invokes all handlers that subscribed to this event
/// with the given arguments.
void operator()(Args&&... args);
/// \brief Invokes all handlers that subscribed to this event
/// with the given arguments.
void Invoke(Args&&... args);
/// \brief Interface for subscribing and unsubscribing to an event.
class Register
{
public:
/// \brief Adds a handler to the event
///
/// \param[in] handler Callable object to subscribe to the event.
/// \param[in] token Token to identify the handler. If the token is collided with
/// another handler, new token will be generated.
///
/// \return Returns the token that was used to subscribe to the event.
Size Add(const Function<ReturnType(Args...)>& handler,
Size token = 0);
/// \brief Removes a handler from the event
///
/// \param[in] token Token to identify the handler.
///
/// \return Returns true if the handler was removed successfully.
Bool Remove(Size token) noexcept;
/// \brief Checks if the event has any handlers with the given token
/// subscribed to it.
///
/// \param[in] token Token to identify the handler.
///
/// \return Returns true if the event has any handlers with the given token
Bool TokenExists(Size token) const noexcept;
private:
/// \brief Private default constructor
Register() noexcept = default;
/// \brief Private destructor
~Register() noexcept = default;
/// \brief Private copy constructor
Register(const Register& other) = default;
/// \brief Private move constructor
Register(Register&& other) = default;
/// \brief Private assignment operator
Register& operator=(const Register& other) = default;
/// \brief Private move assignment operator
Register& operator=(Register&& other) = default;
/// Contains handlers that subscribed to this event.
HashMap<Size, Function<ReturnType(Args...)>> _handlers;
// Friend declaration
friend class Event;
};
Register EventRegister; ///< Register instance
// ReturnType must be void
static_assert(std::is_same_v<ReturnType, void>);
};
template <class T>
class EventToken;
/// \brief RAII wrapper for event subscription and unsubscription.
/// When the object is destroyed, it will unsubscribe the handler
template <class ReturnType, class... Args>
class EventToken<ReturnType(Args...)>
{
public:
/// \brief Default constructor
EventToken() noexcept = default;
/// \brief Constructor
///
/// \param[in] event Event to subscribe to.
/// \param[in] handler Callable object to subscribe to the event.
/// \param[in] token The token that may be used in event subscription.
EventToken(typename Event<ReturnType(Args...)>::Register& event,
const Function<ReturnType(Args...)>& handler,
Size token = 0);
/// \brief Constructor
///
/// \param[in] event Event to subscribe to.
/// \param[in] handler Callable object to subscribe to the event.
/// \param[in] token The token that may be used in event subscription.
EventToken(typename Event<ReturnType(Args...)>::Register& event,
Function<ReturnType(Args...)>&& handler,
Size token = 0);
/// \brief Destructor
~EventToken() noexcept;
/// \brief Copy constructor is deleted
EventToken(const EventToken& other) = delete;
/// \brief Move constructor
EventToken(EventToken&& other) noexcept;
/// \brief Copy assignment operator is deleted
EventToken& operator=(const EventToken& other) = delete;
/// \brief Move assignment operator
EventToken& operator=(EventToken&& other) noexcept;
/// \brief Unsubscribes the handler from the event
void Unsubscribe() noexcept;
/// \brief Checks if the event token has been subscribed to an event or not
///
/// \return Returns true if the event token has been subscribed to an event.
Bool IsSubscribed() const noexcept;
private:
Size _token = {}; ///< Token used in registration
typename Event<ReturnType(Args...)>::Register* _event = nullptr; ///< Event to subscribe to
};
} // namespace System
} // namespace Axis
#include "../../Private/Axis/EventImpl.inl"
#endif // AXIS_SYSTEM_EVENT_HPP | 33.439759 | 100 | 0.622951 | [
"object"
] |
11d6ffb26c681a153826df9ba392a0dae7277c04 | 13,282 | cpp | C++ | src/python/py_GDMR.cpp | jonaschn/tomotopy | e37878ac3531a13e29317912298bf4b5f457521b | [
"MIT"
] | 393 | 2019-05-11T16:43:30.000Z | 2022-03-29T12:54:28.000Z | src/python/py_GDMR.cpp | jonaschn/tomotopy | e37878ac3531a13e29317912298bf4b5f457521b | [
"MIT"
] | 122 | 2019-05-22T07:08:31.000Z | 2022-03-21T11:58:01.000Z | src/python/py_GDMR.cpp | jonaschn/tomotopy | e37878ac3531a13e29317912298bf4b5f457521b | [
"MIT"
] | 49 | 2019-06-05T09:04:30.000Z | 2022-03-30T18:04:20.000Z | #include "../TopicModel/GDMR.h"
#include "module.h"
#include "utils.h"
using namespace std;
tomoto::RawDoc::MiscType GDMR_misc_args(TopicModelObject* self, const tomoto::RawDoc::MiscType& o)
{
tomoto::RawDoc::MiscType ret;
ret["metadata"] = getValueFromMiscDefault<string>("metadata", o,
"Since version 0.11.0, `GDMRModel` requires a `metadata` value in `str` type. You can store numerical metadata to a `numeric_metadata` argument."
);
ret["numeric_metadata"] = getValueFromMiscDefault<vector<tomoto::Float>>("numeric_metadata", o,
"`GDMRModel` requires a `numeric_metadata` value in `Iterable[float]` type."
);
return ret;
}
static int GDMR_init(TopicModelObject *self, PyObject *args, PyObject *kwargs)
{
size_t tw = 0, minCnt = 0, minDf = 0, rmTop = 0;
tomoto::GDMRArgs margs;
PyObject* objCorpus = nullptr, *objTransform = nullptr,
*objDegrees = nullptr, *objRange = nullptr;
PyObject* objAlpha = nullptr;
static const char* kwlist[] = { "tw", "min_cf", "min_df", "rm_top", "k",
"degrees", "alpha", "eta", "sigma", "sigma0", "alpha_epsilon",
"decay", "metadata_range", "seed", "corpus", "transform", nullptr };
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|nnnnnOOfffffOnOO", (char**)kwlist,
&tw, &minCnt, &minDf, &rmTop, &margs.k,
&objDegrees, &objAlpha, &margs.eta, &margs.sigma, &margs.sigma0, &margs.alphaEps,
&margs.orderDecay, &objRange, &margs.seed, &objCorpus, &objTransform)) return -1;
return py::handleExc([&]()
{
if (objAlpha) margs.alpha = broadcastObj<tomoto::Float>(objAlpha, margs.k,
[=]() { return "`alpha` must be an instance of `float` or `List[float]` with length `k` (given " + py::repr(objAlpha) + ")"; }
);
if (objDegrees)
{
margs.degrees = py::toCpp<vector<uint64_t>>(objDegrees, "`degrees` must be an iterable of int.");
}
tomoto::IGDMRModel* inst = tomoto::IGDMRModel::create((tomoto::TermWeight)tw, margs);
if (!inst) throw py::ValueError{ "unknown `tw` value" };
self->inst = inst;
self->isPrepared = false;
self->minWordCnt = minCnt;
self->minWordDf = minDf;
self->removeTopWord = rmTop;
self->initParams = py::buildPyDict(kwlist,
tw, minCnt, minDf, rmTop,
margs.k, margs.degrees, margs.alpha, margs.eta, margs.sigma, margs.sigma0, margs.alphaEps,
margs.orderDecay
);
py::setPyDictItem(self->initParams, "version", getVersion());
if (objRange && objRange != Py_None)
{
vector<tomoto::Float> vMin, vMax;
py::UniqueObj rangeIter{ PyObject_GetIter(objRange) }, item;
if (!rangeIter) throw py::ValueError{ "`metadata_range` must be a list of pairs." };
while (item = py::UniqueObj{ PyIter_Next(rangeIter) })
{
auto r = py::toCpp<vector<tomoto::Float>>(item, "`metadata_range` must be a list of pairs.");
if (r.size() != 2) throw py::ValueError{ "`metadata_range` must be a list of pairs." };
vMin.emplace_back(r[0]);
vMax.emplace_back(r[1]);
}
if (vMin.size() != margs.degrees.size()) throw py::ValueError{ "`len(metadata_range)` must be equal to `len(degrees)`" };
inst->setMdRange(vMin, vMax);
}
insertCorpus(self, objCorpus, objTransform);
return 0;
});
}
static PyObject* GDMR_addDoc(TopicModelObject* self, PyObject* args, PyObject *kwargs)
{
PyObject* argWords, *argNumMetadata = nullptr;
const char* metadata = nullptr;
static const char* kwlist[] = { "words", "numeric_metadata", "metadata", nullptr };
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|Oz", (char**)kwlist, &argWords, &argNumMetadata, &metadata)) return nullptr;
return py::handleExc([&]() -> PyObject*
{
if (!self->inst) throw py::RuntimeError{ "inst is null" };
if (self->isPrepared) throw py::RuntimeError{ "cannot add_doc() after train()" };
auto* inst = static_cast<tomoto::IGDMRModel*>(self->inst);
if (PyUnicode_Check(argWords))
{
if (PyErr_WarnEx(PyExc_RuntimeWarning, "`words` should be an iterable of str.", 1)) return nullptr;
}
if (!metadata) metadata = "";
tomoto::RawDoc raw = buildRawDoc(argWords);
raw.misc["metadata"] = metadata;
auto nmd = py::toCpp<vector<tomoto::Float>>(argNumMetadata, "`numeric_metadata` must be an iterable of float.");
for (auto x : nmd)
{
if (!isfinite(x)) throw py::ValueError{ "`numeric_metadata` has non-finite value (" + py::reprFromCpp(nmd) + ")." };
}
raw.misc["numeric_metadata"] = move(nmd);
auto ret = inst->addDoc(raw);
return py::buildPyValue(ret);
});
}
static DocumentObject* GDMR_makeDoc(TopicModelObject* self, PyObject* args, PyObject *kwargs)
{
PyObject* argWords, * argNumMetadata = nullptr;
const char* metadata = "";
static const char* kwlist[] = { "words", "numeric_metadata", "metadata", nullptr };
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|Oz", (char**)kwlist, &argWords, &argNumMetadata, &metadata)) return nullptr;
return py::handleExc([&]() -> DocumentObject*
{
if (!self->inst) throw py::RuntimeError{ "inst is null" };
auto* inst = static_cast<tomoto::IDMRModel*>(self->inst);
if (PyUnicode_Check(argWords))
{
if (PyErr_WarnEx(PyExc_RuntimeWarning, "`words` should be an iterable of str.", 1)) return nullptr;
}
if (!metadata) metadata = "";
tomoto::RawDoc raw = buildRawDoc(argWords);
raw.misc["metadata"] = metadata;
auto nmd = py::toCpp<vector<tomoto::Float>>(argNumMetadata, "`numeric_metadata` must be an iterable of float.");
for (auto x : nmd)
{
if (!isfinite(x)) throw py::ValueError{ "`numeric_metadata` has non-finite value (" + py::reprFromCpp(nmd) + ")." };
}
raw.misc["numeric_metadata"] = move(nmd);
auto doc = inst->makeDoc(raw);
py::UniqueObj corpus{ PyObject_CallFunctionObjArgs((PyObject*)&UtilsCorpus_type, (PyObject*)self, nullptr) };
auto* ret = (DocumentObject*)PyObject_CallFunctionObjArgs((PyObject*)&UtilsDocument_type, corpus.get(), nullptr);
ret->doc = doc.release();
ret->owner = true;
return ret;
});
}
static PyObject* GDMR_tdf(TopicModelObject* self, PyObject* args, PyObject *kwargs)
{
PyObject *argNumMetadata = nullptr;
PyObject* multiMetadata = nullptr;
const char* metadata = "";
int normalize = 1;
static const char* kwlist[] = { "numeric_metadata", "metadata", "multi_metadata", "normalize", nullptr };
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|zOp", (char**)kwlist, &argNumMetadata, &metadata, &multiMetadata, &normalize)) return nullptr;
return py::handleExc([&]() -> PyObject*
{
if (!self->inst) throw py::RuntimeError{ "inst is null" };
auto* inst = static_cast<tomoto::IGDMRModel*>(self->inst);
auto v = py::toCpp<vector<tomoto::Float>>(argNumMetadata, "`numeric_metadata` must be an iterable of float.");
if (v.size() != inst->getFs().size()) throw py::ValueError{ "`len(numeric_metadata)` must be equal to `len(degree).`" };
try
{
return py::buildPyValue(inst->getTDF(v.data(), metadata, {}, !!normalize));
}
catch (const tomoto::exc::InvalidArgument& e)
{
throw py::ValueError{ e.what() };
}
});
}
static PyObject* GDMR_tdfLinspace(TopicModelObject* self, PyObject* args, PyObject *kwargs)
{
PyObject *argMetadataStart = nullptr, *argMetadataStop = nullptr, *argNum = nullptr;
PyObject* multiMetadata = nullptr;
const char* metadata = "";
size_t endpoint = 1, normalize = 1;
static const char* kwlist[] = { "numeric_metadata_start", "numeric_metadata_stop", "num", "metadata", "multi_metadata", "endpoint", "normalize", nullptr };
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OOO|zOpp", (char**)kwlist,
&argMetadataStart, &argMetadataStop, &argNum, &metadata, &multiMetadata, &endpoint, &normalize)) return nullptr;
return py::handleExc([&]() -> PyObject*
{
if (!self->inst) throw py::RuntimeError{ "inst is null" };
auto* inst = static_cast<tomoto::IGDMRModel*>(self->inst);
auto start = py::toCpp<vector<tomoto::Float>>(argMetadataStart, "`metadata_start` must be an iterable of float.");
if (start.size() != inst->getFs().size()) throw py::ValueError{ "`len(metadata_start)` must be equal to `len(degree).`" };
auto stop = py::toCpp<vector<tomoto::Float>>(argMetadataStop, "`metadata_stop` must be an iterable of float.");
if (stop.size() != inst->getFs().size()) throw py::ValueError{ "`len(metadata_stop)` must be equal to `len(degree).`" };
auto num = py::toCpp<vector<npy_intp>>(argNum, "`num` must be an iterable of float.");
if (num.size() != inst->getFs().size()) throw py::ValueError{ "`len(num)` must be equal to `len(degree).`" };
ssize_t tot = 1;
for (auto& v : num)
{
if (v <= 0) v = 1;
tot *= v;
}
Eigen::MatrixXf mds{ (Eigen::Index)num.size(), (Eigen::Index)tot };
vector<npy_intp> idcs(num.size());
for (size_t i = 0; i < tot; ++i)
{
for (size_t j = 0; j < num.size(); ++j)
{
mds(j, i) = start[j] + (stop[j] - start[j]) * idcs[j] / (endpoint ? max(num[j] - 1, (npy_intp)1) : num[j]);
}
idcs.back()++;
for (int j = idcs.size() - 1; j >= 0; --j)
{
if (idcs[j] >= num[j])
{
idcs[j] = 0;
if (j) idcs[j - 1]++;
}
else break;
}
}
try
{
py::UniqueObj obj{ py::buildPyValue(inst->getTDFBatch(mds.data(), metadata, {}, num.size(), tot, !!normalize)) };
PyArray_Dims dims;
num.emplace_back(inst->getK());
dims.ptr = num.data();
dims.len = num.size();
return PyArray_Newshape((PyArrayObject*)obj.get(), &dims, NPY_CORDER);
}
catch (const tomoto::exc::InvalidArgument& e)
{
throw py::ValueError{ e.what() };
}
});
}
static PyObject* GDMR_getMetadataRange(TopicModelObject* self, void* closure)
{
return py::handleExc([&]()
{
if (!self->inst) throw py::RuntimeError{ "inst is null" };
auto* inst = static_cast<tomoto::IGDMRModel*>(self->inst);
vector<float> vMin, vMax;
inst->getMdRange(vMin, vMax);
vector<pair<float, float>> ret;
for (size_t i = 0; i < vMin.size(); ++i)
{
ret.emplace_back(vMin[i], vMax[i]);
}
return py::buildPyValue(ret);
});
}
static PyObject* GDMR_getTopicPrior(TopicModelObject* self, PyObject* args, PyObject* kwargs)
{
return py::handleExc([&]() -> PyObject*
{
throw py::RuntimeError{ "GDMRModel doesn't support get_topic_prior(). Use tdf() instead." };
});
}
DEFINE_GETTER(tomoto::IGDMRModel, GDMR, getSigma0);
DEFINE_GETTER(tomoto::IGDMRModel, GDMR, getOrderDecay);
DEFINE_GETTER(tomoto::IGDMRModel, GDMR, getFs);
DEFINE_DOCUMENT_GETTER(tomoto::DocumentGDMR, numericMetadata, metadataOrg);
DEFINE_LOADER(GDMR, GDMR_type);
static PyMethodDef GDMR_methods[] =
{
{ "add_doc", (PyCFunction)GDMR_addDoc, METH_VARARGS | METH_KEYWORDS, GDMR_add_doc__doc__ },
{ "make_doc", (PyCFunction)GDMR_makeDoc, METH_VARARGS | METH_KEYWORDS, GDMR_make_doc__doc__ },
{ "load", (PyCFunction)GDMR_load, METH_STATIC | METH_VARARGS | METH_KEYWORDS, LDA_load__doc__ },
{ "loads", (PyCFunction)GDMR_loads, METH_STATIC | METH_VARARGS | METH_KEYWORDS, LDA_loads__doc__ },
{ "get_topic_prior", (PyCFunction)GDMR_getTopicPrior, METH_VARARGS | METH_KEYWORDS, DMR_get_topic_prior__doc__ },
{ "tdf", (PyCFunction)GDMR_tdf, METH_VARARGS | METH_KEYWORDS, GDMR_tdf__doc__ },
{ "tdf_linspace", (PyCFunction)GDMR_tdfLinspace, METH_VARARGS | METH_KEYWORDS, GDMR_tdf_linspace__doc__ },
{ nullptr }
};
static PyGetSetDef GDMR_getseters[] = {
{ (char*)"degrees", (getter)GDMR_getFs, nullptr, GDMR_degrees__doc__, nullptr },
{ (char*)"sigma0", (getter)GDMR_getSigma0, nullptr, GDMR_sigma0__doc__, nullptr },
{ (char*)"decay", (getter)GDMR_getOrderDecay, nullptr, GDMR_decay__doc__, nullptr },
{ (char*)"metadata_range", (getter)GDMR_getMetadataRange, nullptr, GDMR_metadata_range__doc__, nullptr },
{ nullptr },
};
TopicModelTypeObject GDMR_type = { {
PyVarObject_HEAD_INIT(nullptr, 0)
"tomotopy.GDMRModel", /* tp_name */
sizeof(TopicModelObject), /* tp_basicsize */
0, /* tp_itemsize */
(destructor)TopicModelObject::dealloc, /* tp_dealloc */
0, /* tp_print */
0, /* tp_getattr */
0, /* tp_setattr */
0, /* tp_reserved */
0, /* tp_repr */
0, /* tp_as_number */
0, /* tp_as_sequence */
0, /* tp_as_mapping */
0, /* tp_hash */
0, /* tp_call */
0, /* tp_str */
0, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
GDMR___init____doc__, /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
GDMR_methods, /* tp_methods */
0, /* tp_members */
GDMR_getseters, /* tp_getset */
&DMR_type, /* tp_base */
0, /* tp_dict */
0, /* tp_descr_get */
0, /* tp_descr_set */
0, /* tp_dictoffset */
(initproc)GDMR_init, /* tp_init */
PyType_GenericAlloc,
PyType_GenericNew,
}, GDMR_misc_args };
| 39.295858 | 156 | 0.641168 | [
"vector",
"transform"
] |
11d8d49d0eedcfe080651c7e8efb4128185d00ed | 8,739 | cc | C++ | madc_lib/map_combine_functions.cc | amir-keramatian/MAD-C | 3bd67eb314309f2efe67435cc59df0d80ca080a5 | [
"CC0-1.0"
] | null | null | null | madc_lib/map_combine_functions.cc | amir-keramatian/MAD-C | 3bd67eb314309f2efe67435cc59df0d80ca080a5 | [
"CC0-1.0"
] | null | null | null | madc_lib/map_combine_functions.cc | amir-keramatian/MAD-C | 3bd67eb314309f2efe67435cc59df0d80ca080a5 | [
"CC0-1.0"
] | null | null | null | void envMap::combineV3(envMap& otherMap){
std::vector<Stone*> thisMapObjectRepresentatives = getObjectRepresentatives();
std::vector<Stone*>::iterator currentMapObjRepIter = thisMapObjectRepresentatives.begin();
while(currentMapObjRepIter != thisMapObjectRepresentatives.end()){
std::vector<Stone*> thatMapObjectRepresentatives = otherMap.getObjectRepresentatives(); //CONSIDER moving this line out of the inner loop
std::vector<Stone*>::iterator otherMapObjRepIter = thatMapObjectRepresentatives.begin();
while(otherMapObjRepIter != thatMapObjectRepresentatives.end()){
if ( (*currentMapObjRepIter)->findRoot() == (*otherMapObjRepIter)->findRoot()){
;// do nothing
}
else if (Stone::compareTwoObjectRepresentatives(*currentMapObjRepIter, *otherMapObjRepIter)) {
// 1. set the new parent pointer /
// 2. expand the bounding box for the new parent /
// 3. make a singular linked list /
// ((*currentMapObjRepIter)->getId() < (*otherMapObjRepIter)->getId())?
// (*otherMapObjRepIter)->setParent((*currentMapObjRepIter)):
// ((*currentMapObjRepIter))->setParent((*otherMapObjRepIter)) ;
// 1.
//#@! ((*otherMapObjRepIter)->findRoot())->setParent((*currentMapObjRepIter)->findRoot()) ;
((*currentMapObjRepIter)->findRoot())->setParent((*otherMapObjRepIter)->findRoot()) ;
// 2.
(*otherMapObjRepIter)->x_lower_bound =
my_MIN((*currentMapObjRepIter)->x_lower_bound, (*otherMapObjRepIter)->x_lower_bound);
(*otherMapObjRepIter)->x_upper_bound =
my_MAX((*currentMapObjRepIter)->x_upper_bound, (*otherMapObjRepIter)->x_upper_bound);
(*otherMapObjRepIter)->z_lower_bound =
my_MIN((*currentMapObjRepIter)->z_lower_bound, (*otherMapObjRepIter)->z_lower_bound);
(*otherMapObjRepIter)->z_upper_bound =
my_MAX((*currentMapObjRepIter)->z_upper_bound, (*otherMapObjRepIter)->z_upper_bound);
//3
//swapping the next pointers
Stone* temp = (*currentMapObjRepIter)->next;
(*currentMapObjRepIter)->next = (*otherMapObjRepIter)->next;
(*otherMapObjRepIter)->next = temp;
}
otherMapObjRepIter++;
}
currentMapObjRepIter++;
}
stonesInMap.insert(stonesInMap.end(), otherMap.stonesInMap.begin(), otherMap.stonesInMap.end());
}
void envMap::combine(envMap& otherMap){
std::vector<Stone*>::iterator currentMapIterator = stonesInMap.begin();
while(currentMapIterator != stonesInMap.end()){ //iterater over the current map
std::vector<Stone*>::iterator otherMapIterator = otherMap.stonesInMap.begin();
while(otherMapIterator != otherMap.stonesInMap.end()){ //iterate over otherMap
Stone* stoneInCurrentMap = *currentMapIterator;
Stone* stoneInOtherMap = *otherMapIterator;
Stone* lastParentOfStoneInCurrentMap = stoneInCurrentMap->findRoot();
Stone* lastParentOfStoneInOtherMap = stoneInOtherMap->findRoot();
if (lastParentOfStoneInCurrentMap == lastParentOfStoneInOtherMap){
otherMapIterator++;
continue;
}
totalNumberOfComparisons++;
if (Stone::compareTwoStonesV2(*stoneInCurrentMap, *stoneInOtherMap)) {
(lastParentOfStoneInCurrentMap->getId() < lastParentOfStoneInOtherMap->getId()) ?
lastParentOfStoneInOtherMap->setParent(lastParentOfStoneInCurrentMap) :
lastParentOfStoneInCurrentMap->setParent(lastParentOfStoneInOtherMap);
}
otherMapIterator++;
}
currentMapIterator++;
}
//now append theOtherMap to the working map (this map)
stonesInMap.insert(stonesInMap.end(), otherMap.stonesInMap.begin(), otherMap.stonesInMap.end());
// printMap();
}
void envMap::combineV2(envMap& otherMap){
std::vector<object> thisMapObjects = getObjects();
std::vector<object> otherMapObjects = otherMap.getObjects();
std::vector<object>::iterator currentMapObjectIterator = thisMapObjects.begin();
while(currentMapObjectIterator != thisMapObjects.end()){ //iterater over objects in the current map
std::vector<object>::iterator otherMapObjectIterator = otherMapObjects.begin();
while(otherMapObjectIterator != otherMapObjects.end()){ //iterate over objects in the otherMap
object thisObject = *currentMapObjectIterator;
object thatObject = *otherMapObjectIterator;
if ( (thisObject.x_upper_bound < thatObject.x_lower_bound) ||
(thatObject.x_upper_bound < thisObject.x_lower_bound) ){
; //do nothing
}
else if ( (thisObject.z_upper_bound < thatObject.z_lower_bound) ||
(thatObject.z_upper_bound < thisObject.z_lower_bound) ){
; //do nothing
}
else{
std::vector<Stone*>::iterator thisObjectsEllipsoids = thisObject.ellipsoids.begin();
while(thisObjectsEllipsoids != thisObject.ellipsoids.end()){
std::vector<Stone*>::iterator thatObjectsEllipsoids = thatObject.ellipsoids.begin();
while(thatObjectsEllipsoids != thatObject.ellipsoids.end()){
Stone* stoneInCurrentMap = *thisObjectsEllipsoids;
Stone* stoneInOtherMap = *thatObjectsEllipsoids;
Stone* lastParentOfStoneInCurrentMap = stoneInCurrentMap->findRoot();
Stone* lastParentOfStoneInOtherMap = stoneInOtherMap->findRoot();
totalNumberOfComparisons++;
if (Stone::compareTwoStonesV2(*stoneInCurrentMap, *stoneInOtherMap)) {
(lastParentOfStoneInCurrentMap->getId() < lastParentOfStoneInOtherMap->getId()) ?
lastParentOfStoneInOtherMap->setParent(lastParentOfStoneInCurrentMap) :
lastParentOfStoneInCurrentMap->setParent(lastParentOfStoneInOtherMap);
thisObjectsEllipsoids = thisObject.ellipsoids.end() - 1;
thatObjectsEllipsoids = thatObject.ellipsoids.end() - 1;
}
thatObjectsEllipsoids++;
}
thisObjectsEllipsoids++;
}
} //END else
otherMapObjectIterator++;
} //END iterate over objects in the otherMap
currentMapObjectIterator++;
}
//now append theOtherMap to the working map (this map)
stonesInMap.insert(stonesInMap.end(), otherMap.stonesInMap.begin(), otherMap.stonesInMap.end());
}
void envMap::combineV4(envMap& otherMap){
object_t thisObject, thatObject;
resetTheFlags();
thisObject = getNextObject_t();
while(thisObject != NULL){
otherMap.resetTheFlags();
thatObject = otherMap.getNextObject_t();
while(thatObject != NULL){
if( thisObject->findRoot() == thatObject->findRoot()){
; //do nothing
}
else if (Stone::compareTwoObjectRepresentatives(thisObject, thatObject)) {
/* 1. set the new parent pointer */
/* 2. expand the bounding box for the new parent */
/* 3. make a singular linked list */
/* 1. */
(thisObject->findRoot())->setParent(thatObject->findRoot()) ;
/* 2. */
thatObject->findRoot()->x_lower_bound =
my_MIN(thisObject->findRoot()->x_lower_bound, thatObject->findRoot()->x_lower_bound);
thatObject->x_upper_bound =
my_MAX(thisObject->findRoot()->x_upper_bound, thatObject->findRoot()->x_upper_bound);
thatObject->z_lower_bound =
my_MIN(thisObject->findRoot()->z_lower_bound, thatObject->findRoot()->z_lower_bound);
thatObject->z_upper_bound =
my_MAX(thisObject->findRoot()->z_upper_bound, thatObject->findRoot()->z_upper_bound);
/* 3. */
/*swapping the next pointers*/
Stone* temp = (thisObject)->next;
thisObject->next = thatObject->next;
thatObject->next = temp;
}
thatObject = otherMap.getNextObject_t();
}
thisObject = getNextObject_t();
}
stonesInMap.insert(stonesInMap.end(), otherMap.stonesInMap.begin(), otherMap.stonesInMap.end());
}
void envMap::combineV5(envMap& otherMap){
std::vector<object_t> thisMapObjects = getObjects_t();
std::vector<object_t>::iterator thisMapObjectIter = thisMapObjects.begin();
while(thisMapObjectIter != thisMapObjects.end()){
std::vector<object_t> thatMapObjects = otherMap.getObjects_t();
std::vector<object_t>::iterator thatMapObjectIter = thatMapObjects.begin();
while(thatMapObjectIter != thatMapObjects.end()){
if( (*thisMapObjectIter)->findRoot() == (*thatMapObjectIter)->findRoot() ){
; // do nothing
}
else if (Stone::compareTwoObjectRepresentatives((*thisMapObjectIter), (*thatMapObjectIter))) {
/* 1. set the new parent pointer */
/* 2. expand the bounding box for the new parent */
/* 3. make a singular linked list */
/* 1. */
((*thisMapObjectIter)->findRoot())->setParent((*thatMapObjectIter)->findRoot()) ;
/* 2. */ /* CURRENTLY MISSING */
/* 3. */
/*swapping the next pointers*/
Stone* temp = (*thisMapObjectIter)->next;
(*thisMapObjectIter)->next = (*thatMapObjectIter)->next;
(*thatMapObjectIter)->next = temp;
}
thatMapObjectIter++;
}
thisMapObjectIter++;
}
stonesInMap.insert(stonesInMap.end(), otherMap.stonesInMap.begin(), otherMap.stonesInMap.end());
}
| 33.741313 | 141 | 0.713011 | [
"object",
"vector"
] |
11e4a93783cacfaf661604e9b3f1d426866a38d3 | 3,465 | cpp | C++ | Players/Cocos2d-x_v4/EffekseerRendererLLGI/EffekseerRendererLLGI.ModelLoader.cpp | darreney/EffekseerForCocos2d-x | de9222b28f6f376cfb96f98b7b4dd783a3d66055 | [
"MIT"
] | null | null | null | Players/Cocos2d-x_v4/EffekseerRendererLLGI/EffekseerRendererLLGI.ModelLoader.cpp | darreney/EffekseerForCocos2d-x | de9222b28f6f376cfb96f98b7b4dd783a3d66055 | [
"MIT"
] | null | null | null | Players/Cocos2d-x_v4/EffekseerRendererLLGI/EffekseerRendererLLGI.ModelLoader.cpp | darreney/EffekseerForCocos2d-x | de9222b28f6f376cfb96f98b7b4dd783a3d66055 | [
"MIT"
] | null | null | null |
#include "EffekseerRendererLLGI.ModelLoader.h"
#include "EffekseerRendererLLGI.Renderer.h"
#include <memory>
namespace EffekseerRendererLLGI
{
ModelLoader::ModelLoader(GraphicsDevice* graphicsDevice, ::Effekseer::FileInterface* fileInterface)
: graphicsDevice_(graphicsDevice), m_fileInterface(fileInterface)
{
LLGI::SafeAddRef(graphicsDevice_);
if (m_fileInterface == NULL)
{
m_fileInterface = &m_defaultFileInterface;
}
}
ModelLoader::~ModelLoader() { LLGI::SafeRelease(graphicsDevice_); }
void* ModelLoader::Load(const EFK_CHAR* path)
{
std::unique_ptr<::Effekseer::FileReader> reader(m_fileInterface->OpenRead(path));
if (reader.get() == NULL)
return nullptr;
if (reader.get() != NULL)
{
size_t size_model = reader->GetLength();
uint8_t* data_model = new uint8_t[size_model];
reader->Read(data_model, size_model);
Model* model = new Model(data_model, size_model);
model->ModelCount = Effekseer::Min(Effekseer::Max(model->GetModelCount(), 1), 40);
model->InternalModels = new Model::InternalModel[model->GetFrameCount()];
for (int32_t f = 0; f < model->GetFrameCount(); f++)
{
model->InternalModels[f].VertexCount = model->GetVertexCount(f);
{
std::vector<Effekseer::Model::VertexWithIndex> vs;
for (int32_t m = 0; m < model->ModelCount; m++)
{
for (int32_t i = 0; i < model->GetVertexCount(f); i++)
{
Effekseer::Model::VertexWithIndex v;
v.Position = model->GetVertexes(f)[i].Position;
v.Normal = model->GetVertexes(f)[i].Normal;
v.Binormal = model->GetVertexes(f)[i].Binormal;
v.Tangent = model->GetVertexes(f)[i].Tangent;
v.UV = model->GetVertexes(f)[i].UV;
v.VColor = model->GetVertexes(f)[i].VColor;
v.Index[0] = m;
vs.push_back(v);
}
}
auto vb_size = sizeof(Effekseer::Model::VertexWithIndex) * model->GetVertexCount(f) * model->ModelCount;
model->InternalModels[f].VertexBuffer = graphicsDevice_->GetGraphics()->CreateVertexBuffer(vb_size);
auto p_ = model->InternalModels[f].VertexBuffer->Lock();
memcpy(p_, vs.data(), sizeof(Effekseer::Model::VertexWithIndex) * vs.size());
model->InternalModels[f].VertexBuffer->Unlock();
}
model->InternalModels[f].FaceCount = model->GetFaceCount(f);
model->InternalModels[f].IndexCount = model->InternalModels[f].FaceCount * 3;
{
std::vector<Effekseer::Model::Face> fs;
for (int32_t m = 0; m < model->ModelCount; m++)
{
for (int32_t i = 0; i < model->InternalModels[f].FaceCount; i++)
{
Effekseer::Model::Face face;
face.Indexes[0] = model->GetFaces(f)[i].Indexes[0] + model->GetVertexCount(f) * m;
face.Indexes[1] = model->GetFaces(f)[i].Indexes[1] + model->GetVertexCount(f) * m;
face.Indexes[2] = model->GetFaces(f)[i].Indexes[2] + model->GetVertexCount(f) * m;
fs.push_back(face);
}
}
model->InternalModels[f].IndexBuffer = graphicsDevice_->GetGraphics()->CreateIndexBuffer(
4, sizeof(int32_t) * 3 * model->InternalModels[f].FaceCount * model->ModelCount);
auto p_ = model->InternalModels[f].IndexBuffer->Lock();
memcpy(p_, fs.data(), sizeof(Effekseer::Model::Face) * fs.size());
model->InternalModels[f].IndexBuffer->Unlock();
}
}
delete[] data_model;
return (void*)model;
}
return NULL;
}
void ModelLoader::Unload(void* data)
{
if (data != NULL)
{
Model* model = (Model*)data;
delete model;
}
}
} // namespace EffekseerRendererLLGI
| 29.615385 | 108 | 0.672439 | [
"vector",
"model"
] |
eb199f516f44ae9ff6d852a09645b4fee95ebd72 | 61,719 | cpp | C++ | src/Solver.cpp | meelgroup/KCBox | b2e66952f39d5777f7826dce154cfc703fde29c3 | [
"MIT"
] | 3 | 2021-02-20T11:12:52.000Z | 2021-02-21T22:22:34.000Z | src/Solver.cpp | meelgroup/KCBox | b2e66952f39d5777f7826dce154cfc703fde29c3 | [
"MIT"
] | 1 | 2021-02-20T11:33:35.000Z | 2021-02-25T06:03:57.000Z | src/Solver.cpp | meelgroup/KCBox | b2e66952f39d5777f7826dce154cfc703fde29c3 | [
"MIT"
] | null | null | null | #include "Solver.h"
#include <sys/sysinfo.h>
namespace KCBox {
const Reason Reason::mismatched( UNSIGNED_UNDEF - 1, 1 ); // UNSIGNED_UNDEF - 2
const Reason Reason::unknown( UNSIGNED_UNDEF, 0 ); // UNSIGNED_UNDEF - 1
const Reason Reason::undef( UNSIGNED_UNDEF, 1 ); // UNSIGNED_UNDEF
Solver::Solver():
_old_num_long_clauses( 0 ),
_heur_lits_heap( Literal::start, _heur_decaying_sum ),
_big_clause( 0 ),
_big_learnt( 0 )
{
}
Solver::~Solver()
{
if ( _max_var != Variable::undef || Is_Oracle_Mode() ) Free_Auxiliary_Memory();
if ( _max_var == Variable::undef && Is_Oracle_Mode() ) {
// Decision_Manager::Free_Auxiliary_Memory();
}
}
void Solver::Allocate_and_Init_Auxiliary_Memory( Variable max_var ) // ToDo: whether can we optimize when mv < max_var
{
if ( Is_Oracle_Mode() ) {
assert( max_var <= running_options.variable_bound );
_max_var = max_var;
return;
}
if ( running_options.profile_solving != Profiling_Close ) statistics.Init_Solver();
if ( _max_var == max_var ) return; /// to make the recursive calls from inherited classes correct
if ( _max_var != Variable::undef ) Free_Auxiliary_Memory();
Decision_Manager::Allocate_and_Init_Auxiliary_Memory( max_var );
_binary_clauses = new vector<Literal> [2 * _max_var + 2];
_old_num_binary_clauses = new unsigned [2 * _max_var + 2];
_long_watched_lists = new vector<unsigned> [2 * _max_var + 2];
_var_seen = new bool [_max_var + 2]; // The last bit is used to mark max_var + 1 not assigned
_lit_seen = new bool [2 * _max_var + 4]; // The last two bits are used to mark 2*max_var + 2 and 2*max_var + 3 not assigned
_heur_decaying_sum = new double [2 * _max_var + 4]; // heur_value[0] and heur_value[1] is sometimes used to reduce the number of iteration }
_heur_sorted_lits = new Literal [2 * _max_var + 4]; // "heur_lits[2 * max_var + 2]" and "heur_lits[2 * max_var + 3]" is sometimes used to reduce the number of iteration
_heur_lits_heap.Enlarge_Index( 2 * _max_var + 1, _heur_decaying_sum );
_var_rank = new unsigned [2 * _max_var + 2];
_big_clause.Reserve( _max_var );
_big_learnt.Reserve( _max_var ); // used in learning conflict
if ( Hyperscale_Problem() ) _model_pool = new Model_Pool( _max_var, 1 );
else if ( Large_Scale_Problem() ) _model_pool = new Model_Pool( _max_var, _max_var );
else _model_pool = new Model_Pool( _max_var, 10 * _max_var );
/// Init
_no_instance = true;
for ( unsigned i = 0; i < Variable::start; i++ ) {
_var_seen[i] = false; // _var_seen is sometimes used for indices
}
for ( Variable i = Variable::start; i <= _max_var; i++ ) {
_old_num_binary_clauses[i + i] = 0;
_old_num_binary_clauses[i + i + 1] = 0;
_var_seen[i] = false;
_lit_seen[i + i] = false;
_lit_seen[i + i + 1] = false;
}
_var_seen[max_var + 1] = false;
_lit_seen[2 * max_var + 2] = false;
_lit_seen[2 * max_var + 3] = false;
}
void Solver::Free_Auxiliary_Memory() // NOTE: only called in Allocate_and_Init_Auxiliary_Memory
{
delete [] _binary_clauses;
delete [] _old_num_binary_clauses;
delete [] _long_watched_lists;
delete [] _var_seen; // The last bit is used to mark max_var + 1 not assigned
delete [] _lit_seen; // The last two bits are used to mark 2*max_var + 2 and 2*max_var + 3 not assigned
delete [] _heur_decaying_sum; // heur_value[0] and heur_value[1] is sometimes used to reduce the number of iteration }
delete [] _heur_sorted_lits; // "heur_lits[2 * max_var + 2]" and "heur_lits[2 * max_var + 3]" is sometimes used to reduce the number of iteration
delete [] _var_rank;
delete _model_pool;
}
void Solver::Reset()
{
Decision_Manager::Reset(); /// if we detect some implied literals, we need to initialize them for other callings
_no_instance = true;
_unary_clauses.clear();
for ( Variable i = Variable::start; i <= _max_var; i++ ) {
Literal lit( i, false );
_binary_clauses[lit].clear();
_old_num_binary_clauses[lit] = 0;
_long_watched_lists[lit].clear();
lit = Literal( i, true );
_binary_clauses[lit].clear();
_old_num_binary_clauses[lit] = 0;
_long_watched_lists[lit].clear();
}
_old_num_long_clauses = 0;
vector<Clause>::iterator itr = _long_clauses.begin();
vector<Clause>::iterator end = _long_clauses.end();
for ( ; itr < end; itr++ ) itr->Free();
_long_clauses.clear();
}
void Solver::Open_Oracle_Mode( Variable var_bound )
{
Allocate_and_Init_Auxiliary_Memory( var_bound );
running_options.variable_bound = var_bound; /// Allocate_and_Init_Auxiliary_Memory will use running_options.bounded_problem_mode, so please don't change the calling order
running_options.display_solving_process = false;
}
void Solver::Close_Oracle_Mode()
{
running_options.variable_bound = Variable::undef;
}
bool Solver::Solve( CNF_Formula & cnf, vector<Model *> & models )
{
if ( running_options.display_solving_process ) {
cout << "Number of original variables: " << cnf.Num_Vars() << endl;
cout << "Number of original clauses: " << cnf.Num_Clauses() << endl;
}
Allocate_and_Init_Auxiliary_Memory( cnf.Max_Var() );
if ( !Load_Instance( cnf ) ) {
Un_BCP( 0 );
return false;
}
Gather_Infor_For_SAT();
Extend_New_Level(); // to store initialized implied literals
bool sat = Solve( models );
Backtrack();
Reset();
if ( debug_options.verify_satisfiability ) Verify_Satisfiability( cnf, sat );
if ( debug_options.verify_learnts ) Verify_Learnts( cnf );
if ( running_options.display_solving_process ) {
Display_Statistics( cout );
}
if ( running_options.display_solving_process ) {
if ( sat ) cout << "SAT" << endl;
else cout << "UNSAT" << endl;
}
return sat;
}
bool Solver::Load_Instance( CNF_Formula & cnf )
{
unsigned i, j;
_clause_status.assign( cnf.Num_Clauses(), false ); // Annotate: the bit true means that the corresponding clause is blocked
for ( i = 0; i < cnf.Num_Clauses(); i++ ) {
Clause & clause = cnf[i];
_big_clause.Clear();
for ( j = 0; j < clause.Size(); j++ ) {
if ( _lit_seen[clause[j]] ) continue;
else if ( _lit_seen[~clause[j]] ) break;
else {
_big_clause.Add_Lit( clause[j] );
_lit_seen[clause[j]] = true;
}
}
if ( j < clause.Size() ) { // Annotate: tautology
_lit_seen[_big_clause[0]] = false;
for ( j = 1; j < _big_clause.Size(); j++ ) _lit_seen[_big_clause[j]] = false;
_clause_status[i] = true;
continue;
}
if ( _big_clause.Size() == 1 ) {
_lit_seen[_big_clause[0]] = false;
if ( Lit_Undecided( _big_clause[0] ) ) {
_unary_clauses.push_back( _big_clause[0] );
Assign( _big_clause[0] );
clause[0] = _big_clause[0];
clause.Shrink( 1 );
}
else if ( Lit_UNSAT( _big_clause[0] ) ) return false;
_clause_status[i] = true; // Annotate: appeared previously
}
else {
_lit_seen[_big_clause[0]] = false;
clause[0] = _big_clause[0];
_lit_seen[_big_clause[1]] = false;
clause[1] = _big_clause[1];
for ( j = 2; j < _big_clause.Size(); j++ ) {
_lit_seen[_big_clause[j]] = false;
clause[j] = _big_clause[j];
}
clause.Shrink( _big_clause.Size() );
}
}
if ( !_unary_clauses.empty() && !Simplify_Original_Clauses_By_Unary( cnf ) ) return false;
for ( i = 0; i < cnf.Num_Clauses(); i++ ) { /// NOTE: load non-unary clauses here
Clause & clause = cnf[i];
if ( _clause_status[i] ) _clause_status[i] = false;
else if ( clause.Size() == 2 ) Add_Binary_Clause_Naive( clause[0], clause[1] );
else _long_clauses.push_back( clause.Copy() ); /// cannot use clause._lits because it will be free in ~CNF_Formula
}
_old_num_long_clauses = _long_clauses.size();
for ( i = Variable::start; i <= _max_var; i++ ) {
_old_num_binary_clauses[i + i] = _binary_clauses[i + i].size();
_old_num_binary_clauses[i + i + 1] = _binary_clauses[i + i + 1].size();
}
return true;
}
bool Solver::Simplify_Original_Clauses_By_Unary( CNF_Formula & cnf )
{
unsigned i, j;
for ( i = 0; i < cnf.Num_Clauses(); i++ ) {
if ( _clause_status[i] ) continue;
Clause & clause = cnf[i];
_long_watched_lists[clause[0]].push_back( i );
_long_watched_lists[clause[1]].push_back( i );
for ( j = 2; j < clause.Size(); j++ ) {
_long_watched_lists[clause[j]].push_back( i );
}
}
for ( i = 0; i < _unary_clauses.size(); i++ ) {
Literal lit = _unary_clauses[i];
vector<unsigned>::iterator it = _long_watched_lists[lit].begin();
vector<unsigned>::iterator en = _long_watched_lists[lit].end();
for ( ; it < en; it++ ) {
_clause_status[*it] = true;
}
Literal lit_neg = ~lit;
it = _long_watched_lists[lit_neg].begin();
en = _long_watched_lists[lit_neg].end();
for ( ; it < en; it++ ) {
Clause & clause = cnf[*it];
for ( j = 0; clause[j] != lit_neg; j++ ) {}
clause.Erase_Lit( j );
if ( clause.Size() == 1 ) {
if ( Lit_Undecided( clause[0] ) ) {
_unary_clauses.push_back( clause[0] );
Assign( clause[0] );
}
else if ( Lit_UNSAT( clause[0] ) ) return false; /// no need to clear _long_watched_lists
_clause_status[*it] = true;
}
}
}
for ( i = Variable::start; i <= _max_var; i++ ) {
_long_watched_lists[i + i].clear();
_long_watched_lists[i + i + 1].clear();
}
return true;
}
void Solver::Add_Binary_Clause_Naive( Literal lit1, Literal lit2 )
{
_binary_clauses[lit1].push_back( lit2 );
vector<Literal>::iterator itr;
for ( itr = _binary_clauses[lit1].begin(); *itr != lit2; itr++ ) {}
if ( itr != _binary_clauses[lit1].end() - 1 ) _binary_clauses[lit1].pop_back();
else _binary_clauses[lit2].push_back( lit1 );
}
void Solver::Gather_Infor_For_SAT()
{
_no_instance = false;
Generate_Long_Watched_Lists();
Init_Heur_Decaying_Sum();
}
void Solver::Generate_Long_Watched_Lists()
{
unsigned i;
for ( i = Variable::start; i <= _max_var; i++ ) {
_long_watched_lists[i + i].clear();
_long_watched_lists[i + i + 1].clear();
}
vector<Clause>::iterator begin = _long_clauses.begin(), itr = begin, end = _long_clauses.end();
for ( ; itr < end; itr++ ) {
_long_watched_lists[(*itr)[0]].push_back( itr - begin );
_long_watched_lists[(*itr)[1]].push_back( itr - begin );
}
}
void Solver::Generate_Long_Watched_Lists_No_Clear()
{
vector<Clause>::iterator begin = _long_clauses.begin(), itr = begin, end = _long_clauses.end();
for ( ; itr < end; itr++ ) {
_long_watched_lists[(*itr)[0]].push_back( itr - begin );
_long_watched_lists[(*itr)[1]].push_back( itr - begin );
}
}
void Solver::Init_Heur_Decaying_Sum()
{
for ( Variable i = Variable::start; i <= _max_var; i++ ) {
_heur_sorted_lits[i + i - Literal::start] = Literal( i, false );
_heur_sorted_lits[i + i + 1 - Literal::start] = Literal( i, true );
_heur_decaying_sum[i + i] = _binary_clauses[i + i].size();
_heur_decaying_sum[i + i + 1] = _binary_clauses[i + i + 1].size();
}
_heur_lit_sentinel = Literal( _max_var.Next(), false );
_heur_sorted_lits[2 * _max_var + 2 - Literal::start] = _heur_lit_sentinel; // NOTE: this line guarantee the correctness of "Branch"
_heur_sorted_lits[2 * _max_var + 3 - Literal::start] = ~_heur_lit_sentinel;
_heur_decaying_sum[_heur_lit_sentinel] = -1; /// NOTE: to speed up Branch and Branch_Component by using only one comparison in for-loop
_heur_decaying_sum[~_heur_lit_sentinel] = -2; /// NOTE: return 2 * _max_var + 2 exactly when all variables are assigned
vector<Clause>::iterator begin = _long_clauses.begin(), itr = begin, end = _long_clauses.end();
for ( ; itr < end; itr++ ) {
_heur_decaying_sum[(*itr)[0]] += 1;
_heur_decaying_sum[(*itr)[1]] += 1;
_heur_decaying_sum[(*itr)[2]] += 1;
for ( unsigned i = 3; i < itr->Size(); i++ ) _heur_decaying_sum[(*itr)[i]] += 1;
}
switch( running_options.sat_heur_lits ) {
case Heuristic_Literal_Unsorted_List:
break;
case Heuristic_Literal_Sorted_List:
Quick_Sort_Weight_Reverse( _heur_sorted_lits, 2 * NumVars( _max_var ), _heur_decaying_sum );
break;
case Heuristic_Literal_Heap:
running_options.sat_heur_cumulative_inc = 1;
_heur_num_lits = 2 * NumVars( _max_var );
_heur_lits_heap.Build( _heur_sorted_lits, _heur_num_lits );
break;
}
}
bool Solver::Solve( vector<Model *> & models )
{
assert( _num_levels == 1 );
StopWatch begin_watch;
if ( running_options.profile_solving >= Profiling_Abstract ) begin_watch.Start();
if ( running_options.profile_solving >= Profiling_Detail ) statistics.num_solve++;
unsigned lifted_sat;
unsigned num_restart = 0;
double restart_bound = Restart_Bound();
while ( ( lifted_sat = Search_Solution( restart_bound ) ) == 2 ) {
restart_bound *= running_options.sat_restart_trigger_inc;
num_restart++;
if ( running_options.sat_employ_external_solver && num_restart > running_options.sat_restart_max ) {
return Solve_External( models );
}
}
assert( lifted_sat <= 1 );
if ( lifted_sat == 1 ) {
Add_Model( models ); // Un_BCP will change _assignment
if ( debug_options.verify_model ) Verify_Model( models.back() );
Backjump( 1 );
}
else if ( running_options.profile_solving >= Profiling_Detail ) statistics.num_unsat_solve++;
if ( running_options.profile_solving >= Profiling_Abstract ) statistics.time_solve += begin_watch.Get_Elapsed_Seconds();
return lifted_sat == 1;
}
unsigned Solver::Search_Solution( unsigned conf_limit )
{
unsigned old_num_levels = _num_levels;
unsigned old_size = _long_clauses.size();
Literal branch;
while ( ( branch = Branch() ) != _heur_lit_sentinel ) {
Extend_New_Level();
Assign( branch );
Reason conf = BCP( _num_dec_stack - 1 );
while ( conf != Reason::undef ) {
assert( _num_levels >= old_num_levels );
if ( _num_levels == old_num_levels ) {
return 0; // UNSAT
}
unsigned back_level = Analyze_Conflict( conf );
if ( back_level < old_num_levels - 1 ) {
Backjump( old_num_levels );
return 3; // implied literal by some previous level before \old_num_levels
}
Backjump( back_level + 1 );
Assign( _big_learnt[0], Add_Learnt_Sort() );
if ( _long_clauses.size() - old_size > conf_limit ) {
Backjump( old_num_levels );
return 2; // restart
}
conf = BCP( _num_dec_stack - 1 );
}
}
return 1; // SAT
}
unsigned Solver::Restart_Bound()
{
if ( !running_options.sat_restart_activate ) return UNSIGNED_UNDEF;
else {
switch( 2 ) {
case 1:
return _max_var + _old_num_long_clauses;
break;
case 2:
return running_options.sat_restart_trigger_init;
break;
}
}
}
Literal Solver::Branch() // TODO: we can optimize this function in a bin-search-like fashion
{
if ( running_options.sat_heur_lits == Heuristic_Literal_Sorted_List ) {
unsigned i;
for ( i = 0; Lit_Decided( _heur_sorted_lits[i] ); i++ );
return _heur_sorted_lits[i];
}
else {
while ( !_heur_lits_heap.Empty() ) {
Literal lit = _heur_lits_heap.Extract_Max();
if ( Lit_Undecided( lit ) ) return lit;
}
return _heur_lit_sentinel;
}
}
Reason Solver::BCP( unsigned start )
{
unsigned i, j, size;
for ( ; start < _num_dec_stack; start++ ) {
Literal lit = ~_dec_stack[start];
for ( i = 0, size = _binary_clauses[lit].size(); i < size; i++ ) {
if ( Lit_UNSAT( _binary_clauses[lit][i] ) ) {
_big_learnt[1] = _binary_clauses[lit][i];
return Reason( lit );
}
else if ( Lit_Undecided( _binary_clauses[lit][i] ) ) {
Assign( _binary_clauses[lit][i], Reason( lit ) );
}
}
vector<unsigned> & watched = _long_watched_lists[lit];
for ( i = 0, size = watched.size(); i < size; ) {
Clause & clause = _long_clauses[watched[i]];
if ( clause.Size() < 3 ) {
cerr << "ERROR[Solver::BCP]: _long_clauses[" << watched[i] << "] = " << _long_clauses[watched[i]] << endl;
}
assert( clause.Size() >= 3 );
if ( clause[0] == lit ) { // let watched[i]->lits[1] be lit, *itr can only propagate watched[i]->lits[0]
clause[0] = clause[1];
clause[1] = lit;
}
if ( Lit_SAT( clause[0] ) ) {
i++;
continue;
}
bool unit; // itr is changed in the following loop, we cannot replace unit by j == watched[i]->len
Literal li = clause[2];
if ( !Lit_UNSAT( li ) ) { // l is not falsified
unit = false;
clause[2] = clause[1];
clause[1] = li;
_long_watched_lists[li].push_back( watched[i] );
Simply_Erase_Vector_Element( watched, i, size );
}
else {
unit = true;
for ( j = 3; j < clause.Size(); j++ ) {
li = clause[j];
if ( !Lit_UNSAT( li ) ) { // l is not falsified
unit = false;
clause[j] = clause[1];
clause[1] = li;
_long_watched_lists[li].push_back( watched[i] );
Simply_Erase_Vector_Element( watched, i, size );
break;
}
}
}
if ( unit ) {
if ( Lit_Decided( clause[0] ) ) {
_big_learnt[1] = clause[0];
return Reason( watched[i], SAT_REASON_CLAUSE ); // (*itr)->lits[0] is falsified
}
else {
Assign( clause[0], Reason( watched[i], SAT_REASON_CLAUSE ) );
i++;
}
}
}
}
return Reason::undef;
}
void Solver::Un_BCP( unsigned start )
{
while ( _num_dec_stack > start ) {
_assignment[_dec_stack[--_num_dec_stack].Var()] = lbool::unknown;
}
}
void Solver::Backjump( unsigned num_kept_levels )
{
_num_levels = num_kept_levels;
for ( ; _num_dec_stack > _dec_offsets[_num_levels]; _num_dec_stack-- ) {
Literal lit = _dec_stack[_num_dec_stack - 1];
Un_Assign( lit.Var() );
if ( running_options.sat_heur_lits == Heuristic_Literal_Heap ) _heur_lits_heap.Insert( lit );
}
}
unsigned Solver::Analyze_Conflict( Reason confl )
{
// if ( _assignment[1] == 0 && _assignment[2] == 0 && _assignment[3] == 0 && _assignment[4] == 1 && _assignment[5] == 1 && _assignment[6] == 0 ) {
// Compile_Top_Down_Display_Clauses( cout, true );
// Compile_Top_Down_Display_Watched_List( cout );
// }
unsigned i, j, k, num_ip = 0;
Variable var = _big_learnt[1].Var();
_var_seen[var] = true;
if ( _var_stamps[var] + 1 == _num_levels ) {
_big_learnt.Resize( 1 );
num_ip++;
}
else _big_learnt.Resize( 2 ); /// _big_learnt[1] is reserved
assert( confl != Reason::undef ); // ToRemove
if ( confl.Is_Clause_Reason() ) { /// SAT_IS_REASON_LONG( Reason::undef ) is true but this situation will not appear
Clause & clause = _long_clauses[confl.Clause_Value()];
assert( _big_learnt[1] == clause[0] );
var = clause[1].Var();
_var_seen[var] = true;
if ( _var_stamps[var] + 1 == _num_levels ) num_ip++;
else _big_learnt.Add_Lit( clause[1] );
var = clause[2].Var();
_var_seen[var] = true;
if ( _var_stamps[var] + 1 == _num_levels ) num_ip++;
else _big_learnt.Add_Lit( clause[2] );
for ( i = 3; i < clause.Size(); i++ ) {
var = clause[i].Var();
_var_seen[var] = true;
if ( _var_stamps[var] + 1 == _num_levels ) num_ip++;
else _big_learnt.Add_Lit( clause[i] );
}
}
else {
var = confl.Lit_Value().Var();
_var_seen[var] = true;
if ( _var_stamps[var] + 1 == _num_levels ) num_ip++;
else _big_learnt.Add_Lit( confl.Lit_Value() );
}
unsigned index = _num_dec_stack - 1;
while ( !_var_seen[_dec_stack[index].Var()] ) index--;
Literal uip = _dec_stack[index--];
confl = _reasons[uip.Var()];
_var_seen[uip.Var()] = false;
num_ip--;
while ( num_ip > 0 ) {
assert( confl != Reason::undef ); // ToRemove
if ( confl.Is_Clause_Reason() ) {
Clause & clause = _long_clauses[confl.Clause_Value()];
assert( uip == clause[0] );
var = clause[1].Var();
if ( !_var_seen[var] ) {
_var_seen[var] = true;
if ( _var_stamps[var] + 1 == _num_levels ) num_ip++;
else _big_learnt.Add_Lit( clause[1] );
}
var = clause[2].Var();
if ( !_var_seen[var] ) {
_var_seen[var] = true;
if ( _var_stamps[var] + 1 == _num_levels ) num_ip++;
else _big_learnt.Add_Lit( clause[2] );
}
for ( i = 3; i < clause.Size(); i++ ) {
var = clause[i].Var();
if ( !_var_seen[var] ) {
_var_seen[var] = true;
if ( _var_stamps[var] + 1 == _num_levels ) num_ip++;
else _big_learnt.Add_Lit( clause[i] );
}
}
}
else {
var = confl.Lit_Value().Var();
if ( !_var_seen[var] ) {
_var_seen[var] = true;
if ( _var_stamps[var] + 1 == _num_levels ) num_ip++;
else _big_learnt.Add_Lit( confl.Lit_Value() );
}
}
while ( !_var_seen[_dec_stack[index].Var()] ) index--;
uip = _dec_stack[index--];
confl = _reasons[uip.Var()];
_var_seen[uip.Var()] = false;
num_ip--;
}
_big_learnt[0] = ~uip;
_big_clause.Clear();
for ( j = i = 1; i < _big_learnt.Size(); i++ ) { /// simplify _big_learnt
var = _big_learnt[i].Var();
if ( _reasons[var] == Reason::undef ) _big_learnt[j++] = _big_learnt[i];
else {
if ( _reasons[var].Is_Clause_Reason() ) {
Clause & clause = _long_clauses[_reasons[var].Clause_Value()];
if ( !_var_seen[clause[1].Var()] ) _big_learnt[j++] = _big_learnt[i];
else {
bool tmp_seen = _var_seen[clause.Last_Lit().Var()];
_var_seen[clause.Last_Lit().Var()] = false;
for ( k = 2; _var_seen[clause[k].Var()]; k++ );
_var_seen[clause.Last_Lit().Var()] = tmp_seen;
if ( _var_seen[clause[k].Var()] ) _big_clause.Add_Lit( _big_learnt[i] );
else _big_learnt[j++] = _big_learnt[i];
}
}
else {
if ( _var_seen[_reasons[var].Lit_Value().Var()] ) _big_clause.Add_Lit( _big_learnt[i] );
else _big_learnt[j++] = _big_learnt[i];
}
}
}
assert( ( j + _big_clause.Size() ) == _big_learnt.Size() );
_big_learnt.Resize( j );
for ( i = 0; i < _big_clause.Size(); i++ ) _var_seen[_big_clause[i].Var()] = false;
_var_seen[_big_learnt[0].Var()] = false;
assert( Lit_Decided( _big_learnt[0] ) );
if ( _big_learnt.Size() == 1 ) return 0;
_var_seen[_big_learnt[1].Var()] = false;
assert( Lit_Decided( _big_learnt[1] ) );
unsigned max = 1;
for ( i = 2; i < _big_learnt.Size(); i++ ) {
_var_seen[_big_learnt[i].Var()] = false;
assert( Lit_Decided( _big_learnt[i] ) );
if ( _var_stamps[_big_learnt[i].Var()] > _var_stamps[_big_learnt[max].Var()] )
max = i;
}
Literal lit = _big_learnt[max];
_big_learnt[max] = _big_learnt[1];
_big_learnt[1] = lit;
return _var_stamps[lit.Var()]; // I should check this line!
}
inline Reason Solver::Add_Learnt_Sort()
{
Reason reason;
if ( _big_learnt.Size() == 1 ) return Reason::undef;
else if ( _big_learnt.Size() == 2 ) {
_binary_clauses[_big_learnt[0]].push_back( _big_learnt[1] );
_binary_clauses[_big_learnt[1]].push_back( _big_learnt[0] );
reason = Reason( _big_learnt[1] );
}
else {
_long_watched_lists[_big_learnt[0]].push_back( _long_clauses.size() );
_long_watched_lists[_big_learnt[1]].push_back( _long_clauses.size() );
reason = Reason( _long_clauses.size(), SAT_REASON_CLAUSE );
_long_clauses.push_back( Clause( _big_learnt ) ); // allocate memory
}
Update_Heur_Decaying_Sum();
return reason;
}
void Solver::Update_Heur_Decaying_Sum()
{
switch ( running_options.sat_heur_lits ) {
case Heuristic_Literal_Unsorted_List:
break;
case Heuristic_Literal_Sorted_List:
Update_Heur_Decaying_Sum_Sorted_List();
break;
case Heuristic_Literal_Heap:
Update_Heur_Decaying_Sum_Heap();
break;
}
}
void Solver::Update_Heur_Decaying_Sum_Sorted_List() // input information is store in _big_learnt
{
unsigned i, j, k, l;
for ( i = 0; i < _big_learnt.Size(); i++ ) {
assert( _big_learnt[i] <= 2 * _max_var + 1 );
assert( !_lit_seen[_big_learnt[i]] );
_lit_seen[_big_learnt[i]] = true;
}
const double sentinel_weight = _heur_decaying_sum[_heur_lit_sentinel];
_heur_decaying_sum[_heur_lit_sentinel] = _heur_decaying_sum[_heur_sorted_lits[0]] + 2; /// for the next loop termination
_big_clause.Resize( _big_learnt.Size() + 1 );
_big_clause.Last_Lit() = _heur_lit_sentinel;
j = k = _big_learnt.Size();
l = 2 * ( _max_var - Variable::start + 1 ) - 1; /// last position of heur_lits
for ( i = l; i != UNSIGNED_UNDEF; i-- ) {
_heur_decaying_sum[_heur_sorted_lits[i]] *= running_options.sat_heur_decay_factor;
if ( _lit_seen[_heur_sorted_lits[i]] ) {
_heur_decaying_sum[_heur_sorted_lits[i]] += 1;
_big_clause[j--] = _heur_sorted_lits[i];
_big_clause[j] = _heur_lit_sentinel;
assert( j <= _max_var );//////////
}
else {
while ( _heur_decaying_sum[_big_clause[k]] <= _heur_decaying_sum[_heur_sorted_lits[i]] ) {
_heur_sorted_lits[l--] = _big_clause[k--];
}
_heur_sorted_lits[l--] = _heur_sorted_lits[i];
}
// Compile_Top_Down_Display_SAT_Heuristic_Value( cout );
}
while ( k > 0 ) {
assert( l <= _max_var + 1 ); /// cannot put it outside the loop because l might be equal to UNSIGNED_UNDEF
_heur_sorted_lits[l--] = _big_clause[k--];
}
_heur_decaying_sum[_heur_lit_sentinel] = sentinel_weight;
for ( i = 0; i < _big_learnt.Size(); i++ ) {
_lit_seen[_big_learnt[i]] = false;
}
}
void Solver::Update_Heur_Decaying_Sum_Heap() // input information is store in _big_learnt
{
/* for ( Variable i = Variable::start; i <= _max_var; i++ ) {
_heur_decaying_sum[Literal( i, false )] *= running_options.sat_heur_decay_factor;
_heur_decaying_sum[Literal( i, true )] *= running_options.sat_heur_decay_factor;
}
for ( unsigned i = 0; i < _big_learnt.Size(); i++ ) {
_heur_decaying_sum[_big_learnt[i]] += 1;
_heur_lits_heap.Prioritize( _big_learnt[i] );
}*/
running_options.sat_heur_cumulative_inc *= ( 1 / running_options.sat_heur_decay_factor );
for ( unsigned i = 0; i < _big_learnt.Size(); i++ ) {
Bump_Heur_Lit( _big_learnt[i] );
}
}
void Solver::Bump_Heur_Lit( Literal lit )
{
_heur_decaying_sum[lit] += running_options.sat_heur_cumulative_inc;
if ( _heur_decaying_sum[lit] > running_options.sat_heur_bound ) {
Rescale_Heur_Decaying_Sum();
}
_heur_lits_heap.Prioritize( lit );
}
void Solver::Rescale_Heur_Decaying_Sum()
{
ASSERT( running_options.sat_heur_lits == Heuristic_Literal_Heap );
cerr << "rescale" << endl;
for ( Variable i = Variable::start; i <= _max_var; i++ ) {
_heur_decaying_sum[Literal( i, false )] /= running_options.sat_heur_bound;
_heur_decaying_sum[Literal( i, true )] /= running_options.sat_heur_bound;
}
running_options.sat_heur_cumulative_inc /= running_options.sat_heur_bound;
}
bool Solver::Solve_External( vector<Model *> & models )
{
StopWatch watch;
size_t i;
if ( running_options.profile_solving >= Profiling_Detail ) watch.Start();
if ( running_options.profile_solving >= Profiling_Detail ) statistics.num_external_solve++;
vector<vector<int>> clauses;
Prepare_Ext_Clauses( clauses );
_minisat_extra_output.return_model = true;
_minisat_extra_output.return_units = true;
_minisat_extra_output.return_learnt_max_len = 2;
int8_t result = Minisat::Ext_Solve( clauses, _minisat_extra_output );
if ( result == 1 ) {
for ( i = 0; i < _minisat_extra_output.units.size(); i++ ) {
Literal lit = InternLit( _minisat_extra_output.units[i] );
if ( Lit_Undecided( lit ) ) {
Assign( lit );
BCP( _num_dec_stack - 1 );
}
}
for ( i = 0; i < _minisat_extra_output.short_learnts[0].size(); i += 2 ) {
Add_Binary_Clause_Naive( InternLit( _minisat_extra_output.short_learnts[0][i] ), InternLit( _minisat_extra_output.short_learnts[0][i+1] ) );
}
assert( _minisat_extra_output.models.size() == 1 );
Add_Model( _minisat_extra_output.models.front(), models );
_minisat_extra_output.models.clear();
}
else if ( running_options.profile_solving >= Profiling_Detail ) statistics.num_unsat_solve++;
if ( running_options.profile_solving >= Profiling_Detail ) statistics.time_external_solve += watch.Get_Elapsed_Seconds();
return result == 1;
}
void Solver::Prepare_Ext_Clauses( vector<vector<int>> & clauses )
{
vector<int> ext_clause(1);
for ( unsigned i = 0; i < _num_dec_stack; i++ ) {
ext_clause[0] = ExtLit( _dec_stack[i] );
clauses.push_back( ext_clause );
}
ext_clause.resize(2);
for ( Variable i = Variable::start; i <= _max_var; i++ ) {
if ( Var_Decided( i ) ) continue;
Literal lit = Literal( i, false );
ext_clause[0] = ExtLit( lit );
for ( unsigned j = 0; j < _binary_clauses[lit].size(); j++ ) {
Literal lit2 = _binary_clauses[lit][j];
if ( lit > lit2 || Lit_Decided( lit2 ) ) continue;
ext_clause[1] = ExtLit( lit2 );
clauses.push_back( ext_clause );
}
lit = Literal( i, true );
ext_clause[0] = ExtLit( lit );
for ( unsigned j = 0; j < _binary_clauses[lit].size(); j++ ) {
Literal lit2 = _binary_clauses[lit][j];
if ( lit > lit2 || Lit_Decided( lit2 ) ) continue;
ext_clause[1] = ExtLit( lit2 );
clauses.push_back( ext_clause );
}
}
for ( unsigned i = 0; i < _old_num_long_clauses; i++ ) {
ext_clause.clear();
unsigned j;
for ( j = 0; j < _long_clauses[i].Size(); j++ ) {
Literal lit = _long_clauses[i][j];
if ( Lit_SAT( lit ) ) break;
if ( Lit_UNSAT( lit ) ) continue;
ext_clause.push_back( ExtLit( lit ) );
}
if ( j == _long_clauses[i].Size() ) clauses.push_back( ext_clause );
}
if ( DEBUG_OFF ) {
for ( unsigned i = 0; i < clauses.size(); i++ ) { // ToRemove
for ( unsigned j = 0; j < clauses[i].size(); j++ ) { // ToRemove
if ( InternLit( clauses[i][j] ) > _max_var ) { // ToRemove
cerr << "clauses[" << i << "][" << j << "] = " << clauses[i][j] << endl;
assert( InternLit( clauses[i][j] ) <= _max_var );
}
} // ToRemove
} // ToRemove
}
}
void Solver::Add_Model( vector<int8_t> & minisat_model, vector<Model *> & models )
{
Model * model = _model_pool->Allocate();
for ( Variable i = Variable::start; i <= _max_var; i++ ) {
model->Assign( i, minisat_model[ExtVar( i )] == 1 );
}
if ( DEBUG_OFF ) Verify_Model( model ); // ToModify
models.push_back( model );
}
void Solver::Add_Model( vector<Model *> & models )
{
Model * model = _model_pool->Allocate();
for ( Variable i = Variable::start; i <= _max_var; i++ ) {
model->Assign( i, _assignment[i] == true );
}
models.push_back( model );
}
Reason Solver::Search_Solution_Component( Component & comp, unsigned conf_limit )
{
unsigned old_num_levels = _num_levels;
assert( old_num_levels >= 3 ); /// required all initialized implied literals are pulled out
unsigned old_size = _long_clauses.size();
Literal branch;
while ( ( branch = Branch_Component( comp ) ) != _heur_lit_sentinel ) {
Extend_New_Level();
Assign( branch );
Reason conf = BCP( _num_dec_stack - 1 );
while ( conf != Reason::undef ) {
assert( _num_levels >= old_num_levels );
if ( _num_levels == old_num_levels ) {
return conf; // UNSAT
}
unsigned back_level = Analyze_Conflict( conf );
assert( _big_learnt.Size() > 1 && back_level >= old_num_levels - 2 ); /// required all initialized implied literals are pulled out
if ( back_level < old_num_levels - 1 ) {
Backjump( old_num_levels );
return Reason::mismatched; // implied literal by some previous level before \old_num_levels
}
Backjump( back_level + 1 );
Assign( _big_learnt[0], Add_Learnt_Sort_Component( comp ) );
if ( _long_clauses.size() - old_size > conf_limit ) {
Backjump( old_num_levels );
return Reason::unknown; // restart
}
conf = BCP( _num_dec_stack - 1 );
}
}
return Reason::undef; // SAT
}
unsigned Solver::Restart_Bound_Component( Component & comp )
{
// return UNSIGNED_UNDEF;
switch( 2 ) {
case 1:
return comp.Vars_Size() - 2 + comp.ClauseIDs_Size();
break;
case 2:
return running_options.sat_restart_trigger_init;
break;
}
}
Reason Solver::Add_Learnt_Sort_Component( Component & comp )
{
Reason reason;
if ( _big_learnt.Size() == 2 ) {
_binary_clauses[_big_learnt[0]].push_back( _big_learnt[1] );
_binary_clauses[_big_learnt[1]].push_back( _big_learnt[0] );
reason = Reason( _big_learnt[1] );
}
else {
assert( _big_learnt.Size() >= 3 ); // all initialized implied were pulled out
_long_watched_lists[_big_learnt[0]].push_back( _long_clauses.size() );
_long_watched_lists[_big_learnt[1]].push_back( _long_clauses.size() );
reason = Reason( _long_clauses.size(), SAT_REASON_CLAUSE );
_long_clauses.push_back( Clause( _big_learnt ) );
}
/* for ( unsigned i = 0; i < _big_learnt.Size(); i++ ) {
assert( Literal::start <= _big_learnt[i] && _big_learnt[i] <= 2 * _max_var + 1 );
assert( !_lit_seen[_big_learnt[i]] );
_heur_decaying_sum[_big_learnt[i]] += 1 / running_options.sat_heur_decay_factor;
}
for ( Variable i = Variable::start; i <= _max_var; i++ ) {
_heur_decaying_sum[i + i] *= running_options.sat_heur_decay_factor;
_heur_decaying_sum[i + i + 1] *= running_options.sat_heur_decay_factor;
}*/
Update_Heur_Decaying_Sum_Component( comp );
return reason;
}
void Solver::Update_Heur_Decaying_Sum_Component( Component & comp ) // input information is store in _big_learnt
{
switch ( running_options.sat_heur_lits ) {
case Heuristic_Literal_Unsorted_List:
break;
case Heuristic_Literal_Sorted_List:
Update_Heur_Decaying_Sum_Sorted_List_Component( comp );
break;
case Heuristic_Literal_Heap:
Update_Heur_Decaying_Sum_Heap();
// Update_Heur_Decaying_Sum_Heap_Component( comp );
break;
}
}
void Solver::Update_Heur_Decaying_Sum_Sorted_List_Component( Component & comp ) // input information is store in _big_learnt
{
unsigned i, j, k, l, num_effective_lits = 0;
for ( i = 0; i < _big_learnt.Size(); i++ ) {
assert( _big_learnt[i] <= 2 * _max_var + 1 );
assert( !_lit_seen[_big_learnt[i]] );
if ( comp.Search_Var( _big_learnt[i].Var() ) ) {
_lit_seen[_big_learnt[i]] = true;
num_effective_lits++;
}
}
const double sentinel_weight = _heur_decaying_sum[_heur_lit_sentinel];
_heur_decaying_sum[_heur_lit_sentinel] = _heur_decaying_sum[_heur_sorted_lits[0]] + 2; /// for the next loop termination
_big_clause.Resize( num_effective_lits + 1 );
_big_clause.Last_Lit() = _heur_lit_sentinel;
j = k = num_effective_lits;
l = 2 * comp.Vars_Size() - 1; /// last position of heur_lits
for ( i = l; i != UNSIGNED_UNDEF; i-- ) {
_heur_decaying_sum[_heur_sorted_lits[i]] *= running_options.sat_heur_decay_factor;
if ( _lit_seen[_heur_sorted_lits[i]] ) {
_heur_decaying_sum[_heur_sorted_lits[i]] += 1;
_big_clause[j--] = _heur_sorted_lits[i];
_big_clause[j] = _heur_lit_sentinel;
assert( j <= comp.Vars_Size() );//////////
}
else {
while ( _heur_decaying_sum[_big_clause[k]] <= _heur_decaying_sum[_heur_sorted_lits[i]] ) {
_heur_sorted_lits[l--] = _big_clause[k--];
}
_heur_sorted_lits[l--] = _heur_sorted_lits[i];
}
// Compile_Top_Down_Display_SAT_Heuristic_Value( cout );
}
while ( k > 0 ) {
assert( l <= comp.Vars_Size() + 1 ); /// cannot put it outside the loop because l might be equal to UNSIGNED_UNDEF
_heur_sorted_lits[l--] = _big_clause[k--];
}
_heur_decaying_sum[_heur_lit_sentinel] = sentinel_weight;
for ( i = 0; i < _big_learnt.Size(); i++ ) {
_lit_seen[_big_learnt[i]] = false;
}
}
void Solver::Update_Heur_Decaying_Sum_Heap_Component( Component & comp ) // input information is store in _big_learnt
{
for ( unsigned i = 0; i < comp.Vars_Size(); i++ ) {
Variable var = comp.Vars( i );
_heur_decaying_sum[Literal( var, false )] *= running_options.sat_heur_decay_factor;
_heur_decaying_sum[Literal( var, true )] *= running_options.sat_heur_decay_factor;
}
for ( unsigned i = 0; i < _big_learnt.Size(); i++ ) {
_heur_decaying_sum[_big_learnt[i]] += 1;
_heur_lits_heap.Prioritize( _big_learnt[i] );
}
}
Literal Solver::Branch_Component( Component & comp )
{
if ( running_options.sat_heur_lits == Heuristic_Literal_Unsorted_List ) {
comp.Add_Var( _max_var.Next() ); /// NOTE: to terminate the following for-loop without comparing
vector<unsigned>::const_iterator itr = comp.VarIDs_Begin();
vector<unsigned>::const_iterator end = comp.VarIDs_End();
Literal lit;
// Debug_Print_Visit_Number( cerr, __LINE__ ); // ToRemove
for ( ; Var_Decided( Variable( *itr ) ); itr++ );
if ( _heur_decaying_sum[*itr + *itr] > _heur_decaying_sum[*itr + *itr + 1] ) lit = Literal( Variable( *itr ), false );
else lit = Literal( Variable( *itr ), true );
for ( itr++, end--; itr < end; itr++ ) {
if ( Var_Undecided( Variable( *itr ) ) ) {
if ( _heur_decaying_sum[*itr + *itr] > _heur_decaying_sum[*itr + *itr + 1] ) {
if ( _heur_decaying_sum[*itr + *itr] > _heur_decaying_sum[lit] ) lit = Literal( Variable( *itr ), false );
}
else {
if ( _heur_decaying_sum[*itr + *itr + 1] > _heur_decaying_sum[lit] ) lit = Literal( Variable( *itr ), true );
}
}
}
comp.Dec_Var(); /// pop _max_var.Next()
return lit;
}
else if ( running_options.sat_heur_lits == Heuristic_Literal_Sorted_List ) {
unsigned i;
for ( i = 0; Lit_Decided( _heur_sorted_lits[i] ); i++ );
return _heur_sorted_lits[i];
}
else {
while ( !_heur_lits_heap.Empty() ) {
Literal lit = _heur_lits_heap.Extract_Max();
if ( Lit_Undecided( lit ) ) return lit;
}
return _heur_lit_sentinel;
}
}
unsigned Solver::Num_Clauses()
{
unsigned i, num = 0;
for ( i = Variable::start; i <= _max_var; i++ ) {
num += _binary_clauses[i + i].size();
num += _binary_clauses[i + i + 1].size();
}
num = num / 2 + _unary_clauses.size() + _long_clauses.size();
return num;
}
unsigned Solver::Old_Num_Clauses()
{
unsigned i, num = 0;
for ( i = Variable::start; i <= _max_var; i++ ) {
num += _old_num_binary_clauses[i + i];
num += _old_num_binary_clauses[i + i + 1];
}
num = num / 2 + _unary_clauses.size() + _old_num_long_clauses;
return num;
}
unsigned Solver::Old_Num_Binary_Clauses()
{
unsigned i, num = 0;
for ( i = Variable::start; i <= _max_var; i++ ) {
num += _old_num_binary_clauses[i + i];
num += _old_num_binary_clauses[i + i + 1];
}
return num / 2;
}
unsigned Solver::Num_Learnts()
{
unsigned i, num = 0;
for ( i = Variable::start; i <= _max_var; i++ ) {
num += _binary_clauses[i + i].size() - _old_num_binary_clauses[i + i];
num += _binary_clauses[i + i + 1].size() - _old_num_binary_clauses[i + i + 1];
}
num = num / 2 + _long_clauses.size() - _old_num_long_clauses;
return num;
}
unsigned Solver::Num_Binary_Learnts()
{
unsigned i, num = 0;
for ( i = Variable::start; i <= _max_var; i++ ) {
num += _binary_clauses[i + i].size() - _old_num_binary_clauses[i + i];
num += _binary_clauses[i + i + 1].size() - _old_num_binary_clauses[i + i + 1];
}
return num / 2;
}
void Solver::Verify_Satisfiability( CNF_Formula & cnf, bool result )
{
vector<vector<int>> original_eclauses;
cnf.ExtClauses( original_eclauses );
int sat = Minisat::Ext_Solve( original_eclauses, _minisat_extra_output );
assert( result == sat );
}
void Solver::Verify_Long_Learnt( unsigned pos )
{
assert( _old_num_long_clauses <= pos && pos <= _long_clauses.size() );
vector<vector<int>> clauses;
vector<int> ext_clause(1);
for ( unsigned i = 0; i < _long_clauses[pos].Size(); i++ ) {
ext_clause[0] = -ExtLit( _long_clauses[pos][i] );
clauses.push_back( ext_clause );
}
ext_clause.resize(2);
for ( Variable i = Variable::start; i <= _max_var; i++ ) {
Literal lit( i, false );
ext_clause[0] = ExtLit( lit );
for ( unsigned j = 0; j < _old_num_binary_clauses[lit]; j++ ) {
if ( lit > _binary_clauses[lit][j] ) continue;
ext_clause[1] = ExtLit( _binary_clauses[lit][j] );
clauses.push_back( ext_clause );
}
lit = Literal( i, true );
ext_clause[0] = ExtLit( lit );
for ( unsigned j = 0; j < _old_num_binary_clauses[lit]; j++ ) {
if ( lit > _binary_clauses[lit][j] ) continue;
ext_clause[1] = ExtLit( _binary_clauses[lit][j] );
clauses.push_back( ext_clause );
}
}
for ( unsigned i = 0; i < _old_num_long_clauses; i++ ) {
clauses.push_back( ExtLits( _long_clauses[i] ) );
}
assert( Minisat::Ext_Solve( clauses, _minisat_extra_output ) == 0 );
}
void Solver::Verify_Learnts( CNF_Formula & cnf )
{
unsigned learnt_index = Old_Num_Clauses();
Literal * lits = new Literal [2];
vector<Clause> learnts;
for ( Variable i = Variable::start; i <= _max_var; i++ ) {
lits[0] = Literal( i, false );
for ( unsigned j = _old_num_binary_clauses[i + i]; j < _binary_clauses[i + i].size(); j++ ) {
if ( i + i > _binary_clauses[i + i][j] ) continue;
lits[1] = _binary_clauses[i + i][j];
learnts.push_back( Clause( lits, 2 ) );
learnt_index++;
}
lits[0] = Literal( i, true );
for ( unsigned j = _old_num_binary_clauses[i + i + 1]; j < _binary_clauses[i + i + 1].size(); j++ ) {
if ( i + i + 1 > _binary_clauses[i + i + 1][j] ) continue;
lits[1] = _binary_clauses[i + i + 1][j];
learnts.push_back( Clause( lits, 2 ) );
learnt_index++;
}
}
delete [] lits;
vector<Clause>::iterator itr = _long_clauses.begin() + _old_num_long_clauses, end = _long_clauses.end();
for ( ; itr < end; itr++ ) {
learnts.push_back( itr->Copy() );
}
assert( learnts.size() == Num_Learnts() );
for ( itr = learnts.begin(), end = learnts.end(); itr < end; itr++ ) {
if ( !Imply_Clause_CNF_No_Learnt( cnf, *itr ) ) {
cerr << "The following learnt clause is not implied by cnf:" << endl;
cerr << learnt_index << ":\t";
itr->Display( cerr );
assert( false );
}
itr->Free();
learnt_index++;
}
}
bool Solver::Imply_Clause_CNF_No_Learnt( CNF_Formula & cnf, Clause & clause )
{
vector<Clause>::iterator itr = _long_clauses.begin();
vector<Clause>::iterator end = _long_clauses.end();
for ( ; itr < end; itr++ ) itr->Free();
_long_clauses.clear();
_old_num_long_clauses = 0;
for ( Variable i = Variable::start; i <= _max_var; i++ ) {
_binary_clauses[i + i].clear();
_old_num_binary_clauses[i + i] = 0;
_long_watched_lists[i + i].clear();
_binary_clauses[i + i + 1].clear();
_old_num_binary_clauses[i + i + 1] = 0;
_long_watched_lists[i + i + 1].clear();
}
_unary_clauses.clear();
Load_Instance( cnf );
for ( itr = _long_clauses.begin(), end = _long_clauses.end(); itr < end; itr++ ) {
_long_watched_lists[(*itr)[0]].push_back( itr - _long_clauses.begin() );
_long_watched_lists[(*itr)[1]].push_back( itr - _long_clauses.begin() );
}
assert( _num_dec_stack == 0 );
for ( unsigned i = 0; i < _unary_clauses.size(); i++ ) {
if ( Lit_Undecided( _unary_clauses[i] ) ) Assign( _unary_clauses[i] );
else if ( _assignment[_unary_clauses[i].Var()] != _unary_clauses[i].Sign() ) {
Un_BCP( 0 );
return true;
}
}
for ( unsigned i = 0; i < clause.Size(); i++ ) {
if ( !Var_Decided( clause[i].Var() ) ) Assign( ~clause[i] );
else if ( Lit_SAT( clause[i] ) ) {
Un_BCP( 0 );
return true;
}
}
if ( BCP( 0 ) != Reason::undef ) {
Un_BCP( 0 );
return true;
}
assert( _num_levels == 0 );
_dec_offsets[_num_levels++] = _num_dec_stack;
while ( true ) {
Variable i;
for ( i = Variable::start; Var_Decided( i ); i++ );
if ( i > _max_var ) {
Verify_Model( cnf );
Un_BCP( 0 );
_num_levels = 0;
return false;
}
else {
_dec_offsets[_num_levels++] = _num_dec_stack;
Assign( i, false, Reason::undef );
}
while ( BCP( _num_dec_stack - 1 ) != Reason::undef ) {
Un_BCP( _dec_offsets[--_num_levels] );
if ( _num_levels == 0 ) {
Un_BCP( 0 );
return true;
}
Assign( ~_dec_stack[_dec_offsets[_num_levels]] );
}
}
assert( false );
return true;
}
void Solver::Verify_Current_Imps()
{
vector<vector<int>> clauses;
vector<int> ext_clause(1);
for ( unsigned i = 0; i <= _dec_offsets[_num_levels - 1]; i++ ) {
ext_clause[0] = ExtLit( _dec_stack[i] );
clauses.push_back( ext_clause );
}
ext_clause.resize(2);
for ( Variable i = Variable::start; i <= _max_var; i++ ) {
Literal lit = Literal( i, false );
ext_clause[0] = ExtLit( lit );
for ( unsigned j = 0; j < _old_num_binary_clauses[lit]; j++ ) {
if ( lit > _binary_clauses[lit][j] ) continue;
ext_clause[1] = ExtLit( _binary_clauses[lit][j] );
clauses.push_back( ext_clause );
}
lit = Literal( i, true );
ext_clause[0] = ExtLit( lit );
for ( unsigned j = 0; j < _old_num_binary_clauses[lit]; j++ ) {
if ( lit > _binary_clauses[lit][j] ) continue;
ext_clause[1] = ExtLit( _binary_clauses[lit][j] );
clauses.push_back( ext_clause );
}
}
for ( unsigned i = 0; i < _old_num_long_clauses; i++ ) {
clauses.push_back( ExtLits( _long_clauses[i] ) );
}
ext_clause.resize(1);
for ( unsigned i = _dec_offsets[_num_levels - 1] + 1; i < _num_dec_stack; i++ ) {
ext_clause[0] = -ExtLit( _dec_stack[i] );
clauses.push_back( ext_clause );
if ( Minisat::Ext_Solve( clauses, _minisat_extra_output ) != 0 ) {
Display_Decision_Stack( cerr, _num_levels - 1 );
cerr << "ERROR[Compiler]: _dec_stack[" << i << "] = " << _dec_stack[i] << " is an invalid implied literal!" << endl;
assert( false );
}
clauses.back()[0] = ExtLit( _dec_stack[i] );
}
}
void Solver::Verify_Model( Model * model )
{
for ( Variable i = Variable::start; i <= _max_var; i++ ) {
Literal lit( i, !(*model)[i] );
for ( unsigned j = 0; j < _binary_clauses[lit].size(); j++ ) {
Literal li = _binary_clauses[lit][j];
if ( (*model)[li.Var()] != li.Sign() ) {
cerr << "ERROR[Solver]: not satisfy ";
cerr << ExtLit( lit );
cerr << " ";
cerr << ExtLit( li );
cerr << endl;
}
assert( (*model)[li.Var()] == li.Sign() );
}
}
vector<Clause>::iterator itr = _long_clauses.begin();
vector<Clause>::iterator end = _long_clauses.end();
for ( ; itr < end; itr++ ) {
Clause & clause = *itr;
unsigned i;
for ( i = 0; i < clause.Size(); i++ ) {
if ( (*model)[clause[i].Var()] == clause[i].Sign() ) break;
}
if ( i == clause.Size() ) {
cerr << "ERROR[Solver]: model is invalid!" << endl;
for ( Variable j = Variable::start; j <= _max_var; j++ ) {
if ( (*model)[j] == 0 ) cerr << "-";
cerr << ExtVar( j ) << " ";
}
cerr << endl;
cerr << "ERROR[Solver]: not satisfy the " << itr - _long_clauses.begin() << "th clause ";
itr->Display( cerr );
assert( false );
}
}
}
void Solver::Verify_Model( CNF_Formula & cnf )
{
vector<Clause>::iterator itr = cnf.Clause_Begin();
vector<Clause>::iterator end = cnf.Clause_End();
for ( ; itr < end; itr++ ) {
Clause & clause = *itr;
unsigned i;
for ( i = 0; i < clause.Size(); i++ ) {
if ( Lit_SAT( clause[i] ) ) break;
}
if ( i == clause.Size() ) {
cerr << "ERROR[Solver]: The following _assignment is not a model of cnf!" << endl;
for ( Variable j = Variable::start; j <= _max_var; j++ ) {
assert( Var_Decided( j ) );
if ( _assignment[j] == false ) cerr << "-";
cerr << ExtVar( j ) << " ";
}
cerr << endl;
assert( false );
}
}
}
void Solver::Verify_Model( Model * model, CNF_Formula & cnf )
{
unsigned num = 0;
vector<Clause>::iterator itr = cnf.Clause_Begin();
vector<Clause>::iterator end = cnf.Clause_End();
for ( ; itr < end; itr++ ) {
Clause & clause = *itr;
unsigned i;
for ( i = 0; i < clause.Size(); i++ ) {
if ( (*model)[clause[i].Var()] == clause[i].Sign() ) break;
}
if ( i == clause.Size() ) {
cerr << "ERROR[Solver]: The " << itr - cnf.Clause_Begin() << "th clause is not satisfied!" << endl;
num++;
}
}
if ( num > 0 ) {
for ( Variable i = Variable::start; i <= _max_var; i++ ) {
if ( !(*model)[i] ) cerr << "-";
cerr << ExtVar( i ) << " ";
}
cerr << endl;
assert( num == 0 );
}
}
void Solver::Verify_Binary_Clauses()
{
for ( Literal lit = Literal::start; lit <= 2 * _max_var + 1; lit++ ) {
assert( _binary_clauses[lit].size() <= _max_var + 1 );
for ( unsigned i = 0; i < _binary_clauses[lit].size(); i++ ) {
Literal lit2 = _binary_clauses[lit][i];
assert( lit2 <= 2 * _max_var + 1 );
assert( lit2 != lit );
unsigned j;
for ( j = 0; j < _binary_clauses[lit2].size(); j++ ) {
if ( _binary_clauses[lit2][j] == lit ) break;
}
if ( j == _binary_clauses[lit2].size() ) {
cerr << "ERROR[Solver]: " << lit << " does not appear in _binary_clauses[" << lit2 << "]" << endl;
assert( j < _binary_clauses[lit2].size() );
}
unsigned loc = j;
for ( j++; j < _binary_clauses[lit2].size(); j++ ) {
if ( _binary_clauses[lit2][j] == lit ) break;
}
if ( j < _binary_clauses[lit2].size() ) {
cerr << "ERROR[Solver]: " << lit << " does not appear in _binary_clauses[" << lit2 << "] more than once!" << endl;
assert( j == _binary_clauses[lit2].size() );
}
if ( i < _old_num_binary_clauses[lit] ) {
if ( loc >= _old_num_binary_clauses[lit2] ) {
cerr << "ERROR[Solver]: literal" << ExtLit( lit2 ) << " should be in an original binary clause with " << ExtLit( lit ) << "!" << endl;
assert( loc < _old_num_binary_clauses[lit2] );
}
}
else if ( loc < _old_num_binary_clauses[lit2] ) {
cerr << "ERROR[Solver]: literal" << ExtLit( lit2 ) << " should be in a binary learnt clause with " << ExtLit( lit ) << "!" << endl;
assert( loc >= _old_num_binary_clauses[lit2] );
}
}
}
}
void Solver::Verify_Reasons()
{
for ( unsigned i = 0; i < _num_dec_stack; i++ ) {
Reason r = _reasons[_dec_stack[i].Var()];
if ( r == Reason::undef || r.Is_Lit_Reason() ) continue;
unsigned cl = r.Clause_Value();
assert( _long_clauses[cl][0] == _dec_stack[i] );
}
}
void Solver::Display_Statistics( ostream & out )
{
}
void Solver::Display_Clauses( ostream & out, bool all )
{
unsigned index = 0;
if ( !all ) out << "p cnf " << _max_var - Variable::start + 1 << ' ' << Old_Num_Clauses() << endl;
else out << "p cnf " << _max_var - Variable::start + 1 << ' ' << Num_Clauses() << endl;
for ( unsigned i = 0; i < _unary_clauses.size(); i++ ) {
if ( all ) out << index++ << ":\t";
out << ExtLit( _unary_clauses[i] ) << ' ' << '0' << endl;
}
for ( Variable i = Variable::start; i <= _max_var; i++ ) {
for ( unsigned j = 0; j < _old_num_binary_clauses[i + i]; j++ ) {
if ( i + i > _binary_clauses[i + i][j] ) continue;
if ( all ) out << index++ << ":\t";
out << '-' << ExtVar( i ) << " ";
out << ExtLit( _binary_clauses[i + i][j] ) << " 0" << endl;
}
for ( unsigned j = 0; j < _old_num_binary_clauses[i + i + 1]; j++ ) {
if ( i + i + 1 > _binary_clauses[i + i + 1][j] ) continue;
if ( all ) out << index++ << ":\t";
out << ExtVar( i ) << " ";
out << ExtLit( _binary_clauses[i + i + 1][j] ) << " 0" << endl;
}
}
for ( unsigned i = 0; i < _old_num_long_clauses; i++ ) {
if ( all ) out << index++ << ":\t";
out << _long_clauses[i] << endl;
}
if ( !all ) return;
out << "--------" << endl;
for ( Variable i = Variable::start; i <= _max_var; i++ ) {
for ( unsigned j = _old_num_binary_clauses[i + i]; j < _binary_clauses[i + i].size(); j++ ) {
if ( i + i > _binary_clauses[i + i][j] ) continue;
out << index++ << ":\t";
out << '-' << ExtVar( i ) << " ";
out << ExtLit( _binary_clauses[i + i][j] ) << " 0" << endl;
}
for ( unsigned j = _old_num_binary_clauses[i + i + 1]; j < _binary_clauses[i + i + 1].size(); j++ ) {
if ( i + i + 1 > _binary_clauses[i + i + 1][j] ) continue;
out << index++ << ":\t";
out << ExtVar( i ) << " ";
out << ExtLit( _binary_clauses[i + i + 1][j] ) << " 0" << endl;
}
}
for ( unsigned i = _old_num_long_clauses; i < _long_clauses.size(); i++ ) {
out << index++ << ":\t";
out << _long_clauses[i] << endl;
}
}
void Solver::Display_Clauses_No_Learnt( ostream & out )
{
if ( _max_var == Variable::undef ) {
out << "No data."<< endl;
return;
}
unsigned index = 0;
out << "p cnf " << _max_var - Variable::start + 1 << ' ' << Num_Clauses() << endl;
for ( unsigned i = 0; i < _unary_clauses.size(); i++ ) {
out << index++ << ":\t";
out << ExtLit( _unary_clauses[i] ) << ' ' << '0' << endl;
}
for ( Variable i = Variable::start; i <= _max_var; i++ ) {
for ( unsigned j = 0; j < _binary_clauses[i + i].size(); j++ ) {
if ( i + i > _binary_clauses[i + i][j] ) continue;
out << index++ << ":\t";
out << '-' << ExtVar( i ) << " ";
out << ExtLit( _binary_clauses[i + i][j] ) << " 0" << endl;
}
for ( unsigned j = 0; j < _binary_clauses[i + i + 1].size(); j++ ) {
if ( i + i + 1 > _binary_clauses[i + i + 1][j] ) continue;
out << index++ << ":\t";
out << ExtVar( i ) << " ";
out << ExtLit( _binary_clauses[i + i + 1][j] ) << " 0" << endl;
}
}
for ( unsigned i = 0; i < _long_clauses.size(); i++ ) {
out << index++ << ":\t";
Clause & clause = _long_clauses[i];
for ( unsigned j = 0; j < clause.Size(); j++ ) {
out << ExtLit( clause[j] ) << ' ';
}
out << '0' << endl;
}
}
void Solver::Display_Long_Clauses( ostream & out, bool all )
{
unsigned i, j, index = 0;
if ( !all ) out << "p cnf " << _max_var - Variable::start + 1 << ' ' << _old_num_long_clauses << endl;
else out << "p cnf " << _max_var - Variable::start + 1 << ' ' << _long_clauses.size() << endl;
for ( i = 0; i < _old_num_long_clauses; i++ ) {
if ( all ) out << index++ << ":\t";
Clause & clause = _long_clauses[i];
for ( j = 0; j < clause.Size(); j++ ) {
out << ExtLit( clause[j] ) << ' ';
}
out << '0' << endl;
}
if ( !all ) return;
out << "--------" << endl;
for ( i = _old_num_long_clauses; i < _long_clauses.size(); i++ ) {
out << index++ << ":\t";
Clause & clause = _long_clauses[i];
for ( j = 0; j < clause.Size(); j++ ) {
out << ExtLit( clause[j] ) << ' ';
}
out << '0' << endl;
}
}
void Solver::Display_Long_Clauses_No_Learnt( ostream & out )
{
unsigned i, j, index = 0;
out << "p cnf " << _max_var - Variable::start + 1 << ' ' << _long_clauses.size() << endl;
for ( i = 0; i < _long_clauses.size(); i++ ) {
out << index++ << ":\t";
Clause & clause = _long_clauses[i];
for ( j = 0; j < clause.Size(); j++ ) {
out << ExtLit( clause[j] ) << ' ';
}
out << '0' << endl;
}
}
void Solver::Display_Binary_Learnts( ostream & out )
{
for ( Literal i = Literal::start; i <= 2 * _max_var + 1; i++ ) {
out << ExtLit(i) << ":";
for ( unsigned j = _old_num_binary_clauses[i]; j < _binary_clauses[i].size(); j++ ) {
out << ' ' << ExtLit( _binary_clauses[i][j] );
}
out << endl;
}
}
void Solver::Display_Watched_List_Naive( ostream & out )
{
for ( Variable i = Variable::start; i <= _max_var; i++ ) {
out << "-" << ExtVar( i ) << ": ";
vector<unsigned>::iterator itr = _long_watched_lists[i + i].begin();
vector<unsigned>::iterator end = _long_watched_lists[i + i].end();
for ( ; itr < end; itr++ ) {
if ( *itr < _old_num_long_clauses ) out << *itr << ' ';
else out << *itr << ' ';
}
out << endl;
}
for ( Variable i = Variable::start; i <= _max_var; i++ ) {
out << ExtVar( i ) << ": ";
vector<unsigned>::iterator itr = _long_watched_lists[i + i + 1].begin();
vector<unsigned>::iterator end = _long_watched_lists[i + i + 1].end();
for ( ; itr < end; itr++ ) {
if ( *itr < _old_num_long_clauses ) out << *itr << ' ';
else out << *itr << ' ';
}
out << endl;
}
}
void Solver::Display_Watched_List( ostream & out )
{
unsigned num_old_short = Old_Num_Clauses() - _old_num_long_clauses; // NOTE: the number of old short clauses (unary or binary)
unsigned num_short = Num_Clauses() - _long_clauses.size(); // NOTE: the number of short clauses (unary or binary)
for ( Variable i = Variable::start; i <= _max_var; i++ ) {
out << "-" << ExtVar( i ) << ": ";
vector<unsigned>::iterator itr = _long_watched_lists[2 * i].begin();
vector<unsigned>::iterator end = _long_watched_lists[2 * i].end();
for ( ; itr < end; itr++ ) {
if ( *itr < _old_num_long_clauses ) out << *itr + num_old_short << ' ';
else out << *itr + num_short << ' ';
}
out << endl;
}
for ( Variable i = Variable::start; i <= _max_var; i++ ) {
out << ExtVar( i ) << ": ";
vector<unsigned>::iterator itr = _long_watched_lists[2 * i].begin();
vector<unsigned>::iterator end = _long_watched_lists[2 * i].end();
for ( ; itr < end; itr++ ) {
if ( *itr < _old_num_long_clauses ) out << *itr + num_old_short << ' ';
else out << *itr + num_short << ' ';
}
out << endl;
}
}
void Solver::Display_SAT_Heuristic_Value( ostream & out )
{
if ( running_options.sat_heur_lits == Heuristic_Literal_Sorted_List ) {
for ( unsigned i = 0; i < 2 * NumVars( _max_var ); i++ ) {
out << ExtLit( _heur_sorted_lits[i] ) << ": ";
out << _heur_decaying_sum[_heur_sorted_lits[i]] << endl;
}
}
else if ( running_options.sat_heur_lits == Heuristic_Literal_Heap ) {
for ( unsigned i = 0; i < _heur_lits_heap.Size(); i++ ) {
out << ExtLit( _heur_lits_heap[i] ) << ": ";
out << _heur_decaying_sum[_heur_lits_heap[i]] << endl;
}
}
}
void Solver::Display_Decision_Stack( ostream & out, unsigned base_dec_level )
{
unsigned i = 0, j = _dec_offsets[0];
if ( 0 < base_dec_level && base_dec_level < _num_levels ) {
for ( ; i < base_dec_level; i++ ) {
out << "(" << i << ") ";
for ( ; j < _dec_offsets[i + 1]; j++ ) {
out << ExtLit( _dec_stack[j] ) << " ";
}
}
out << endl;
}
for ( ; i < _num_levels - 1; i++ ) {
out << "(" << i << ") ";
for ( ; j < _dec_offsets[i + 1]; j++ ) {
out << ExtLit( _dec_stack[j] ) << " ";
}
}
out << "(" << i << ") ";
for ( ; j < _num_dec_stack; j++ ) {
out << ExtLit( _dec_stack[j] ) << " ";
}
out << endl;
}
void Solver::Display_Conflict( Reason confl, ostream & out )
{
unsigned i;
if ( confl == Reason::undef ) {
out << "confl = \tReason::undefined" << endl;
}
else if ( confl.Is_Clause_Reason() ) {
Clause &clause = _long_clauses[confl.Clause_Value()];
out << "confl = " << confl.Clause_Value() << ":";
for ( i = 0; i < clause.Size(); i++ ) {
out << "\t";
out << ExtLit( clause[i] );
}
out << endl;
out << "_var_stamps = ";
for ( i = 0; i < clause.Size(); i++ ) {
out << "\t" << _var_stamps[clause[i].Var()];
}
out << endl;
out << "_var_seen = ";
for ( i = 0; i < clause.Size(); i++ ) {
out << "\t" << _var_seen[clause[i].Var()];
}
out << endl;
}
else {
out << "confl = \t";
out << ExtLit( confl.Lit_Value() );
out << endl;
out << "_var_stamps = \t" << _var_stamps[confl.Lit_Value().Var()] << endl;
out << "_var_seen = \t" << _var_seen[confl.Lit_Value().Var()] << endl;
}
}
bool Solver::Load_Instance( vector<Clause> & clauses )
{
unsigned i, j;
_clause_status.assign( clauses.size(), false ); // Annotate: the bit true means that the corresponding clause is blocked
for ( i = 0; i < clauses.size(); i++ ) {
Clause & clause = clauses[i];
_big_clause.Clear();
for ( j = 0; j < clause.Size(); j++ ) {
if ( _lit_seen[clause[j]] ) continue;
else if ( _lit_seen[~clause[j]] ) break;
else {
_big_clause.Add_Lit( clause[j] );
_lit_seen[clause[j]] = true;
}
}
if ( j < clause.Size() ) { // Annotate: tautology
_lit_seen[_big_clause[0]] = false;
for ( j = 1; j < _big_clause.Size(); j++ ) _lit_seen[_big_clause[j]] = false;
_clause_status[i] = true;
continue;
}
if ( _big_clause.Size() == 1 ) {
_lit_seen[_big_clause[0]] = false;
if ( Lit_Undecided( _big_clause[0] ) ) {
_unary_clauses.push_back( _big_clause[0] );
Assign( _big_clause[0] );
clause[0] = _big_clause[0];
clause.Shrink( 1 );
}
else if ( Lit_UNSAT( _big_clause[0] ) ) return false;
_clause_status[i] = true; // Annotate: appeared previously
}
else {
_lit_seen[_big_clause[0]] = false;
clause[0] = _big_clause[0];
_lit_seen[_big_clause[1]] = false;
clause[1] = _big_clause[1];
for ( j = 2; j < _big_clause.Size(); j++ ) {
_lit_seen[_big_clause[j]] = false;
clause[j] = _big_clause[j];
}
clause.Shrink( _big_clause.Size() );
}
}
if ( !_unary_clauses.empty() && !Simplify_Original_Clauses_By_Unary( clauses ) ) return false;
for ( i = 0; i < clauses.size(); i++ ) { /// NOTE: load non-unary clauses here
Clause & clause = clauses[i];
if ( _clause_status[i] ) {
_clause_status[i] = false;
clause.Free();
}
else if ( clause.Size() == 2 ) {
Add_Binary_Clause_Naive( clause[0], clause[1] );
clause.Free();
}
else _long_clauses.push_back( clause ); /// cannot use clause._lits because it will be free in ~CNF_Formula
}
clauses.clear();
_old_num_long_clauses = _long_clauses.size();
for ( i = Variable::start; i <= _max_var; i++ ) {
_old_num_binary_clauses[i + i] = _binary_clauses[i + i].size();
_old_num_binary_clauses[i + i + 1] = _binary_clauses[i + i + 1].size();
}
return true;
}
bool Solver::Simplify_Original_Clauses_By_Unary( vector<Clause> & clauses )
{
for ( unsigned i = 0; i < clauses.size(); i++ ) { // _long_watched_lists is used as lit_membership_list
if ( _clause_status[i] ) continue;
Clause & clause = clauses[i];
_long_watched_lists[clause[0]].push_back( i );
_long_watched_lists[clause[1]].push_back( i );
for ( unsigned j = 2; j < clause.Size(); j++ ) {
_long_watched_lists[clause[j]].push_back( i );
}
}
for ( unsigned i = 0; i < _unary_clauses.size(); i++ ) {
Literal lit = _unary_clauses[i];
vector<unsigned>::iterator it = _long_watched_lists[lit].begin();
vector<unsigned>::iterator en = _long_watched_lists[lit].end();
for ( ; it < en; it++ ) {
_clause_status[*it] = true;
}
it = _long_watched_lists[~lit].begin();
en = _long_watched_lists[~lit].end();
for ( ; it < en; it++ ) {
Clause & clause = clauses[*it];
unsigned j;
for ( j = 0; clause[j] != ~lit; j++ ) {}
clause.Erase_Lit( j );
if ( clause.Size() == 1 ) {
if ( Lit_Undecided( clause[0] ) ) {
_unary_clauses.push_back( clause[0] );
Assign( clause[0] );
}
else if ( Lit_UNSAT( clause[0] ) ) return false; /// no need to clear _long_watched_lists
_clause_status[*it] = true;
}
}
}
for ( Variable i = Variable::start; i <= _max_var; i++ ) {
_long_watched_lists[i + i].clear();
_long_watched_lists[i + i + 1].clear();
}
return true;
}
size_t Solver::Memory()
{
size_t mem = _model_pool->Memory();
for ( Variable i = Variable::start; i <= _max_var; i++ ) {
mem += _binary_clauses[i + i].capacity() * sizeof(unsigned);
mem += _binary_clauses[i + i + 1].capacity() * sizeof(unsigned);
mem += _long_watched_lists[i + i].capacity() * sizeof(unsigned);
mem += _long_watched_lists[i + i + 1].capacity() * sizeof(unsigned);
}
for ( unsigned i = 0; i < _long_clauses.size(); i++ ) {
mem += _long_clauses[i].Size() * sizeof(unsigned) + sizeof(unsigned *) + sizeof(unsigned);
}
return mem;
}
void Solver::Free_Models( vector<Model *> & models )
{
vector<Model *>::iterator end = models.end();
for ( vector<Model *>::iterator itr = models.begin(); itr < end; itr++ ) {
_model_pool->Free( *itr );
}
models.clear();
}
}
| 34.479888 | 172 | 0.638167 | [
"vector",
"model"
] |
eb1c422a2e08d1b06bad0712e8484935f4d23c86 | 3,834 | cpp | C++ | src/safety_zone/safety_zone.cpp | ctu-mrs/mrs_lib | 1df4282d71c2944904676adbb7289ce45004432a | [
"BSD-3-Clause"
] | 1 | 2022-03-17T17:42:09.000Z | 2022-03-17T17:42:09.000Z | src/safety_zone/safety_zone.cpp | ctu-mrs/mrs_lib | 1df4282d71c2944904676adbb7289ce45004432a | [
"BSD-3-Clause"
] | 11 | 2020-10-20T09:36:36.000Z | 2022-03-08T19:17:26.000Z | src/safety_zone/safety_zone.cpp | ctu-mrs/mrs_lib | 1df4282d71c2944904676adbb7289ce45004432a | [
"BSD-3-Clause"
] | 2 | 2019-04-02T08:47:47.000Z | 2021-08-05T12:54:05.000Z | #include <mrs_lib/safety_zone/safety_zone.h>
#include <mrs_lib/safety_zone/line_operations.h>
namespace mrs_lib
{
/* SafetyZone() //{ */
SafetyZone::SafetyZone(mrs_lib::Polygon border, std::vector<Polygon> innerObstacles, std::vector<PointObstacle> pointObstacles)
: innerObstacles(innerObstacles), pointObstacles(pointObstacles) {
outerBorder = new Polygon(border);
}
//}
/* SafetyZone() //{ */
SafetyZone::~SafetyZone() {
delete outerBorder;
}
//}
/* SafetyZone() //{ */
SafetyZone::SafetyZone(const Eigen::MatrixXd& outerBorderMatrix, const std::vector<Eigen::MatrixXd>& innerObstaclesMatrixes,
const std::vector<Eigen::MatrixXd>& pointObstaclesMatrixes) {
try {
outerBorder = new Polygon(outerBorderMatrix);
}
catch (const Polygon::WrongNumberOfVertices&) {
throw BorderError();
}
catch (const Polygon::WrongNumberOfColumns&) {
throw BorderError();
}
catch (const Polygon::ExtraVertices&) {
throw BorderError();
}
for (auto& matrix : innerObstaclesMatrixes) {
try {
innerObstacles.emplace_back(matrix);
}
catch (const Polygon::WrongNumberOfVertices&) {
throw PolygonObstacleError();
}
catch (const Polygon::WrongNumberOfColumns&) {
throw PolygonObstacleError();
}
catch (const Polygon::ExtraVertices&) {
throw PolygonObstacleError();
}
}
for (auto& matrix : pointObstaclesMatrixes) {
if (matrix.cols() != 4 || matrix.rows() != 1) {
throw PointObstacleError();
}
pointObstacles.emplace_back(Eigen::RowVector2d{matrix(0, 0), matrix(0, 1)}, matrix(0, 2), matrix(0, 3));
}
}
//}
/* isPointValid3d() //{ */
bool SafetyZone::isPointValid3d(const double px, const double py, const double pz) {
if (!outerBorder->isPointInside(px, py)) {
return false;
}
for (auto& elem : innerObstacles) {
if (elem.isPointInside(px, py)) {
return false;
}
}
for (auto& elem : pointObstacles) {
if (elem.isPointInside3d(px, py, pz)) {
return false;
}
}
return true;
}
//}
/* isPointValid2d() //{ */
bool SafetyZone::isPointValid2d(const double px, const double py) {
if (!outerBorder->isPointInside(px, py)) {
return false;
}
for (auto& elem : innerObstacles) {
if (elem.isPointInside(px, py)) {
return false;
}
}
for (auto& elem : pointObstacles) {
if (elem.isPointInside2d(px, py)) {
return false;
}
}
return true;
}
//}
/* isPathValid3d() //{ */
bool SafetyZone::isPathValid3d(const double p1x, const double p1y, const double p1z, const double p2x, const double p2y, const double p2z) {
if (outerBorder->doesSectionIntersect(p1x, p1y, p2x, p2y)) {
return false;
}
for (auto& el : innerObstacles) {
if (el.doesSectionIntersect(p1x, p1y, p2x, p2y)) {
return false;
}
}
for (auto& el : pointObstacles) {
if (el.doesSectionIntersect3d(p1x, p1y, p1z, p2x, p2y, p2z)) {
return false;
}
}
return true;
}
//}
/* isPathValid2d() //{ */
bool SafetyZone::isPathValid2d(const double p1x, const double p1y, const double p2x, const double p2y) {
if (outerBorder->doesSectionIntersect(p1x, p1y, p2x, p2y)) {
return false;
}
for (auto& el : innerObstacles) {
if (el.doesSectionIntersect(p1x, p1y, p2x, p2y)) {
return false;
}
}
for (auto& el : pointObstacles) {
if (el.doesSectionIntersect2d(p1x, p1y, p2x, p2y)) {
return false;
}
}
return true;
}
//}
/* getBorder() //{ */
Polygon SafetyZone::getBorder() {
return *outerBorder;
}
//}
/* getObstacles() //{ */
std::vector<Polygon> SafetyZone::getObstacles() {
return innerObstacles;
}
//}
/* getPointObstacles() //{ */
std::vector<PointObstacle> SafetyZone::getPointObstacles() {
return pointObstacles;
}
//}
} // namespace mrs_lib
| 20.073298 | 140 | 0.642149 | [
"vector"
] |
eb1d8c3d99381ea7277371c343ee57e341b2b068 | 1,970 | cpp | C++ | Chapter_3_Problem_Solving_Paradigms/Complete_Search/kattis_natjecanje.cpp | BrandonTang89/CP4_Code | 5114471f439978dd11f6f2cbf6af20ca654593da | [
"MIT"
] | 2 | 2021-12-29T04:12:59.000Z | 2022-03-30T09:32:19.000Z | Chapter_3_Problem_Solving_Paradigms/Complete_Search/kattis_natjecanje.cpp | BrandonTang89/CP4_Code | 5114471f439978dd11f6f2cbf6af20ca654593da | [
"MIT"
] | null | null | null | Chapter_3_Problem_Solving_Paradigms/Complete_Search/kattis_natjecanje.cpp | BrandonTang89/CP4_Code | 5114471f439978dd11f6f2cbf6af20ca654593da | [
"MIT"
] | 1 | 2022-03-01T06:12:46.000Z | 2022-03-01T06:12:46.000Z | /**Kattis - natjecaje
* Somewhat tedious backtracking problem. But not too hard to AC if you are careful.
*
* Time: O(2^n), Space: O(n)
*/
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
int n, s, r, x;
vector<int> v;
int backtrack(int u){ // returns the minimal number of teams that cannot start competition
if (u == n){
int ans = 0;
for (auto i: v){
if (i == -1)ans++;
}
return ans;
}
if (v[u] != 1)return backtrack(u+1); // cannot do anything
int ans = INT_MAX;
if (u == 0){
if (v[1] == -1){
v[1] = 0;
v[0] = 0;
ans = backtrack(u+1);
v[1] = -1;
v[0] = 1;
}
else{
ans = backtrack(u+1);
}
return ans;
}
else if (u == n-1){
if (v[u-1] == -1){
v[u-1] = 0;
v[u] = 0;
ans = backtrack(u+1);
v[u-1] = -1;
v[u] = 1;
}
else{
ans = backtrack(u+1);
}
return ans;
}
else{
// either pass to before or after
ans = backtrack(u+1); // assume we dont need to pass to before or after
if (v[u-1] == -1){
v[u-1] = 0;
v[u] = 0;
ans = min(ans, backtrack(u+1));
v[u-1] = -1;
v[u] = 1;
}
if (v[u+1] == -1){
v[u+1] = 0;
v[u] = 0;
ans = min(ans, backtrack(u+1));
v[u+1] = -1;
v[u] = 1;
}
return ans;
}
}
int main(){
cin >> n >> s >> r;
v.assign(n, 0);
for (int i=0; i<s; i++){
cin >> x;
v[x-1] += -1;
}
for (int i=0; i<r; i++){
cin >> x;
v[x-1] += 1;
}
cout << backtrack(0) << endl;
return 0;
} | 22.643678 | 90 | 0.404569 | [
"vector"
] |
eb1ec40e4688747c411a45624f8f4af3ebfcfe21 | 9,935 | cpp | C++ | contrib/modules/text/src/ocr_tesseract.cpp | jekhor/opencv | 10dbe4619448461fd12762a815e8f5a226403bb3 | [
"BSD-3-Clause"
] | 1 | 2016-05-23T09:41:26.000Z | 2016-05-23T09:41:26.000Z | opencv_contrib-3.4.1/modules/text/src/ocr_tesseract.cpp | luoyongheng/opencv_add_contrib | 99fc5c28f5e39ebb1a2b76c592ef72d598c429cb | [
"BSD-3-Clause"
] | null | null | null | opencv_contrib-3.4.1/modules/text/src/ocr_tesseract.cpp | luoyongheng/opencv_add_contrib | 99fc5c28f5e39ebb1a2b76c592ef72d598c429cb | [
"BSD-3-Clause"
] | 3 | 2018-02-26T06:43:33.000Z | 2021-03-18T09:13:30.000Z | /*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's 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.
//
// * The name of the copyright holders may not 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 Intel Corporation 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.
//
//M*/
#include "precomp.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/ml.hpp"
#include <iostream>
#include <fstream>
#include <queue>
namespace cv
{
namespace text
{
using namespace std;
void OCRTesseract::run(Mat& image, string& output_text, vector<Rect>* component_rects,
vector<string>* component_texts, vector<float>* component_confidences,
int component_level)
{
CV_Assert( (image.type() == CV_8UC1) || (image.type() == CV_8UC3) );
CV_Assert( (component_level == OCR_LEVEL_TEXTLINE) || (component_level == OCR_LEVEL_WORD) );
output_text.clear();
if (component_rects != NULL)
component_rects->clear();
if (component_texts != NULL)
component_texts->clear();
if (component_confidences != NULL)
component_confidences->clear();
}
void OCRTesseract::run(Mat& image, Mat& mask, string& output_text, vector<Rect>* component_rects,
vector<string>* component_texts, vector<float>* component_confidences,
int component_level)
{
CV_Assert( (image.type() == CV_8UC1) || (image.type() == CV_8UC3) );
CV_Assert( mask.type() == CV_8UC1 );
CV_Assert( (component_level == OCR_LEVEL_TEXTLINE) || (component_level == OCR_LEVEL_WORD) );
output_text.clear();
if (component_rects != NULL)
component_rects->clear();
if (component_texts != NULL)
component_texts->clear();
if (component_confidences != NULL)
component_confidences->clear();
}
CV_WRAP String OCRTesseract::run(InputArray image, int min_confidence, int component_level)
{
std::string output1;
std::string output2;
vector<string> component_texts;
vector<float> component_confidences;
Mat image_m = image.getMat();
run(image_m, output1, NULL, &component_texts, &component_confidences, component_level);
for(unsigned int i = 0; i < component_texts.size(); i++)
{
// cout << "confidence: " << component_confidences[i] << " text:" << component_texts[i] << endl;
if(component_confidences[i] > min_confidence)
{
output2 += component_texts[i];
}
}
return String(output2);
}
CV_WRAP String OCRTesseract::run(InputArray image, InputArray mask, int min_confidence, int component_level)
{
std::string output1;
std::string output2;
vector<string> component_texts;
vector<float> component_confidences;
Mat image_m = image.getMat();
Mat mask_m = mask.getMat();
run(image_m, mask_m, output1, NULL, &component_texts, &component_confidences, component_level);
for(unsigned int i = 0; i < component_texts.size(); i++)
{
// cout << "confidence: " << component_confidences[i] << " text:" << component_texts[i] << endl;
if(component_confidences[i] > min_confidence)
{
output2 += component_texts[i];
}
}
return String(output2);
}
class OCRTesseractImpl : public OCRTesseract
{
private:
#ifdef HAVE_TESSERACT
tesseract::TessBaseAPI tess;
#endif
public:
//Default constructor
OCRTesseractImpl(const char* datapath, const char* language, const char* char_whitelist, int oemode, int psmode)
{
#ifdef HAVE_TESSERACT
const char *lang = "eng";
if (language != NULL)
lang = language;
if (tess.Init(datapath, lang, (tesseract::OcrEngineMode)oemode))
{
cout << "OCRTesseract: Could not initialize tesseract." << endl;
throw 1;
}
//cout << "OCRTesseract: tesseract version " << tess.Version() << endl;
tesseract::PageSegMode pagesegmode = (tesseract::PageSegMode)psmode;
tess.SetPageSegMode(pagesegmode);
if(char_whitelist != NULL)
tess.SetVariable("tessedit_char_whitelist", char_whitelist);
else
tess.SetVariable("tessedit_char_whitelist", "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
tess.SetVariable("save_best_choices", "T");
#else
cout << "OCRTesseract("<<oemode<<psmode<<"): Tesseract not found." << endl;
if (datapath != NULL)
cout << " " << datapath << endl;
if (language != NULL)
cout << " " << language << endl;
if (char_whitelist != NULL)
cout << " " << char_whitelist << endl;
#endif
}
~OCRTesseractImpl()
{
#ifdef HAVE_TESSERACT
tess.End();
#endif
}
void run(Mat& image, string& output, vector<Rect>* component_rects=NULL,
vector<string>* component_texts=NULL, vector<float>* component_confidences=NULL,
int component_level=0)
{
CV_Assert( (image.type() == CV_8UC1) || (image.type() == CV_8UC3) );
#ifdef HAVE_TESSERACT
if (component_texts != 0)
component_texts->clear();
if (component_rects != 0)
component_rects->clear();
if (component_confidences != 0)
component_confidences->clear();
tess.SetImage((uchar*)image.data, image.size().width, image.size().height, image.channels(), image.step1());
tess.Recognize(0);
char *outText;
outText = tess.GetUTF8Text();
output = string(outText);
delete [] outText;
if ( (component_rects != NULL) || (component_texts != NULL) || (component_confidences != NULL) )
{
tesseract::ResultIterator* ri = tess.GetIterator();
tesseract::PageIteratorLevel level = tesseract::RIL_WORD;
if (component_level == OCR_LEVEL_TEXTLINE)
level = tesseract::RIL_TEXTLINE;
if (ri != 0) {
do {
const char* word = ri->GetUTF8Text(level);
if (word == NULL)
continue;
float conf = ri->Confidence(level);
int x1, y1, x2, y2;
ri->BoundingBox(level, &x1, &y1, &x2, &y2);
if (component_texts != 0)
component_texts->push_back(string(word));
if (component_rects != 0)
component_rects->push_back(Rect(x1,y1,x2-x1,y2-y1));
if (component_confidences != 0)
component_confidences->push_back(conf);
delete[] word;
} while (ri->Next(level));
}
delete ri;
}
tess.Clear();
#else
cout << "OCRTesseract(" << component_level << image.type() <<"): Tesseract not found." << endl;
output.clear();
if(component_rects)
component_rects->clear();
if(component_texts)
component_texts->clear();
if(component_confidences)
component_confidences->clear();
#endif
}
void run(Mat& image, Mat& mask, string& output, vector<Rect>* component_rects=NULL,
vector<string>* component_texts=NULL, vector<float>* component_confidences=NULL,
int component_level=0)
{
CV_Assert( mask.type() == CV_8UC1 );
CV_Assert( (image.type() == CV_8UC1) || (image.type() == CV_8UC3) );
run( mask, output, component_rects, component_texts, component_confidences, component_level);
}
void setWhiteList(const String& char_whitelist)
{
#ifdef HAVE_TESSERACT
tess.SetVariable("tessedit_char_whitelist", char_whitelist.c_str());
#else
(void)char_whitelist;
#endif
}
};
Ptr<OCRTesseract> OCRTesseract::create(const char* datapath, const char* language,
const char* char_whitelist, int oem, int psmode)
{
return makePtr<OCRTesseractImpl>(datapath, language, char_whitelist, oem, psmode);
}
}
}
| 35.73741 | 122 | 0.624459 | [
"vector"
] |
eb221c91b55accb801a392e9adf2a4e2681b0006 | 2,074 | cpp | C++ | Leetcode Daily Challenge/August-2021/18. Decode Ways.cpp | Akshad7829/DataStructures-Algorithms | 439822c6a374672d1734e2389d3fce581a35007d | [
"MIT"
] | 1 | 2022-01-23T15:41:37.000Z | 2022-01-23T15:41:37.000Z | Leetcode Daily Challenge/August-2021/18. Decode Ways.cpp | Akshad7829/DataStructures-Algorithms | 439822c6a374672d1734e2389d3fce581a35007d | [
"MIT"
] | 2 | 2022-02-25T13:36:46.000Z | 2022-02-25T14:06:44.000Z | Leetcode Daily Challenge/August-2021/18. Decode Ways.cpp | Akshad7829/DataStructures-Algorithms | 439822c6a374672d1734e2389d3fce581a35007d | [
"MIT"
] | 1 | 2021-10-08T10:07:41.000Z | 2021-10-08T10:07:41.000Z | /*
Decode Ways
===========
A message containing letters from A-Z can be encoded into numbers using the following mapping:
'A' -> "1"
'B' -> "2"
...
'Z' -> "26"
To decode an encoded message, all the digits must be grouped then mapped back into letters using the reverse of the mapping above (there may be multiple ways). For example, "11106" can be mapped into:
"AAJF" with the grouping (1 1 10 6)
"KJF" with the grouping (11 10 6)
Note that the grouping (1 11 06) is invalid because "06" cannot be mapped into 'F' since "6" is different from "06".
Given a string s containing only digits, return the number of ways to decode it.
The answer is guaranteed to fit in a 32-bit integer.
Example 1:
Input: s = "12"
Output: 2
Explanation: "12" could be decoded as "AB" (1 2) or "L" (12).
Example 2:
Input: s = "226"
Output: 3
Explanation: "226" could be decoded as "BZ" (2 26), "VF" (22 6), or "BBF" (2 2 6).
Example 3:
Input: s = "0"
Output: 0
Explanation: There is no character that is mapped to a number starting with 0.
The only valid mappings with 0 are 'J' -> "10" and 'T' -> "20", neither of which start with 0.
Hence, there are no valid ways to decode this since all digits need to be mapped.
Example 4:
Input: s = "06"
Output: 0
Explanation: "06" cannot be mapped to "F" because of the leading zero ("6" is different from "06").
Constraints:
1 <= s.length <= 100
s contains only digits and may contain leading zero(s).
*/
class Solution
{
public:
int dfs(string &s, int i, vector<int> &memo)
{
if (s.size() == i)
return 1;
if (s[i] == '0')
return 0;
if (memo[i] != -1)
return memo[i];
int ans = 0;
ans += dfs(s, i + 1, memo);
if (i + 1 < s.size())
{
if (s[i] == '1' || (s[i] == '2' && s[i + 1] <= '6'))
{
ans += dfs(s, i + 2, memo);
}
}
return memo[i] = ans;
}
int numDecodings(string s)
{
vector<int> memo(s.size() + 1, -1);
return dfs(s, 0, memo);
}
}; | 25.604938 | 200 | 0.584378 | [
"vector"
] |
eb26c1a57639f0b01537501abdb38e6eeabbba3e | 7,326 | cpp | C++ | hub/src/DlgGenerateSshKey.cpp | satarovaAziza/control-center | ad8fd5a2b2f53836e827cfce2d283b802df553be | [
"Apache-2.0"
] | null | null | null | hub/src/DlgGenerateSshKey.cpp | satarovaAziza/control-center | ad8fd5a2b2f53836e827cfce2d283b802df553be | [
"Apache-2.0"
] | null | null | null | hub/src/DlgGenerateSshKey.cpp | satarovaAziza/control-center | ad8fd5a2b2f53836e827cfce2d283b802df553be | [
"Apache-2.0"
] | null | null | null | #include <QMessageBox>
#include <QApplication>
#include <QDir>
#include <QFile>
#include <RestWorker.h>
#include <QFileDialog>
#include <QStandardItem>
#include <QStandardItemModel>
#include <QListView>
#include <QModelIndexList>
#include <QItemSelectionModel>
#include <algorithm>
#include <QtConcurrent/QtConcurrent>
#include "DlgGenerateSshKey.h"
#include "ui_DlgGenerateSshKey.h"
#include "SystemCallWrapper.h"
#include "HubController.h"
#include "SettingsManager.h"
#include "NotificationObserver.h"
#include "SshKeysController.h"
#include "RhController.h"
DlgGenerateSshKey::DlgGenerateSshKey(QWidget *parent) :
QDialog(parent),
ui(new Ui::DlgGenerateSshKey),
m_change_everything_on_all_select(true)
{
ui->setupUi(this);
ui->btn_send_to_hub->setEnabled(false);
m_model_environments = new QStandardItemModel(this);
m_model_keys = new QStandardItemModel(this);
ui->lstv_environments->setModel(m_model_environments);
ui->lstv_sshkeys->setModel(m_model_keys);
ui->pb_send_to_hub->setVisible(false);
connect(ui->btn_generate_new_key, &QPushButton::released,
this, &DlgGenerateSshKey::btn_generate_released);
connect(ui->btn_send_to_hub, &QPushButton::released,
this, &DlgGenerateSshKey::btn_send_to_hub_released);
connect(ui->lstv_sshkeys->selectionModel(), &QItemSelectionModel::currentChanged,
this, &DlgGenerateSshKey::lstv_keys_current_changed);
connect(ui->chk_select_all, &QCheckBox::stateChanged,
this, &DlgGenerateSshKey::chk_select_all_checked_changed);
connect(m_model_environments, &QStandardItemModel::itemChanged,
this, &DlgGenerateSshKey::environments_item_changed);
connect(&CSshKeysController::Instance(), &CSshKeysController::ssh_key_send_progress,
this, &DlgGenerateSshKey::ssh_key_send_progress_sl);
connect(&CSshKeysController::Instance(), &CSshKeysController::ssh_key_send_finished,
this, &DlgGenerateSshKey::ssh_key_send_finished_sl);
connect(&CSshKeysController::Instance(), &CSshKeysController::matrix_updated,
this, &DlgGenerateSshKey::matrix_updated_slot);
connect(&CSshKeysController::Instance(), &CSshKeysController::key_files_changed,
this, &DlgGenerateSshKey::keys_updated_slot);
CSshKeysController::Instance().refresh_key_files();
CSshKeysController::Instance().refresh_healthy_environments();
rebuild_keys_model();
rebuild_environments_model();
set_environments_checked_flag();
if (m_model_keys->rowCount() && CSshKeysController::Instance().has_current_key()) {
ui->lstv_sshkeys->selectionModel()->setCurrentIndex(
m_model_keys->index(0, 0), QItemSelectionModel::Select);
}
}
////////////////////////////////////////////////////////////////////////////
DlgGenerateSshKey::~DlgGenerateSshKey() {
CSshKeysController::Instance().reset_matrix_current();
delete ui;
}
////////////////////////////////////////////////////////////////////////////
void
DlgGenerateSshKey::set_environments_checked_flag() {
for (int r = 0; r < m_model_environments->rowCount(); ++r) {
QStandardItem* item = m_model_environments->item(r);
Qt::CheckState st =
CSshKeysController::Instance().get_key_environments_bit(r) ? Qt::Checked : Qt::Unchecked;
item->setCheckState(st);
}
}
////////////////////////////////////////////////////////////////////////////
void
DlgGenerateSshKey::rebuild_environments_model() {
m_model_environments->clear();
std::vector<CEnvironment> tmp = CSshKeysController::Instance().lst_healthy_environments();
for (auto i : tmp) {
QStandardItem* nitem = new QStandardItem(i.name());
nitem->setCheckable(true);
nitem->setCheckState(Qt::Unchecked);
nitem->setEditable(false);
m_model_environments->appendRow(nitem);
}
}
////////////////////////////////////////////////////////////////////////////
void
DlgGenerateSshKey::rebuild_keys_model() {
m_model_keys->clear();
for (auto i : CSshKeysController::Instance().lst_key_files()) {
QStandardItem* item = new QStandardItem(i);
item->setEditable(false);
m_model_keys->appendRow(item);
}
}
////////////////////////////////////////////////////////////////////////////
void DlgGenerateSshKey::btn_generate_released() {
QFileInfo fi(CSettingsManager::Instance().ssh_keys_storage());
if (!fi.isDir() || !fi.isWritable()) {
CNotificationObserver::Instance()->Info(
tr("You don't have write permission to ssh-keys directory. "
"Please add write permission or change ssh-keys storage in settings. Thanks"), DlgNotification::N_SETTINGS);
return;
}
CSshKeysController::Instance().generate_new_ssh_key(this);
CSshKeysController::Instance().refresh_key_files();
rebuild_keys_model();
}
////////////////////////////////////////////////////////////////////////////
void
DlgGenerateSshKey::btn_send_to_hub_released() {
ui->btn_send_to_hub->setEnabled(false);
ui->pb_send_to_hub->setVisible(true);
QtConcurrent::run(&CSshKeysController::Instance(),
&CSshKeysController::send_data_to_hub);
}
////////////////////////////////////////////////////////////////////////////
void
DlgGenerateSshKey::lstv_keys_current_changed(QModelIndex ix0,
QModelIndex ix1) {
UNUSED_ARG(ix1);
UNUSED_ARG(ix0);
CSshKeysController::Instance().set_current_key(
ui->lstv_sshkeys->currentIndex().data().toString());
set_environments_checked_flag();
ui->chk_select_all->setChecked(
CSshKeysController::Instance().current_key_is_allselected());
}
////////////////////////////////////////////////////////////////////////////
void
DlgGenerateSshKey::ssh_key_send_progress_sl(int part, int total) {
ui->pb_send_to_hub->setMaximum(total);
ui->pb_send_to_hub->setValue(part);
}
////////////////////////////////////////////////////////////////////////////
void
DlgGenerateSshKey::ssh_key_send_finished_sl() {
ui->pb_send_to_hub->setValue(ui->pb_send_to_hub->maximum());
}
////////////////////////////////////////////////////////////////////////////
void
DlgGenerateSshKey::chk_select_all_checked_changed(int st) {
if (!m_change_everything_on_all_select) return;
CSshKeysController::Instance().set_current_key_allselected(st == Qt::Checked);
set_environments_checked_flag();
}
void
DlgGenerateSshKey::matrix_updated_slot() {
rebuild_environments_model();
set_environments_checked_flag();
ui->btn_send_to_hub->setEnabled(CSshKeysController::Instance().something_changed());
}
////////////////////////////////////////////////////////////////////////////
void
DlgGenerateSshKey::keys_updated_slot() {
rebuild_keys_model();
rebuild_environments_model();
}
////////////////////////////////////////////////////////////////////////////
void
DlgGenerateSshKey::environments_item_changed(QStandardItem *item) {
CSshKeysController::Instance().set_key_environments_bit(item->index().row(),
item->checkState() == Qt::Checked);
ui->btn_send_to_hub->setEnabled(CSshKeysController::Instance().something_changed());
m_change_everything_on_all_select = false;
ui->chk_select_all->setChecked(CSshKeysController::Instance().current_key_is_allselected());
m_change_everything_on_all_select = true;
}
////////////////////////////////////////////////////////////////////////////
| 35.911765 | 118 | 0.648376 | [
"vector"
] |
eb290c7b29446800d8b63dba110832be9d063372 | 2,112 | cpp | C++ | src/ruby_object_backend.cpp | robfors/esruby-bind | f0809292ac577852703569b7ab0275340f66df90 | [
"MIT"
] | 1 | 2020-12-26T13:58:15.000Z | 2020-12-26T13:58:15.000Z | src/ruby_object_backend.cpp | robfors/esruby-bind | f0809292ac577852703569b7ab0275340f66df90 | [
"MIT"
] | null | null | null | src/ruby_object_backend.cpp | robfors/esruby-bind | f0809292ac577852703569b7ab0275340f66df90 | [
"MIT"
] | null | null | null | #include "ruby_object_backend.hpp"
namespace ESRubyBind
{
RubyObjectBackend::RubyObjectBackend(mrb_state* mrb, mrb_value ruby_object)
: _mrb(mrb), _ruby_self(ruby_object)
{
mrb_gc_register(_mrb, _ruby_self);
}
RubyObjectBackend::~RubyObjectBackend()
{
mrb_gc_unregister(_mrb, _ruby_self);
}
mrb_state* RubyObjectBackend::mrb()
{
return _mrb;
}
mrb_value RubyObjectBackend::ruby_object()
{
return _ruby_self;
}
emscripten::val RubyObjectBackend::send(emscripten::val js_method_name, emscripten::val js_args)
{
if (!js_method_name.isString())
{
printf("'method_name' must be a string\n");
throw std::invalid_argument("'method_name' must be a string");
}
std::string cpp_method_name = js_method_name.as<std::string>();
if (cpp_method_name.empty())
{
printf("'method_name' must not be empty\n");
throw std::invalid_argument("'method_name' must not be empty");
}
if (!js_args.isArray())
{
printf("'args' must be an array\n");
throw std::invalid_argument("'args' must be an array");
}
emscripten::val js_arg = emscripten::val::undefined();
mrb_int arg_count = js_args["length"].as<mrb_int>();
std::vector<mrb_value> ruby_args;
ruby_args.push_back(js_object_to_ruby_object(_mrb, js_method_name));
for (mrb_int i = 0; i < arg_count; i++)
{
js_arg = js_args.call<emscripten::val>("shift");
ruby_args.push_back(js_object_to_ruby_object(_mrb, js_arg));
}
mrb_value ruby_return;
ruby_return = mrb_funcall_argv(_mrb, _ruby_self, mrb_intern_lit(_mrb, "send"), ruby_args.size(), ruby_args.data());
if (_mrb->exc)
{
// Error
mrb_print_error(_mrb);
_mrb->exc = 0;
throw std::runtime_error("");
}
emscripten::val js_return = ruby_obj_to_js_object(_mrb, ruby_return);
return js_return;
}
EMSCRIPTEN_BINDINGS(ruby_object_backend)
{
emscripten::class_<RubyObjectBackend>("RubyObjectBackend")
.function("send", &RubyObjectBackend::send)
;
}
}
| 25.142857 | 119 | 0.65625 | [
"vector"
] |
eb344ba977862c62c2f6f6378fbb9821307babcb | 12,714 | cpp | C++ | game/graphics/opengl_renderer/loader/Loader.cpp | Hat-Kid/jak-project | 0e2320ca9584118316313e41e646b179a1083feb | [
"ISC"
] | null | null | null | game/graphics/opengl_renderer/loader/Loader.cpp | Hat-Kid/jak-project | 0e2320ca9584118316313e41e646b179a1083feb | [
"ISC"
] | null | null | null | game/graphics/opengl_renderer/loader/Loader.cpp | Hat-Kid/jak-project | 0e2320ca9584118316313e41e646b179a1083feb | [
"ISC"
] | null | null | null | #include "Loader.h"
#include "common/util/Timer.h"
#include "common/util/FileUtil.h"
#include "common/util/compress.h"
#include "game/graphics/opengl_renderer/loader/LoaderStages.h"
namespace {
std::string uppercase_string(const std::string& s) {
std::string result;
for (auto c : s) {
result.push_back(toupper(c));
}
return result;
}
} // namespace
Loader::Loader() {
m_loader_thread = std::thread(&Loader::loader_thread, this);
m_loader_stages = make_loader_stages();
}
Loader::~Loader() {
{
std::lock_guard<std::mutex> lk(m_loader_mutex);
m_want_shutdown = true;
m_loader_cv.notify_all();
}
m_loader_thread.join();
}
/*!
* Try to get a loaded level by name. It may fail and return nullptr.
* Getting a level will reset the counter for the level and prevent it from being kicked out
* for a little while.
*
* This is safe to call from the graphics thread
*/
const LevelData* Loader::get_tfrag3_level(const std::string& level_name) {
std::unique_lock<std::mutex> lk(m_loader_mutex);
const auto& existing = m_loaded_tfrag3_levels.find(level_name);
if (existing == m_loaded_tfrag3_levels.end()) {
return nullptr;
} else {
existing->second->frames_since_last_used = 0;
return existing->second.get();
}
}
/*!
* The game calls this to give the loader a hint on which levels we want.
* If the loader is not busy, it will begin loading the level.
* This should be called on every frame.
*/
void Loader::set_want_levels(const std::vector<std::string>& levels) {
std::unique_lock<std::mutex> lk(m_loader_mutex);
m_desired_levels = levels;
if (!m_level_to_load.empty()) {
// can't do anything, we're loading a level right now
return;
}
if (!m_initializing_tfrag3_levels.empty()) {
// can't do anything, we're initializing a level right now
return;
}
// loader isn't busy, try to load one of the requested levels.
for (auto& lev : levels) {
auto it = m_loaded_tfrag3_levels.find(lev);
if (it == m_loaded_tfrag3_levels.end()) {
// we haven't loaded it yet. Request this level to load and wake up the thread.
m_level_to_load = lev;
lk.unlock();
m_loader_cv.notify_all();
return;
}
}
}
/*!
* Get all levels that are in memory and used very recently.
*/
std::vector<LevelData*> Loader::get_in_use_levels() {
std::vector<LevelData*> result;
std::unique_lock<std::mutex> lk(m_loader_mutex);
for (auto& lev : m_loaded_tfrag3_levels) {
if (lev.second->frames_since_last_used < 5) {
result.push_back(lev.second.get());
}
}
return result;
}
/*!
* Loader function that runs in a completely separate thread.
* This is used for file I/O and unpacking.
*/
void Loader::loader_thread() {
while (!m_want_shutdown) {
std::unique_lock<std::mutex> lk(m_loader_mutex);
// this will keep us asleep until we've got a level to load.
m_loader_cv.wait(lk, [&] { return !m_level_to_load.empty() || m_want_shutdown; });
if (m_want_shutdown) {
return;
}
std::string lev = m_level_to_load;
// don't hold the lock while reading the file.
lk.unlock();
// simulate slower hard drive (so that the loader thread can lose to the game loads)
// std::this_thread::sleep_for(std::chrono::milliseconds(1500));
// load the fr3 file
Timer disk_timer;
auto data = file_util::read_binary_file(
file_util::get_file_path({fmt::format("assets/{}.fr3", uppercase_string(lev))}));
double disk_load_time = disk_timer.getSeconds();
// the FR3 files are compressed
Timer decomp_timer;
auto decomp_data = compression::decompress_zstd(data.data(), data.size());
double decomp_time = decomp_timer.getSeconds();
// Read back into the tfrag3::Level structure
Timer import_timer;
auto result = std::make_unique<tfrag3::Level>();
Serializer ser(decomp_data.data(), decomp_data.size());
result->serialize(ser);
double import_time = import_timer.getSeconds();
// and finally "unpack", which creates the vertex data we'll upload to the GPU
Timer unpack_timer;
for (auto& tie_tree : result->tie_trees) {
for (auto& tree : tie_tree) {
tree.unpack();
}
}
for (auto& t_tree : result->tfrag_trees) {
for (auto& tree : t_tree) {
tree.unpack();
}
}
for (auto& shrub_tree : result->shrub_trees) {
shrub_tree.unpack();
}
fmt::print(
"------------> Load from file: {:.3f}s, import {:.3f}s, decomp {:.3f}s unpack {:.3f}s\n",
disk_load_time, import_time, decomp_time, unpack_timer.getSeconds());
// grab the lock again
lk.lock();
// move this level to "initializing" state.
m_initializing_tfrag3_levels[lev] = std::make_unique<LevelData>(); // reset load state
m_initializing_tfrag3_levels[lev]->level = std::move(result);
m_level_to_load = "";
m_file_load_done_cv.notify_all();
}
}
/*!
* Load a "common" FR3 file that has non-level textures.
* This should be called during initialization, before any threaded loading goes on.
*/
void Loader::load_common(TexturePool& tex_pool, const std::string& name) {
auto data =
file_util::read_binary_file(file_util::get_file_path({fmt::format("assets/{}.fr3", name)}));
auto decomp_data = compression::decompress_zstd(data.data(), data.size());
Serializer ser(decomp_data.data(), decomp_data.size());
m_common_level.level = std::make_unique<tfrag3::Level>();
m_common_level.level->serialize(ser);
for (auto& tex : m_common_level.level->textures) {
m_common_level.textures.push_back(add_texture(tex_pool, tex, true));
}
Timer tim;
MercLoaderStage mls;
LoaderInput input;
input.tex_pool = &tex_pool;
input.mercs = &m_all_merc_models;
input.lev_data = &m_common_level;
bool done = false;
while (!done) {
done = mls.run(tim, input);
}
}
bool Loader::upload_textures(Timer& timer, LevelData& data, TexturePool& texture_pool) {
// try to move level from initializing to initialized:
constexpr int MAX_TEX_BYTES_PER_FRAME = 1024 * 128;
int bytes_this_run = 0;
int tex_this_run = 0;
if (data.textures.size() < data.level->textures.size()) {
std::unique_lock<std::mutex> tpool_lock(texture_pool.mutex());
while (data.textures.size() < data.level->textures.size()) {
auto& tex = data.level->textures[data.textures.size()];
data.textures.push_back(add_texture(texture_pool, tex, false));
bytes_this_run += tex.w * tex.h * 4;
tex_this_run++;
if (tex_this_run > 20) {
break;
}
if (bytes_this_run > MAX_TEX_BYTES_PER_FRAME || timer.getMs() > SHARED_TEXTURE_LOAD_BUDGET) {
break;
}
}
}
return data.textures.size() == data.level->textures.size();
}
void Loader::update_blocking(TexturePool& tex_pool) {
fmt::print("NOTE: coming out of blackout on next frame, doing all loads now...\n");
bool missing_levels = true;
while (missing_levels) {
bool needs_run = true;
while (needs_run) {
needs_run = false;
{
std::unique_lock<std::mutex> lk(m_loader_mutex);
if (!m_level_to_load.empty()) {
m_file_load_done_cv.wait(lk, [&]() { return m_level_to_load.empty(); });
}
}
}
needs_run = true;
while (needs_run) {
needs_run = false;
{
std::unique_lock<std::mutex> lk(m_loader_mutex);
if (!m_initializing_tfrag3_levels.empty()) {
needs_run = true;
}
}
if (needs_run) {
update(tex_pool);
}
}
{
std::unique_lock<std::mutex> lk(m_loader_mutex);
missing_levels = false;
for (auto& des : m_desired_levels) {
if (m_loaded_tfrag3_levels.find(des) == m_loaded_tfrag3_levels.end()) {
fmt::print("blackout loader doing additional level {}...\n", des);
missing_levels = true;
}
}
}
if (missing_levels) {
set_want_levels(m_desired_levels);
}
}
fmt::print("Blackout loads done. Current status:");
std::unique_lock<std::mutex> lk(m_loader_mutex);
for (auto& ld : m_loaded_tfrag3_levels) {
fmt::print(" {} is loaded.\n", ld.first);
}
}
void Loader::update(TexturePool& texture_pool) {
Timer loader_timer;
// only main thread can touch this.
for (auto& lev : m_loaded_tfrag3_levels) {
lev.second->frames_since_last_used++;
}
bool did_gpu_stuff = false;
// work on moving initializing to initialized.
{
// accessing initializing, should lock
std::unique_lock<std::mutex> lk(m_loader_mutex);
// grab the first initializing level:
const auto& it = m_initializing_tfrag3_levels.begin();
if (it != m_initializing_tfrag3_levels.end()) {
did_gpu_stuff = true;
std::string name = it->first;
auto& lev = it->second;
if (it->second->load_id == UINT64_MAX) {
it->second->load_id = m_id++;
}
// we're the only place that erases, so it's okay to unlock and hold a reference
lk.unlock();
bool done = true;
LoaderInput loader_input;
loader_input.lev_data = lev.get();
loader_input.mercs = &m_all_merc_models;
loader_input.tex_pool = &texture_pool;
for (auto& stage : m_loader_stages) {
Timer stage_timer;
done = stage->run(loader_timer, loader_input);
if (stage_timer.getMs() > 5.f) {
fmt::print("stage {} took {:.2f} ms\n", stage->name(), stage_timer.getMs());
}
if (!done) {
break;
}
}
if (done) {
lk.lock();
m_loaded_tfrag3_levels[name] = std::move(lev);
m_initializing_tfrag3_levels.erase(it);
for (auto& stage : m_loader_stages) {
stage->reset();
}
}
}
}
if (!did_gpu_stuff) {
// try to remove levels.
Timer unload_timer;
if (m_loaded_tfrag3_levels.size() >= 3) {
for (auto& lev : m_loaded_tfrag3_levels) {
if (lev.second->frames_since_last_used > 180) {
std::unique_lock<std::mutex> lk(texture_pool.mutex());
fmt::print("------------------------- PC unloading {}\n", lev.first);
for (size_t i = 0; i < lev.second->level->textures.size(); i++) {
auto& tex = lev.second->level->textures[i];
if (tex.load_to_pool) {
texture_pool.unload_texture(PcTextureId::from_combo_id(tex.combo_id),
lev.second->textures.at(i));
}
}
lk.unlock();
for (auto tex : lev.second->textures) {
if (EXTRA_TEX_DEBUG) {
for (auto& slot : texture_pool.all_textures()) {
if (slot.source) {
ASSERT(slot.gpu_texture != tex);
} else {
ASSERT(slot.gpu_texture != tex);
}
}
}
glBindTexture(GL_TEXTURE_2D, tex);
glDeleteTextures(1, &tex);
}
for (auto& tie_geo : lev.second->tie_data) {
for (auto& tie_tree : tie_geo) {
glDeleteBuffers(1, &tie_tree.vertex_buffer);
if (tie_tree.has_wind) {
glDeleteBuffers(1, &tie_tree.wind_indices);
}
}
}
for (auto& tfrag_geo : lev.second->tfrag_vertex_data) {
for (auto& tfrag_buff : tfrag_geo) {
glDeleteBuffers(1, &tfrag_buff);
}
}
glDeleteBuffers(1, &lev.second->collide_vertices);
glDeleteBuffers(1, &lev.second->merc_vertices);
glDeleteBuffers(1, &lev.second->merc_indices);
for (auto& model : lev.second->level->merc_data.models) {
auto& mercs = m_all_merc_models.at(model.name);
MercRef ref{&model, lev.second->load_id};
auto it = std::find(mercs.begin(), mercs.end(), ref);
ASSERT_MSG(it != mercs.end(), fmt::format("missing merc: {}\n", model.name));
mercs.erase(it);
}
m_loaded_tfrag3_levels.erase(lev.first);
break;
}
}
}
if (unload_timer.getMs() > 5.f) {
fmt::print("Unload took {:.2f}\n", unload_timer.getMs());
}
}
if (loader_timer.getMs() > 5) {
fmt::print("Loader::update slow setup: {:.1f}ms\n", loader_timer.getMs());
}
}
std::optional<MercRef> Loader::get_merc_model(const char* model_name) {
// don't think we need to lock here...
const auto& it = m_all_merc_models.find(model_name);
if (it != m_all_merc_models.end() && !it->second.empty()) {
// it->second.front().parent_level->frames_since_last_used = 0;
return it->second.front();
} else {
return std::nullopt;
}
} | 31.009756 | 99 | 0.622149 | [
"vector",
"model"
] |
eb358f7389514cdcd47491616b16f5031c6dda42 | 13,996 | cpp | C++ | src/libvoxelbot/combat/combat_environment.cpp | eladyaniv01/MicroMachine | dbf8d09f7c3400ed4f2e1b4b2c6c0405928d5807 | [
"MIT"
] | 1 | 2020-06-15T19:41:45.000Z | 2020-06-15T19:41:45.000Z | src/libvoxelbot/combat/combat_environment.cpp | eladyaniv01/MicroMachine | dbf8d09f7c3400ed4f2e1b4b2c6c0405928d5807 | [
"MIT"
] | null | null | null | src/libvoxelbot/combat/combat_environment.cpp | eladyaniv01/MicroMachine | dbf8d09f7c3400ed4f2e1b4b2c6c0405928d5807 | [
"MIT"
] | null | null | null | #include "combat_environment.h"
#include "simulator.h"
#include "../utilities/predicates.h"
#include <iostream>
using namespace std;
using namespace sc2;
int getDamageBonus(UNIT_TYPEID unit, const CombatUpgrades& upgrades) {
if (isStructure(unit)) return 0;
int bonus = 0;
switch(getUnitData(unit).race) {
case Race::Protoss:
if (isFlying(unit)) {
if (upgrades.hasUpgrade(UPGRADE_ID::PROTOSSAIRWEAPONSLEVEL1)) bonus += 1;
if (upgrades.hasUpgrade(UPGRADE_ID::PROTOSSAIRWEAPONSLEVEL2)) bonus += 1;
if (upgrades.hasUpgrade(UPGRADE_ID::PROTOSSAIRWEAPONSLEVEL3)) bonus += 1;
} else {
if (upgrades.hasUpgrade(UPGRADE_ID::PROTOSSGROUNDWEAPONSLEVEL1)) bonus += 1;
if (upgrades.hasUpgrade(UPGRADE_ID::PROTOSSGROUNDWEAPONSLEVEL2)) bonus += 1;
if (upgrades.hasUpgrade(UPGRADE_ID::PROTOSSGROUNDWEAPONSLEVEL3)) bonus += 1;
}
break;
case Race::Zerg:
if (isFlying(unit)) {
if (upgrades.hasUpgrade(UPGRADE_ID::ZERGFLYERWEAPONSLEVEL1)) bonus += 1;
if (upgrades.hasUpgrade(UPGRADE_ID::ZERGFLYERWEAPONSLEVEL2)) bonus += 1;
if (upgrades.hasUpgrade(UPGRADE_ID::ZERGFLYERWEAPONSLEVEL3)) bonus += 1;
} else if (isMelee(unit)) {
// TODO: Might need to check which units are actually melee
if (upgrades.hasUpgrade(UPGRADE_ID::ZERGMELEEWEAPONSLEVEL1)) bonus += 1;
if (upgrades.hasUpgrade(UPGRADE_ID::ZERGMELEEWEAPONSLEVEL2)) bonus += 1;
if (upgrades.hasUpgrade(UPGRADE_ID::ZERGMELEEWEAPONSLEVEL3)) bonus += 1;
} else {
// Ranged
if (upgrades.hasUpgrade(UPGRADE_ID::ZERGMISSILEWEAPONSLEVEL1)) bonus += 1;
if (upgrades.hasUpgrade(UPGRADE_ID::ZERGMISSILEWEAPONSLEVEL2)) bonus += 1;
if (upgrades.hasUpgrade(UPGRADE_ID::ZERGMISSILEWEAPONSLEVEL3)) bonus += 1;
}
break;
case Race::Terran: {
auto canonical = canonicalize(unit);
auto& casters = abilityToCasterUnit(getUnitData(canonical).ability_id);
if (casters.size() > 0 && casters[0] == UNIT_TYPEID::TERRAN_BARRACKS) {
if (upgrades.hasUpgrade(UPGRADE_ID::TERRANINFANTRYWEAPONSLEVEL1)) bonus += 1;
if (upgrades.hasUpgrade(UPGRADE_ID::TERRANINFANTRYWEAPONSLEVEL2)) bonus += 1;
if (upgrades.hasUpgrade(UPGRADE_ID::TERRANINFANTRYWEAPONSLEVEL3)) bonus += 1;
} else if (casters.size() > 0 && casters[0] == UNIT_TYPEID::TERRAN_FACTORY) {
if (upgrades.hasUpgrade(UPGRADE_ID::TERRANVEHICLEWEAPONSLEVEL1)) bonus += 1;
if (upgrades.hasUpgrade(UPGRADE_ID::TERRANVEHICLEWEAPONSLEVEL2)) bonus += 1;
if (upgrades.hasUpgrade(UPGRADE_ID::TERRANVEHICLEWEAPONSLEVEL3)) bonus += 1;
} else if (casters.size() > 0 && casters[0] == UNIT_TYPEID::TERRAN_STARPORT) {
if (upgrades.hasUpgrade(UPGRADE_ID::TERRANSHIPWEAPONSLEVEL1)) bonus += 1;
if (upgrades.hasUpgrade(UPGRADE_ID::TERRANSHIPWEAPONSLEVEL2)) bonus += 1;
if (upgrades.hasUpgrade(UPGRADE_ID::TERRANSHIPWEAPONSLEVEL3)) bonus += 1;
}
break;
}
default:
break;
}
return bonus;
}
float getArmorBonus(UNIT_TYPEID unit, const CombatUpgrades& upgrades) {
if (isStructure(unit)) {
if (getUnitData(unit).race == Race::Terran && upgrades.hasUpgrade(UPGRADE_ID::TERRANBUILDINGARMOR)) return 2;
return 0;
}
float bonus = 0;
switch(getUnitData(unit).race) {
case Race::Protoss:
if (isFlying(unit)) {
if (upgrades.hasUpgrade(UPGRADE_ID::PROTOSSAIRARMORSLEVEL1)) bonus += 1;
if (upgrades.hasUpgrade(UPGRADE_ID::PROTOSSAIRARMORSLEVEL2)) bonus += 1;
if (upgrades.hasUpgrade(UPGRADE_ID::PROTOSSAIRARMORSLEVEL3)) bonus += 1;
} else {
if (upgrades.hasUpgrade(UPGRADE_ID::PROTOSSGROUNDARMORSLEVEL1)) bonus += 1;
if (upgrades.hasUpgrade(UPGRADE_ID::PROTOSSGROUNDARMORSLEVEL2)) bonus += 1;
if (upgrades.hasUpgrade(UPGRADE_ID::PROTOSSGROUNDARMORSLEVEL3)) bonus += 1;
}
if (upgrades.hasUpgrade(UPGRADE_ID::PROTOSSSHIELDSLEVEL1)) bonus += 1;
if (upgrades.hasUpgrade(UPGRADE_ID::PROTOSSSHIELDSLEVEL2)) bonus += 1;
if (upgrades.hasUpgrade(UPGRADE_ID::PROTOSSSHIELDSLEVEL3)) bonus += 1;
break;
case Race::Zerg:
if (isFlying(unit)) {
if (upgrades.hasUpgrade(UPGRADE_ID::ZERGFLYERARMORSLEVEL1)) bonus += 1;
if (upgrades.hasUpgrade(UPGRADE_ID::ZERGFLYERARMORSLEVEL2)) bonus += 1;
if (upgrades.hasUpgrade(UPGRADE_ID::ZERGFLYERARMORSLEVEL3)) bonus += 1;
} else {
if (upgrades.hasUpgrade(UPGRADE_ID::ZERGGROUNDARMORSLEVEL1)) bonus += 1;
if (upgrades.hasUpgrade(UPGRADE_ID::ZERGGROUNDARMORSLEVEL2)) bonus += 1;
if (upgrades.hasUpgrade(UPGRADE_ID::ZERGGROUNDARMORSLEVEL3)) bonus += 1;
}
case Race::Terran: {
auto canonical = canonicalize(unit);
auto& casters = abilityToCasterUnit(getUnitData(canonical).ability_id);
if (casters.size() > 0 && casters[0] == UNIT_TYPEID::TERRAN_BARRACKS) {
if (upgrades.hasUpgrade(UPGRADE_ID::TERRANINFANTRYARMORSLEVEL1)) bonus += 1;
if (upgrades.hasUpgrade(UPGRADE_ID::TERRANINFANTRYARMORSLEVEL2)) bonus += 1;
if (upgrades.hasUpgrade(UPGRADE_ID::TERRANINFANTRYARMORSLEVEL3)) bonus += 1;
} else if (casters.size() > 0 && (casters[0] == UNIT_TYPEID::TERRAN_FACTORY || casters[0] == UNIT_TYPEID::TERRAN_STARPORT)) {
if (upgrades.hasUpgrade(UPGRADE_ID::TERRANVEHICLEANDSHIPARMORSLEVEL1)) bonus += 1;
if (upgrades.hasUpgrade(UPGRADE_ID::TERRANVEHICLEANDSHIPARMORSLEVEL2)) bonus += 1;
if (upgrades.hasUpgrade(UPGRADE_ID::TERRANVEHICLEANDSHIPARMORSLEVEL3)) bonus += 1;
}
break;
}
default:
break;
}
return bonus;
}
CombatEnvironment::CombatEnvironment(const CombatUpgrades& upgrades, const CombatUpgrades& targetUpgrades) : upgrades({{ upgrades, targetUpgrades }}) {
assertMappingsInitialized();
auto& unitTypes = getUnitTypes();
for (size_t i = 0; i < unitTypes.size(); i++) {
combatInfo[0].push_back(UnitCombatInfo((UNIT_TYPEID)i, upgrades, targetUpgrades));
}
for (size_t i = 0; i < unitTypes.size(); i++) {
combatInfo[1].push_back(UnitCombatInfo((UNIT_TYPEID)i, targetUpgrades, upgrades));
}
for (int owner = 0; owner < 2; owner++) {
combatInfo[owner][(int)UNIT_TYPEID::TERRAN_LIBERATOR].airWeapon.splash = 3.0;
combatInfo[owner][(int)UNIT_TYPEID::TERRAN_MISSILETURRET].airWeapon.splash = 3.0;
combatInfo[owner][(int)UNIT_TYPEID::TERRAN_SIEGETANKSIEGED].groundWeapon.splash = 4.0;
combatInfo[owner][(int)UNIT_TYPEID::TERRAN_HELLION].groundWeapon.splash = 2;
combatInfo[owner][(int)UNIT_TYPEID::TERRAN_HELLIONTANK].groundWeapon.splash = 3;
combatInfo[owner][(int)UNIT_TYPEID::ZERG_MUTALISK].groundWeapon.splash = 1.44f;
combatInfo[owner][(int)UNIT_TYPEID::ZERG_MUTALISK].airWeapon.splash = 1.44f;
combatInfo[owner][(int)UNIT_TYPEID::TERRAN_THOR].airWeapon.splash = 3;
combatInfo[owner][(int)UNIT_TYPEID::PROTOSS_ARCHON].groundWeapon.splash = 3;
combatInfo[owner][(int)UNIT_TYPEID::PROTOSS_ARCHON].airWeapon.splash = 3;
combatInfo[owner][(int)UNIT_TYPEID::PROTOSS_COLOSSUS].groundWeapon.splash = 3;
}
}
const CombatEnvironment& CombatPredictor::combineCombatEnvironment(const CombatEnvironment* env, const CombatUpgrades& upgrades, int upgradesOwner) const {
assert(upgradesOwner == 1 || upgradesOwner == 2);
array<CombatUpgrades, 2> newUpgrades = env != nullptr ? env->upgrades : array<CombatUpgrades, 2>{{ {}, {} }};
newUpgrades[upgradesOwner - 1].combine(upgrades);
return getCombatEnvironment(newUpgrades[0], newUpgrades[1]);
}
const CombatEnvironment& CombatPredictor::getCombatEnvironment(const CombatUpgrades& upgrades, const CombatUpgrades& targetUpgrades) const {
uint64_t hash = (upgrades.hash() * 5123143) ^ targetUpgrades.hash();
auto it = combatEnvironments.find(hash);
if (it != combatEnvironments.end()) {
return (*it).second;
}
// Note: references to map values are guaranteed to remain valid even after additional insertion into the map
return (*combatEnvironments.emplace(make_pair(hash, CombatEnvironment(upgrades, targetUpgrades))).first).second;
}
// TODO: Air?
float CombatEnvironment::attackRange(int owner, UNIT_TYPEID type) const {
auto& info = combatInfo[owner - 1][(int)type];
return max(info.airWeapon.range(), info.groundWeapon.range());
}
float CombatEnvironment::attackRange(const CombatUnit& unit) const {
auto& info = combatInfo[unit.owner - 1][(int)unit.type];
float range = max(info.airWeapon.range(), info.groundWeapon.range());
if (unit.type == UNIT_TYPEID::PROTOSS_COLOSSUS && upgrades[unit.owner-1].hasUpgrade(UPGRADE_ID::EXTENDEDTHERMALLANCE)) range += 2;
return range;
}
const UnitCombatInfo& CombatEnvironment::getCombatInfo(const CombatUnit& unit) const {
return combatInfo[unit.owner - 1][(int)unit.type];
}
float CombatEnvironment::calculateDPS(int owner, UNIT_TYPEID type, bool air) const {
auto& info = combatInfo[owner - 1][(int)type];
return air ? info.airWeapon.getDPS() : info.groundWeapon.getDPS();
}
float CombatEnvironment::calculateDPS(const vector<CombatUnit>& units, bool air) const {
float dps = 0;
for (auto& u : units)
dps += calculateDPS(u.owner, u.type, air);
return dps;
}
float CombatEnvironment::calculateDPS(const CombatUnit& unit, bool air) const {
auto& info = combatInfo[unit.owner - 1][(int)unit.type];
return air ? info.airWeapon.getDPS() : info.groundWeapon.getDPS();
}
float CombatEnvironment::calculateDPS(const CombatUnit& unit1, const CombatUnit& unit2) const {
auto& info = combatInfo[unit1.owner - 1][(int)unit1.type];
return max(info.groundWeapon.getDPS(unit2.type), info.airWeapon.getDPS(unit2.type));
}
float calculateDPS(UNIT_TYPEID attacker, UNIT_TYPEID target, const Weapon& weapon, const CombatUpgrades& attackerUpgrades, const CombatUpgrades& targetUpgrades) {
// canBeAttackedByAirWeapons is primarily for coloussus.
if (weapon.type == Weapon::TargetType::Any || (weapon.type == Weapon::TargetType::Air ? canBeAttackedByAirWeapons(target) : !isFlying(target))) {
float dmg = weapon.damage_;
for (auto& b : weapon.damage_bonus) {
if (contains(getUnitData(target).attributes, b.attribute)) {
dmg += b.bonus;
}
}
dmg += getDamageBonus(attacker, attackerUpgrades);
float armor = getUnitData(target).armor + getArmorBonus(target, targetUpgrades);
// Note: cannot distinguish between damage to shields and damage to health yet, so average out so that the armor is about 0.5 over the whole shield+health of the unit
// Important only for protoss
armor *= maxHealth(target) / (maxHealth(target) + maxShield(target));
float timeBetweenAttacks = weapon.speed;
if (attacker == UNIT_TYPEID::PROTOSS_ADEPT && attackerUpgrades.hasUpgrade(UPGRADE_ID::ADEPTPIERCINGATTACK)) timeBetweenAttacks /= 1.45f;
return max(0.0f, dmg - armor) * weapon.attacks / timeBetweenAttacks;
}
return 0;
}
float WeaponInfo::getDPS(UNIT_TYPEID target, float modifier) const {
if (!available || !weapon || weapon->speed == 0)
return 0;
if (dpsCache.find(unsigned(target)) == dpsCache.end()) {
cerr << "CombatSimulator error: dpsCache does not contain unit of type " << unsigned(target) << " named " << UnitTypeToName(target) << endl;
dpsCache[unsigned(target)] = 0;
}
// TODO: Modifier ignores speed upgrades
return max(0.0f, dpsCache[unsigned(target)] + modifier*weapon->attacks/weapon->speed);
}
float WeaponInfo::range() const {
return weapon != nullptr ? weapon->range : 0;
}
float UnitCombatInfo::attackInterval() const {
float v = numeric_limits<float>::infinity();
if (airWeapon.weapon != nullptr) v = airWeapon.weapon->speed;
if (groundWeapon.weapon != nullptr) v = min(v, groundWeapon.weapon->speed);
return v;
}
WeaponInfo::WeaponInfo(const Weapon* weapon, UNIT_TYPEID type, const CombatUpgrades& upgrades, const CombatUpgrades& targetUpgrades) {
available = true;
splash = 0;
this->weapon = weapon;
// TODO: Range upgrades!
baseDPS = (weapon->damage_ + getDamageBonus(type, upgrades)) * weapon->attacks / weapon->speed;
auto& unitTypes = getUnitTypes();
for (size_t i = 0; i < unitTypes.size(); i++) {
dpsCache[i] = calculateDPS(type, UNIT_TYPEID(i), *weapon, upgrades, targetUpgrades);
}
}
UnitCombatInfo::UnitCombatInfo(UNIT_TYPEID type, const CombatUpgrades& upgrades, const CombatUpgrades& targetUpgrades) {
auto& data = getUnitData(type);
for (const Weapon& weapon : data.weapons) {
if (weapon.type == Weapon::TargetType::Any || weapon.type == Weapon::TargetType::Air) {
if (airWeapon.available) {
cerr << "For unit type " << UnitTypeToName(type) << endl;
cerr << "Weapon slot is already used";
assert(false);
}
airWeapon = WeaponInfo(&weapon, type, upgrades, targetUpgrades);
}
if (weapon.type == Weapon::TargetType::Any || weapon.type == Weapon::TargetType::Ground) {
if (groundWeapon.available) {
cerr << "For unit type " << UnitTypeToName(type) << endl;
cerr << "Weapon slot is already used";
assert(false);
}
groundWeapon = WeaponInfo(&weapon, type, upgrades, targetUpgrades);
}
}
} | 47.767918 | 174 | 0.664118 | [
"vector"
] |
eb3a2f50a5f980bc360f40317c214b1e5cb2a52c | 304 | cpp | C++ | Hard/164_Maximum_Gap.cpp | ShehabMMohamed/LeetCodeCPP | 684340f29ac15c5e8fa9f6ef5c3f99d4c95ce780 | [
"MIT"
] | 1 | 2021-03-15T10:02:10.000Z | 2021-03-15T10:02:10.000Z | Hard/164_Maximum_Gap.cpp | ShehabMMohamed/LeetCodeCPP | 684340f29ac15c5e8fa9f6ef5c3f99d4c95ce780 | [
"MIT"
] | null | null | null | Hard/164_Maximum_Gap.cpp | ShehabMMohamed/LeetCodeCPP | 684340f29ac15c5e8fa9f6ef5c3f99d4c95ce780 | [
"MIT"
] | null | null | null | class Solution {
public:
int maximumGap(vector<int>& nums) {
if(nums.size() < 2) return 0;
sort(nums.begin(), nums.end());
int max_gap = 0;
for(int i = 0; i < nums.size()-1; i++)
max_gap = max(max_gap, nums[i+1] - nums[i]);
return max_gap;
}
}; | 27.636364 | 56 | 0.506579 | [
"vector"
] |
eb3ad213ef460de96b6be69d0c5699336d3f376c | 4,754 | cc | C++ | release/src-rt-6.x.4708/router/transmission/qt/FilterBarComboBoxDelegate.cc | afeng11/tomato-arm | 1ca18a88480b34fd495e683d849f46c2d47bb572 | [
"FSFAP"
] | 278 | 2015-11-03T03:01:20.000Z | 2022-01-20T18:21:05.000Z | release/src-rt-6.x.4708/router/transmission/qt/FilterBarComboBoxDelegate.cc | afeng11/tomato-arm | 1ca18a88480b34fd495e683d849f46c2d47bb572 | [
"FSFAP"
] | 374 | 2015-11-03T12:37:22.000Z | 2021-12-17T14:18:08.000Z | release/src-rt-6.x.4708/router/transmission/qt/FilterBarComboBoxDelegate.cc | afeng11/tomato-arm | 1ca18a88480b34fd495e683d849f46c2d47bb572 | [
"FSFAP"
] | 96 | 2015-11-22T07:47:26.000Z | 2022-01-20T19:52:19.000Z | /*
* This file Copyright (C) 2012-2015 Mnemosyne LLC
*
* It may be used under the GNU GPL versions 2 or 3
* or any future license endorsed by Mnemosyne LLC.
*
* $Id: FilterBarComboBoxDelegate.cc 14537 2015-06-10 21:27:11Z mikedld $
*/
#include <QAbstractItemView>
#include <QComboBox>
#include <QStandardItemModel>
#include <QStyle>
#include "FilterBarComboBox.h"
#include "FilterBarComboBoxDelegate.h"
#include "Utils.h"
namespace
{
int
getHSpacing (const QWidget * w)
{
return qMax (3, w->style ()->pixelMetric (QStyle::PM_LayoutHorizontalSpacing, 0, w));
}
}
FilterBarComboBoxDelegate::FilterBarComboBoxDelegate (QObject * parent, QComboBox * combo):
QItemDelegate (parent),
myCombo (combo)
{
}
bool
FilterBarComboBoxDelegate::isSeparator (const QModelIndex& index)
{
return index.data (Qt::AccessibleDescriptionRole).toString () == QLatin1String ("separator");
}
void
FilterBarComboBoxDelegate::setSeparator (QAbstractItemModel * model, const QModelIndex& index)
{
model->setData (index, QString::fromLatin1 ("separator"), Qt::AccessibleDescriptionRole);
if (QStandardItemModel *m = qobject_cast<QStandardItemModel*> (model))
if (QStandardItem *item = m->itemFromIndex (index))
item->setFlags (item->flags () & ~ (Qt::ItemIsSelectable|Qt::ItemIsEnabled));
}
void
FilterBarComboBoxDelegate::paint (QPainter * painter,
const QStyleOptionViewItem & option,
const QModelIndex & index) const
{
if (isSeparator (index))
{
QRect rect = option.rect;
if (const QStyleOptionViewItemV3 *v3 = qstyleoption_cast<const QStyleOptionViewItemV3*> (&option))
if (const QAbstractItemView *view = qobject_cast<const QAbstractItemView*> (v3->widget))
rect.setWidth (view->viewport ()->width ());
QStyleOption opt;
opt.rect = rect;
myCombo->style ()->drawPrimitive (QStyle::PE_IndicatorToolBarSeparator, &opt, painter, myCombo);
}
else
{
QStyleOptionViewItem disabledOption = option;
const QPalette::ColorRole disabledColorRole = (disabledOption.state & QStyle::State_Selected) ?
QPalette::HighlightedText : QPalette::Text;
disabledOption.palette.setColor (disabledColorRole, Utils::getFadedColor (disabledOption.palette.color (disabledColorRole)));
QRect boundingBox = option.rect;
const int hmargin = getHSpacing (myCombo);
boundingBox.adjust (hmargin, 0, -hmargin, 0);
QRect decorationRect = rect (option, index, Qt::DecorationRole);
decorationRect.setSize (myCombo->iconSize ());
decorationRect = QStyle::alignedRect (option.direction,
Qt::AlignLeft|Qt::AlignVCenter,
decorationRect.size (), boundingBox);
Utils::narrowRect (boundingBox, decorationRect.width () + hmargin, 0, option.direction);
QRect countRect = rect (option, index, FilterBarComboBox::CountStringRole);
countRect = QStyle::alignedRect (option.direction,
Qt::AlignRight|Qt::AlignVCenter,
countRect.size (), boundingBox);
Utils::narrowRect (boundingBox, 0, countRect.width () + hmargin, option.direction);
const QRect displayRect = boundingBox;
drawBackground (painter, option, index);
QStyleOptionViewItem option2 = option;
option2.decorationSize = myCombo->iconSize ();
drawDecoration (painter, option, decorationRect, decoration (option2,index.data (Qt::DecorationRole)));
drawDisplay (painter, option, displayRect, index.data (Qt::DisplayRole).toString ());
drawDisplay (painter, disabledOption, countRect, index.data (FilterBarComboBox::CountStringRole).toString ());
drawFocus (painter, option, displayRect|countRect);
}
}
QSize
FilterBarComboBoxDelegate::sizeHint (const QStyleOptionViewItem & option,
const QModelIndex & index) const
{
if (isSeparator (index))
{
const int pm = myCombo->style ()->pixelMetric (QStyle::PM_DefaultFrameWidth, 0, myCombo);
return QSize (pm, pm + 10);
}
else
{
QStyle * s = myCombo->style ();
const int hmargin = getHSpacing (myCombo);
QSize size = QItemDelegate::sizeHint (option, index);
size.setHeight (qMax (size.height (), myCombo->iconSize ().height () + 6));
size.rwidth () += s->pixelMetric (QStyle::PM_FocusFrameHMargin, 0, myCombo);
size.rwidth () += rect (option,index,FilterBarComboBox::CountStringRole).width ();
size.rwidth () += hmargin * 4;
return size;
}
}
| 38.967213 | 131 | 0.655027 | [
"model"
] |
eb3cd188e14ad61b1c3b62d7d2cac0d60b389e39 | 2,539 | cpp | C++ | main.cpp | markg85/cansole_calendar | 1578c4b6d12996f1d407ce096684e74f3988e9c1 | [
"BSD-3-Clause"
] | null | null | null | main.cpp | markg85/cansole_calendar | 1578c4b6d12996f1d407ce096684e74f3988e9c1 | [
"BSD-3-Clause"
] | null | null | null | main.cpp | markg85/cansole_calendar | 1578c4b6d12996f1d407ce096684e74f3988e9c1 | [
"BSD-3-Clause"
] | null | null | null | #include <iostream>
#include <iomanip>
#include <vector>
#include <numeric>
#include <ctime>
#include <algorithm>
#include <range.hpp>
#include <chunked.hpp>
#include <zip.hpp>
#include <accumulate.hpp>
const int weekStartsAt = 1;
const int firstDayOfYear = 6; // In which index position is the first day of the year. For 2017 that is sunday jan 1st.
const std::vector<std::string> dayNamesAccordingToWeekStart(const int weekStartDay)
{
// Define dayNames in std::tm tm_wday format. Now we know which day is which index.
std::vector<std::string> dayNames = {"s", "m", "t", "w", "t", "f", "s"};
// Rotate the vector so that our week start day becomes index 0.
std::rotate(dayNames.begin(), dayNames.begin() + weekStartDay, dayNames.end());
return dayNames;
}
// Leap year calculation (gregorian calendar)
constexpr bool isLeapYear(const int year)
{
return ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0));
}
constexpr int daysInMonth(const int month, const bool isLeapYear)
{
return 31 - ((month == 2) ? (3 - isLeapYear) : ((month - 1) % 7 % 2));
}
constexpr char *dayColumn(char day, char *data)
{
data[0] = ' ';
data[1] = (day > 9) ? '0' + ((day - (day % 10)) / 10) : ' ';
data[2] = '0' + (day % 10);
data[3] = '\0';
return data;
}
// Define dayNames in std::tm tm_wday format. Now we know which day is which index.
const std::vector<std::string> dayNamesShort = dayNamesAccordingToWeekStart(weekStartsAt);
int main(int, char **)
{
std::time_t time = std::time(nullptr);
std::tm *tm = std::localtime(&time);
int daysThusFar = 0;
char dayColumnBuffer[4];
for (auto &&month : iter::range(1, 13)) // 1, 13 is only for the isLeapYear function that assumes the second (2) month is februari.
{
int daysInCurrentMonth = daysInMonth(month, isLeapYear(1900 + tm->tm_year));
int dayIndex = ((daysThusFar % 7) + firstDayOfYear);
int startPosition = (dayIndex > 7) ? dayIndex % 7 : dayIndex;
daysThusFar += daysInCurrentMonth;
for (int dayNameIndex: iter::range(0, 7))
{
std::cout << " " << dayNamesShort[dayNameIndex] << ' ';
}
std::cout << std::endl;
for (auto&& daysInWeek: iter::chunked(iter::range(1 - startPosition, daysInCurrentMonth + 1), 7))
{
for (char day: daysInWeek)
{
if (day < 1)
{
std::cout << " ";
}
else
{
std::cout << dayColumn(day, dayColumnBuffer) << ' ';
}
}
std::cout << '\n';
}
std::cout << '\n';
}
return 0;
}
| 27.597826 | 133 | 0.615597 | [
"vector"
] |
eb437099776b87390b763a308b52ff20f215ab67 | 1,383 | cpp | C++ | tutorial/client.cpp | axell-corp/TFHEpp-1 | 6e489396575d2d6cf830af5b1153e8ab3d22f9c6 | [
"Apache-2.0"
] | 33 | 2020-01-29T08:43:37.000Z | 2022-03-29T03:06:12.000Z | tutorial/client.cpp | axell-corp/TFHEpp-1 | 6e489396575d2d6cf830af5b1153e8ab3d22f9c6 | [
"Apache-2.0"
] | 6 | 2020-01-17T12:40:40.000Z | 2022-03-24T12:47:23.000Z | tutorial/client.cpp | axell-corp/TFHEpp-1 | 6e489396575d2d6cf830af5b1153e8ab3d22f9c6 | [
"Apache-2.0"
] | 12 | 2020-05-10T19:10:43.000Z | 2022-01-10T05:12:33.000Z | #include <cereal/archives/portable_binary.hpp>
#include <cereal/types/vector.hpp>
#include <fstream>
#include <memory>
#include <random>
#include <tfhe++.hpp>
#include <vector>
int main()
{
// generate a random key
std::unique_ptr<TFHEpp::SecretKey> sk =
std::make_unique<TFHEpp::SecretKey>();
std::unique_ptr<TFHEpp::GateKey> gk =
std::make_unique<TFHEpp::GateKey>(*sk);
// export the secret key to file for later use
{
std::ofstream ofs{"secret.key", std::ios::binary};
cereal::PortableBinaryOutputArchive ar(ofs);
sk->serialize(ar);
};
// export the cloud key to a file (for the cloud)
{
std::ofstream ofs{"cloud.key", std::ios::binary};
cereal::PortableBinaryOutputArchive ar(ofs);
gk->serialize(ar);
};
// get client input
uint16_t client_input;
std::cout << "Type client input (16bit unsigned interger)" << std::endl;
std::cin >> client_input;
// encrypt the input
std::vector<uint8_t> p(16);
for (int i; i < 16; i++) p[i] = (client_input >> i) & 1;
std::vector<TFHEpp::TLWE<TFHEpp::lvl0param>> ciphertext =
TFHEpp::bootsSymEncrypt(p, *sk);
// export the ciphertexts to a file
{
std::ofstream ofs{"cloud.data", std::ios::binary};
cereal::PortableBinaryOutputArchive ar(ofs);
ar(ciphertext);
};
} | 28.8125 | 76 | 0.62039 | [
"vector"
] |
eb4be6beec5ce11987146adf7ef313bf9ae11a21 | 3,127 | cpp | C++ | aiEngine/src/path/navmesh/polytope/services/PlaneSurfaceSplitService.cpp | petitg1987/UrchinEngine | 32d4b62b1ab7e2aa781c99de11331e3738078b0c | [
"MIT"
] | 24 | 2015-10-05T00:13:57.000Z | 2020-05-06T20:14:06.000Z | aiEngine/src/path/navmesh/polytope/services/PlaneSurfaceSplitService.cpp | petitg1987/UrchinEngine | 32d4b62b1ab7e2aa781c99de11331e3738078b0c | [
"MIT"
] | 1 | 2019-11-01T08:00:55.000Z | 2019-11-01T08:00:55.000Z | aiEngine/src/path/navmesh/polytope/services/PlaneSurfaceSplitService.cpp | petitg1987/UrchinEngine | 32d4b62b1ab7e2aa781c99de11331e3738078b0c | [
"MIT"
] | 10 | 2015-11-25T07:33:13.000Z | 2020-03-02T08:21:10.000Z | #include <path/navmesh/polytope/services/PlaneSurfaceSplitService.h>
namespace urchin {
PlaneSurfaceSplitService::PlaneSurfaceSplitService(float surfaceMaxSize) :
surfaceMaxSize(surfaceMaxSize) {
}
std::vector<PlaneSurfaceSplit> PlaneSurfaceSplitService::splitRectangleSurface(const std::vector<Point3<float>>& planeSurfacePoints) const {
#ifdef URCHIN_DEBUG
assert(planeSurfacePoints.size() == 4);
assert(MathFunction::isZero(planeSurfacePoints[0].distance(planeSurfacePoints[1]) - planeSurfacePoints[2].distance(planeSurfacePoints[3]), 0.01f));
assert(MathFunction::isZero(planeSurfacePoints[1].distance(planeSurfacePoints[2]) - planeSurfacePoints[3].distance(planeSurfacePoints[0]), 0.01f));
#endif
std::vector<PlaneSurfaceSplit> planeSurfaceSplits;
auto aSamples = MathFunction::ceilToUInt(planeSurfacePoints[0].distance(planeSurfacePoints[1]) / surfaceMaxSize);
auto bSamples = MathFunction::ceilToUInt(planeSurfacePoints[1].distance(planeSurfacePoints[2]) / surfaceMaxSize);
if (aSamples == 1 && bSamples == 1) { //no split required
PlaneSurfaceSplit planeSurfaceSplit;
planeSurfaceSplit.planeSurfacePoints = planeSurfacePoints;
planeSurfaceSplits.emplace_back(planeSurfaceSplit);
return planeSurfaceSplits;
}
for (unsigned int aSample = 0; aSample < aSamples; ++aSample) {
float aPointStartRange = (float)aSample / (float)aSamples;
LineSegment3D aLine((1.0f - aPointStartRange) * planeSurfacePoints[0] + aPointStartRange * planeSurfacePoints[1],
(1.0f - aPointStartRange) * planeSurfacePoints[3] + aPointStartRange * planeSurfacePoints[2]);
float aPointEndRange = (float)(aSample + 1) / (float)aSamples;
LineSegment3D aNextLine((1.0f - aPointEndRange) * planeSurfacePoints[0] + aPointEndRange * planeSurfacePoints[1],
(1.0f - aPointEndRange) * planeSurfacePoints[3] + aPointEndRange * planeSurfacePoints[2]);
for (unsigned int bSample = 0; bSample < bSamples; ++bSample) {
float bPointStartRange = (float)bSample / (float)bSamples;
float bPointEndRange = (float)(bSample + 1) / (float)bSamples;
Point3<float> firstPoint = (1.0f - bPointStartRange) * aLine.getA() + bPointStartRange * aLine.getB();
Point3<float> secondPoint = (1.0f - bPointStartRange) * aNextLine.getA() + bPointStartRange * aNextLine.getB();
Point3<float> thirdPoint = (1.0f - bPointEndRange) * aNextLine.getA() + bPointEndRange * aNextLine.getB();
Point3<float> fourthPoint = (1.0f - bPointEndRange) * aLine.getA() + bPointEndRange * aLine.getB();
PlaneSurfaceSplit planeSurfaceSplit;
planeSurfaceSplit.planeSurfacePoints = {firstPoint, secondPoint, thirdPoint, fourthPoint};
planeSurfaceSplits.emplace_back(planeSurfaceSplit);
}
}
return planeSurfaceSplits;
}
}
| 56.854545 | 159 | 0.667093 | [
"vector"
] |
eb4cf58aa24c02ff9c6679729ce34d5fd9ceecc2 | 5,927 | cc | C++ | src/gameManager.cc | lysyjakk/neuralchess | d1e7b73580784026a4087b11d6939870dcf0f4e4 | [
"MIT"
] | null | null | null | src/gameManager.cc | lysyjakk/neuralchess | d1e7b73580784026a4087b11d6939870dcf0f4e4 | [
"MIT"
] | null | null | null | src/gameManager.cc | lysyjakk/neuralchess | d1e7b73580784026a4087b11d6939870dcf0f4e4 | [
"MIT"
] | null | null | null | #include "../inc/gameManager.hh"
#define COORD_TO_BIT_POS(x , y) (x * 8 + y)
void GameManager::start_new_game()
{
TRACE_INFO("Initialization new game...");
TRACE_INFO("Initialization bitboards...");
m_black_board.king = Bitboard(0x1000000000000000ULL);
m_black_board.queens = Bitboard(0x0800000000000000ULL);
m_black_board.rooks = Bitboard(0x8100000000000000ULL);
m_black_board.knights = Bitboard(0x4200000000000000ULL);
m_black_board.bishops = Bitboard(0x2400000000000000ULL);
m_black_board.pawns = Bitboard(0x00ff000000000000ULL);
m_white_board.king = Bitboard(0x0000000000000010ULL);
m_white_board.queens = Bitboard(0x0000000000000008ULL);
m_white_board.rooks = Bitboard(0x0000000000000081ULL);
m_white_board.knights = Bitboard(0x0000000000000042ULL);
m_white_board.bishops = Bitboard(0x0000000000000024ULL);
m_white_board.pawns = Bitboard(0x000000000000ff00ULL);
TRACE_INFO("Initialization bitboards done");
TRACE_INFO("Setting necessary moves varables...");
m_bot = NegaMax();
m_move_checker = MoveLookup();
m_move_checker.init();
m_player_turn = Site::WHITE;
m_special_moves.en_passant = ENPASS_NO_SQ;
m_special_moves.castle = BLACK_KING_SIDE | BLACK_QUEEN_SIDE |
WHITE_KING_SIDE | WHITE_QUEEN_SIDE;
m_special_moves.w_double_mv_pawn = Bitboard(Mask["FIELD_2"]);
m_special_moves.b_double_mv_pawn = Bitboard(Mask["FIELD_7"]);
//Clear GUI board
for (int itr = 0; itr < MAX_BOARD_SQ; ++itr)
{
m_pieces_pos[itr] = NONE;
}
__set_up_GUI_board(m_white_board, Site::WHITE);
__set_up_GUI_board(m_black_board, Site::BLACK);
TRACE_INFO("Setting necessary moves varables done");
TRACE_INFO("Initialization new game done");
return;
}
void GameManager::move_piece(uint8_t x_src,
uint8_t y_src,
uint8_t x_dest,
uint8_t y_dest)
{
std::size_t sq_src = COORD_TO_BIT_POS(y_src, x_src);
std::size_t sq_dest = COORD_TO_BIT_POS(y_dest, x_dest);
if (m_player_turn == Site::WHITE)
{
MoveToMake move;
move.sq_src = sq_src;
move.sq_dest = sq_dest;
move.piece_type = m_pieces_pos[sq_src];
move.site = Site::WHITE;
move.special_mv = m_special_moves;
if ( m_move_checker.is_move_valid(move, m_white_board, m_black_board) )
{
m_move_checker.make_move(&move, &m_white_board, &m_black_board);
m_special_moves = move.special_mv;
change_player_turn(m_player_turn);
//Clear GUI board
for (int itr = 0; itr < MAX_BOARD_SQ; ++itr)
{
m_pieces_pos[itr] = NONE;
}
__set_up_GUI_board(m_white_board, Site::WHITE);
__set_up_GUI_board(m_black_board, Site::BLACK);
}
}
else
{
MoveToMake move;
BestMove best_move;
best_move = m_bot.get_best_move(m_white_board,
m_black_board,
m_player_turn,
m_special_moves);
move.sq_src = std::get<0>(best_move);
move.sq_dest = std::get<1>(best_move);
move.piece_type = m_pieces_pos[std::get<0>(best_move)];
move.site = Site::BLACK;
move.special_mv = m_special_moves;
m_move_checker.make_move(&move, &m_black_board, &m_white_board);
m_special_moves = move.special_mv;
change_player_turn(m_player_turn);
//Clear GUI board
for (int itr = 0; itr < MAX_BOARD_SQ; ++itr)
{
m_pieces_pos[itr] = NONE;
}
__set_up_GUI_board(m_white_board, Site::WHITE);
__set_up_GUI_board(m_black_board, Site::BLACK);
}
return;
}
BitBoardToGUI GameManager::get_board() const
{
return m_pieces_pos;
}
void GameManager::__set_up_GUI_board(ChessBoard board, Site site)
{
//Set up all white pieces
int index = 1;
for (Bitboard* element = get_begin(&board);
element < get_end(&board);
++element)
{
switch (index)
{
case 1: //Pawn
{
std::vector< std::size_t > sq_vector = element -> scan_for_bit_index();
for (auto sq : sq_vector)
{
m_pieces_pos[sq] = site == Site::BLACK ? BLACK_PAWN
: WHITE_PAWN;
}
}
break;
case 2: //Rook
{
std::vector< std::size_t > sq_vector = element -> scan_for_bit_index();
for (auto sq : sq_vector)
{
m_pieces_pos[sq] = site == Site::BLACK ? BLACK_ROOK
: WHITE_ROOK;
}
}
break;
case 3: //Knight
{
std::vector< std::size_t > sq_vector = element -> scan_for_bit_index();
for (auto sq : sq_vector)
{
m_pieces_pos[sq] = site == Site::BLACK ? BLACK_KNIGHT
: WHITE_KNIGHT;
}
}
break;
case 4: //Bishop
{
std::vector< std::size_t > sq_vector = element -> scan_for_bit_index();
for (auto sq : sq_vector)
{
m_pieces_pos[sq] = site == Site::BLACK ? BLACK_BISHOP
: WHITE_BISHOP;
}
}
break;
case 5: //Queen
{
std::vector< std::size_t > sq_vector = element -> scan_for_bit_index();
for (auto sq : sq_vector)
{
m_pieces_pos[sq] = site == Site::BLACK ? BLACK_QUEEN
: WHITE_QUEEN;
}
}
break;
case 6: //King
{
std::vector< std::size_t > sq_vector = element -> scan_for_bit_index();
for (auto sq : sq_vector)
{
m_pieces_pos[sq] = site == Site::BLACK ? BLACK_KING
: WHITE_KING;
}
}
break;
default:
break;
}
++index;
}
} | 26.819005 | 79 | 0.586469 | [
"vector"
] |
eb4dfa4e1b41a9fda79d905b2796139f98a65196 | 39,935 | cpp | C++ | src/util/arg_main.cpp | maximeseguin/micmac | 34925011ecb3c63d65eaa7db1741430f71363f1d | [
"CECILL-B"
] | 451 | 2016-11-25T09:40:28.000Z | 2022-03-30T04:20:42.000Z | src/util/arg_main.cpp | maximeseguin/micmac | 34925011ecb3c63d65eaa7db1741430f71363f1d | [
"CECILL-B"
] | 143 | 2016-11-25T20:35:57.000Z | 2022-03-01T11:58:02.000Z | src/util/arg_main.cpp | maximeseguin/micmac | 34925011ecb3c63d65eaa7db1741430f71363f1d | [
"CECILL-B"
] | 139 | 2016-12-02T10:26:21.000Z | 2022-03-10T19:40:29.000Z | /*Header-MicMac-eLiSe-25/06/2007
MicMac : Multi Image Correspondances par Methodes Automatiques de Correlation
eLiSe : ELements of an Image Software Environnement
www.micmac.ign.fr
Copyright : Institut Geographique National
Author : Marc Pierrot Deseilligny
Contributors : Gregoire Maillet, Didier Boldo.
[1] M. Pierrot-Deseilligny, N. Paparoditis.
"A multiresolution and optimization-based image matching approach:
An application to surface reconstruction from SPOT5-HRS stereo imagery."
In IAPRS vol XXXVI-1/W41 in ISPRS Workshop On Topographic Mapping From Space
(With Special Emphasis on Small Satellites), Ankara, Turquie, 02-2006.
[2] M. Pierrot-Deseilligny, "MicMac, un lociel de mise en correspondance
d'images, adapte au contexte geograhique" to appears in
Bulletin d'information de l'Institut Geographique National, 2007.
Francais :
MicMac est un logiciel de mise en correspondance d'image adapte
au contexte de recherche en information geographique. Il s'appuie sur
la bibliotheque de manipulation d'image eLiSe. Il est distibue sous la
licences Cecill-B. Voir en bas de fichier et http://www.cecill.info.
English :
MicMac is an open source software specialized in image matching
for research in geographic information. MicMac is built on the
eLiSe image library. MicMac is governed by the "Cecill-B licence".
See below and http://www.cecill.info.
Header-MicMac-eLiSe-25/06/2007*/
#include "StdAfx.h"
#include <iterator>
//#include <process.h>
#if ElMemberTpl
#define SzBuf 2000
std::map<void *,std::string> MapValuesEAM;
std::set<void *> AllAddrEAM;
class cFileDebug
{
public :
~cFileDebug()
{
Close(0);
}
void Close(int aVal)
{
if (mFile)
{
fprintf(mFile," RES=%d\n",aVal);
fprintf(mFile,"End}\n");
fclose(mFile);
}
mFile = 0;
}
void Open(const std::string & aName)
{
// ELISE_ASSERT(mFile==0,"Multiple Open in File Debug");
if (mFile==0)
{
mFile = fopen(aName.c_str(),"a+");
fprintf(mFile,"{Begin\n");
}
}
FILE * File() {return mFile;}
static cFileDebug TheOne;
private :
cFileDebug() :
mFile (0)
{
}
FILE * mFile;
};
cFileDebug cFileDebug::TheOne;
FILE * TheFileDebug()
{
return cFileDebug::TheOne.File();
}
void OpenFileDebug(const std::string & aName)
{
cFileDebug::TheOne.Open(aName);
}
std::string TheStringMemoArgOptGlob = "";
static const int TheNbKeyACM=9;
int TheNbProcCom = -1;
std::string TheSpecMess="";
const char * TheKeyACM[TheNbKeyACM] ={"ExitOnBrkp","ExitOnNan","MajickFile","EnBoucle","NbMaxProc","SpecMessage","SFS","ExitOnWarn","GoonOnWarn"};
std::string TheGlobSFS="";
void AnalyseContextCom(int argc,char ** argv)
{
static bool First = true;
if (!First) return;
First = false;
for (int aK=0 ; aK<argc ; aK++)
{
if (argv[aK][0] == cInterfChantierNameManipulateur::theCharSymbOptGlob)
{
bool ForAction = false;
std::string ArgK = argv[aK]+1;
std::string aBeforEq,aAfterEq;
SplitIn2ArroundCar(ArgK,'=', aBeforEq,aAfterEq,true);
if (ArgK ==TheKeyACM[0])
{
TheExitOnBrkp = true;
ForAction = true;
}
else if (ArgK==TheKeyACM[1])
{
TheExitOnNan = true;
ForAction = true;
}
else if (ArgK==TheKeyACM[2])
{
TheMajickFile=true;
ForAction = true;
}
else if (ArgK==TheKeyACM[3])
{
TheNbIterProcess=100000000;
ForAction = true;
}
else if (aBeforEq==TheKeyACM[4])
{
bool Ok=FromString(TheNbProcCom,aAfterEq);
ELISE_ASSERT(Ok,"Cannot read value in @NbProc");
ForAction = true;
}
else if (aBeforEq==TheKeyACM[5])
{
TheSpecMess= aAfterEq;
ForAction = true;
}
else if (aBeforEq==TheKeyACM[6])
{
TheGlobSFS= argv[aK];
ForAction = true;
}
else if (aBeforEq==TheKeyACM[7])
{
TheExitOnWarn = true;
ForAction = true;
}
else if (aBeforEq==TheKeyACM[8])
{
TheGoonOnWarn = true;
ForAction = true;
}
/*
*/
if (ForAction)
{
TheStringMemoArgOptGlob += " " + std::string(argv[aK]);
}
else
{
std::cout << " Warning, unknown special arg " << argv[aK] << "\n";
for (int aK=0 ; aK< TheNbKeyACM ; aK++)
std::cout << " Opt[" << aK << "]= "<< cInterfChantierNameManipulateur::theCharSymbOptGlob << TheKeyACM[aK] << "\n";
}
}
}
}
static char buf[SzBuf];
std::list<std::string> TheEmptyListEnum;
bool MMVisualMode = false;
std::string MakeStrFromArgcARgvWithSubst(int argc,char** argv,int aKSubst,std::string aSubst, bool aProtect,bool StrongProtect)
{
if (aProtect) aSubst = PATTERN_QUOTE(aSubst);
std::string aRes;
for (int aK=0 ; aK<argc ; aK++)
{
if (aK == aKSubst)
aRes = aRes + aSubst + " ";
else
{
const string str(argv[aK]);
aRes = aRes + (aProtect ? (StrongProtect ? QUOTE(str) : PATTERN_QUOTE(str)) : str) + " ";
}
}
return aRes;
}
std::string MakeStrFromArgcARgvWithSubst(int argc,char** argv,int aKSubst,std::string aSubst, bool aProtect)
{
return MakeStrFromArgcARgvWithSubst(argc,argv,aKSubst,aSubst,aProtect,true);
}
std::string MakeStrFromArgcARgv( int argc,char **argv, bool aProtect )
{
return MakeStrFromArgcARgvWithSubst(argc, argv, -1, "", aProtect);
}
std::string SubstArgcArvGlob(int aKSubst,std::string aSubst, bool aProtect)
{
return MakeStrFromArgcARgvWithSubst(MemoArgc, MemoArgv, aKSubst, aSubst, aProtect);
}
int MemoArgc=-1;
char ** MemoArgv=0;
std::string GlobArcArgv;
static std::vector<std::string> GlobMessErrContext;
void AddMessErrContext(const std::string & aMes)
{
GlobMessErrContext.push_back(aMes);
}
int mm_getpid()
{
#if ELISE_windows
return _getpid();
#else
return getpid();
#endif
}
const std::string & mm_getstrpid()
{
static std::string aRes = ToString(mm_getpid());
return aRes;
}
void MemoArg(int argc,char** argv)
{
AnalyseContextCom(argc,argv);
static bool First = true;
if (! First) return;
First = false;
MMD_InitArgcArgv(argc,argv);
MemoArgc = argc;
MemoArgv = argv;
// GlobArcArgv = MakeStrFromArgcARgv(argc,argv,true);
// MODIF MPD car sinon les pattern reconnu par le shell ne sont pas quote
GlobArcArgv = MakeStrFromArgcARgvWithSubst(argc, argv, -1, "", true,true);
}
void ShowArgs()
{
static bool Done=false;
if (MemoArgv && (!Done))
{
Done=true;
std::cout << "ARG MAIN RECEIVED \n";
for (int aK=0 ; aK< MemoArgc ; aK++)
std::cout << " " << MemoArgv[aK] << "\n";
std::cout << "\n";
}
}
std::istream & VStrElStdRead
(
std::istream &is,
ElSTDNS vector<std::string> & vec,
const ElGramArgMain & Gram
)
{
vec.clear();
if (Gram.mCharBeginTab != -1)
{
if (is.get() != Gram.mCharBeginTab)
{
ELISE_ASSERT(false,"istream >> vector<Type>");
}
}
int c;
vec.push_back("");
while ((c = is.get()) != Gram.mCharEndTab)
{
ELISE_ASSERT (c!=-1,"Unexpected End Of String in ElStdRead(vector<Type> &)");
if (c==',')
vec.push_back("");
else
vec.back() += (char) c;
}
ELISE_ASSERT (is.get()==-1,"Expected End Of String param vector (did you forget a space between two parameters?)");
if ((vec.size()==1) && (vec[0]==""))
vec.pop_back();
return is;
}
ElGramArgMain::ElGramArgMain(char CharEq,int CharBeginTab,char CharEndTab,bool aAnyEqual) :
mCharEq (CharEq),
mCharBeginTab (CharBeginTab),
mCharEndTab (CharEndTab),
mAnyEqual (aAnyEqual)
{
}
bool ElGramArgMain::AnyEqual() const
{
return mAnyEqual;
}
const ElGramArgMain ElGramArgMain::SPHGram(' ',-1,'\n',false);
const ElGramArgMain ElGramArgMain::THOMGram('=',-1,'\n',false);
const ElGramArgMain ElGramArgMain::HDRGram(' ',-1,'\n',true);
const ElGramArgMain ElGramArgMain::StdGram('=','[',']',false);
istream & operator >> (istream & is,ElSTDNS string & st)
{
is >> buf;
st = ElSTDNS string(buf);
return is;
}
template <class Type> std::istream & operator >>
(std::istream &is,ElSTDNS vector<Type> & vec)
{
return ElStdRead(is,vec,ElGramArgMain::StdGram);
}
template std::istream & operator >> (std::istream &is,ElSTDNS vector<INT> & vec);
#define DEFINE_theEmptyLvalADM(Type,Name)\
template <> const ElSTDNS list<Type > ElArgMain<Type >::theEmptyLvalADM;\
template <> const char * str_type(Type *) { return Name; }
DEFINE_theEmptyLvalADM(Box2di,"Box2di");
DEFINE_theEmptyLvalADM(Box2dr,"Box2dr");
DEFINE_theEmptyLvalADM(bool,"bool");
DEFINE_theEmptyLvalADM(INT,"INT");
DEFINE_theEmptyLvalADM(REAL,"REAL");
DEFINE_theEmptyLvalADM(Pt2di,"Pt2di");
DEFINE_theEmptyLvalADM(Pt2dr,"Pt2dr");
DEFINE_theEmptyLvalADM(Pt3dr,"Pt3dr");
DEFINE_theEmptyLvalADM(Pt3di,"Pt3di");
DEFINE_theEmptyLvalADM(ElSTDNS string,"string");
DEFINE_theEmptyLvalADM(U_INT1,"u_int1");
DEFINE_theEmptyLvalADM(INT1,"int1");
DEFINE_theEmptyLvalADM(char,"char");
DEFINE_theEmptyLvalADM(ElSTDNS vector<Pt2dr>,"vector<Pt2dr>");
DEFINE_theEmptyLvalADM(ElSTDNS vector<int>,"vector<int>");
DEFINE_theEmptyLvalADM(ElSTDNS vector<double>,"vector<double>");
DEFINE_theEmptyLvalADM(ElSTDNS vector < ElSTDNS vector < int > >,"vector<vector<int> >");
DEFINE_theEmptyLvalADM(ElSTDNS vector<std::string>,"vector<std::string>");
template <> eArgMainBaseType ElArgMain<Box2di>::type() const { return AMBT_Box2di; }
template <> eArgMainBaseType ElArgMain<Box2dr>::type() const { return AMBT_Box2dr; }
template <> eArgMainBaseType ElArgMain<bool>::type() const { return AMBT_bool; }
template <> eArgMainBaseType ElArgMain<INT>::type() const { return AMBT_INT; }
template <> eArgMainBaseType ElArgMain<REAL>::type() const { return AMBT_REAL; }
template <> eArgMainBaseType ElArgMain<Pt2di>::type() const { return AMBT_Pt2di; }
template <> eArgMainBaseType ElArgMain<Pt2dr>::type() const { return AMBT_Pt2dr; }
template <> eArgMainBaseType ElArgMain<Pt3dr>::type() const { return AMBT_Pt3dr; }
template <> eArgMainBaseType ElArgMain<Pt3di>::type() const { return AMBT_Pt3di; }
template <> eArgMainBaseType ElArgMain<string>::type() const { return AMBT_string; }
template <> eArgMainBaseType ElArgMain<U_INT1>::type() const { return AMBT_U_INT1; }
template <> eArgMainBaseType ElArgMain<INT1>::type() const { return AMBT_INT1; }
template <> eArgMainBaseType ElArgMain<char>::type() const { return AMBT_char; }
template <> eArgMainBaseType ElArgMain<vector<Pt2dr> >::type() const { return AMBT_vector_Pt2dr; }
template <> eArgMainBaseType ElArgMain<vector<int> >::type() const { return AMBT_vector_int; }
template <> eArgMainBaseType ElArgMain<vector<double> >::type() const { return AMBT_vector_double; }
template <> eArgMainBaseType ElArgMain<vector<vector<int> > >::type() const { return AMBT_vvector_int; }
template <> eArgMainBaseType ElArgMain<vector<std::string> >::type() const { return AMBT_vector_string; }
std::vector<cMMSpecArg> LArgMain::ExportMMSpec(bool isOpt) const
{
std::vector<cMMSpecArg> aRes;
int aNum=0;
for (std::list<GenElArgMain*>::const_iterator itA=_larg.begin(); itA!=_larg.end() ; itA++, aNum++)
{
aRes.push_back(cMMSpecArg(*itA,aNum,isOpt));
}
return aRes;
}
INT LArgMain::Init
(
int argc,
char ** argv
) const
{
if (argc<(INT)_larg.size())
{
std::ostringstream oss0, oss1;
oss0 << argc;
oss1 << (INT)_larg.size();
Tjs_El_User.ElAssert
(
argc>=(INT)_larg.size(),
EEM0 << "Not enough Arg in LArgMain::Init"
<< " Got : " << oss0.str().c_str() << " expecting " << oss1.str().c_str()
);
}
INT k=0;
for
(
ElSTDNS list<GenElArgMain *>::const_iterator it = _larg.begin();
it != _larg.end();
it++
)
{
MapValuesEAM[(*it)->AddrArg()] = argv[k];
(*it)->InitEAM(argv[k],ElGramArgMain::StdGram);
k++;
}
return k;
}
int LArgMain::Size() const {return (int)_larg.size();}
bool LArgMain::OneInitIfMatchEq
(
char * s,
const ElGramArgMain & Gram,
bool anAcceptUnknown
) const
{
for
(
ElSTDNS list<GenElArgMain *>::const_iterator it = _larg.begin();
it != _larg.end();
it++
)
if ((*it)->InitIfMatchEq(s,Gram))
return true;
if (anAcceptUnknown || s[0]=='+' || s[0]==cInterfChantierNameManipulateur::theCharSymbOptGlob)
return false;
Tjs_El_User.ElAssert
(
false,
EEM0 << "LArgMain , Don't understand :["
<< s <<"]"
);
return false;
}
void LArgMain::InitIfMatchEq
(
std::vector<char *> * aRes,
int argc,
char ** argv,
const ElGramArgMain & Gram,
bool VerifInit,
bool AccUnK
) const
{
for (INT k=0; k<argc ; k++)
{
if ( (! OneInitIfMatchEq(argv[k],Gram,AccUnK)) && (aRes!=0))
aRes->push_back(argv[k]);
}
// if (VerifInit)
//VerifInitialize();
}
void LArgMain::VerifInitialize() const
{
for
(
ElSTDNS list<GenElArgMain *>::const_iterator it = _larg.begin();
it != _larg.end();
it++
)
{
Tjs_El_User.ElAssert
(
(*it)->IsInit(),
EEM0 << "LArgMain, unitialized var :" << (*it)->name()
);
}
}
LArgMain::LArgMain() {}
void LArgMain::show(bool isNamed) const
{
for
(
ElSTDNS list<GenElArgMain *>::const_iterator it = _larg.begin();
it!= _larg.end();
it++
)
(*it)->show(isNamed);
}
LArgMain::~LArgMain()
{
for
(
ElSTDNS list<GenElArgMain *>::iterator it = _larg.begin();
it!= _larg.end();
it++
)
delete (*it);
}
LArgMain & LArgMain::operator << (const LArgMain & v)
{
for (list<GenElArgMain *>::const_iterator it=v._larg.begin() ; it!=v._larg.end() ; it++)
_larg.push_back((*it)->dup());
return *this;
}
std::list<std::string> ModifListe(const std::list<std::string> & aList,const char * aNameType)
{
if (std::string(aNameType)==std::string("bool"))
{
std::list<std::string> aL;
aL.push_back("true");
aL.push_back("false");
return aL;
}
return aList;
}
GenElArgMain::GenElArgMain(const char * Name,bool IsInit,eSpecArgMain aSpec,const std::list<std::string> & aLEnumVal) :
_name (Name),
_is_init (IsInit),
mSpec (aSpec),
mLEnum (aLEnumVal)
{
}
eSpecArgMain GenElArgMain::Spec() const
{
return mSpec;
}
const std::list<std::string> & GenElArgMain::ListEnum() const
{
return mLEnum;
}
bool GenElArgMain::IsActif() const
{
return _name!=theChaineInactif;
}
const char * GenElArgMain::ActifStr(bool isAct)
{
return isAct ? theChaineActif.c_str() : theChaineInactif.c_str();
}
const std::string GenElArgMain::theChaineInactif = "#%$(|[])??";
const std::string GenElArgMain::theChaineActif="OK";
bool GenElArgMain::InitIfMatchEq(const ElSTDNS string &s,const ElGramArgMain & Gram) const
{
const char * N = _name.c_str();
const char * EQ = s.c_str();
// std::cout << "HHHHHHHH " << EQ << " " << AddrArg() << "\n";
while ((*N==* EQ) && *N )
{
N++;
EQ++;
}
if (*N==0 && (*EQ == Gram.mCharEq))
{
if (Gram.AnyEqual())
{
while(EQ[1] == Gram.mCharEq)
EQ++;
}
InitEAM(ElSTDNS string(EQ+1),Gram);
MapValuesEAM[AddrArg()] = s;
return true;
}
return false;
}
bool GenElArgMain::IsInit() const
{
return _is_init;
}
const char * GenElArgMain::name() const
{
return _name.c_str();
}
// typedef void (*tActionOnHelp)(int argc,char ** argv);
void DefActionOnHelp(int argc,char ** argv)
{
}
tActionOnHelp TheActionOnHelp = DefActionOnHelp;
std::vector<char *> ElInitArgMain
(
int argc,char ** argv,
const LArgMain & LGlob,
const LArgMain & L1,
const std::string & aFirstArg,
bool VerifInit,
bool AccUnK,
int aNbArgGlobGlob
)
{
setlocale(LC_ALL,"C");
MMD_InitArgcArgv( argc,argv);
std::vector<char *> aRes;
if (MMVisualMode)
{
if(argc > 1)
{
MMVisualMode = false;
ElInitArgMain(argc,argv,LGlob,L1,aFirstArg,VerifInit,AccUnK,aNbArgGlobGlob);
MMVisualMode = true;
}
std::vector<cMMSpecArg> aVAM = LGlob.ExportMMSpec();
std::vector<cMMSpecArg> aVAO = L1.ExportMMSpec(true);
MMRunVisualMode(argc,argv,aVAM,aVAO,aFirstArg);
return aRes;
}
setlocale(LC_ALL,"C");
aRes.push_back(argv[0]);
argc--;
argv++;
bool Help = false;
AnalyseContextCom(argc,argv);
//std::cout << "ARGCCCC " << argc << " " << LGlob.Size() << endl;
if ((argc==0) && ( LGlob.Size() !=0)) Help = true;
for (int aK=0 ; aK<argc ; aK++)
{
if (std::string(argv[aK])=="-help")
{
Help = true;
}
}
// if ((argc >=1) && (ElSTDNS string(argv[0]) == "-help"))
if (Help)
{
TheActionOnHelp(argc,argv);
cout << "*****************************\n";
cout << "* Help for Elise Arg main *\n";
cout << "*****************************\n";
cout << "Mandatory unnamed args : \n";
LGlob.show(false);
cout << "Named args : \n";
L1.show(true);
StdEXIT(-1);
}
INT k = LGlob.Init(argc,argv);
if (aNbArgGlobGlob !=-1)
{
ELISE_ASSERT(k<=aNbArgGlobGlob," ElInitArgMain ArgGlob");
ELISE_ASSERT(aNbArgGlobGlob<=argc," Nb Arg Glob Pas assez important");
for(;k<aNbArgGlobGlob ; k++)
aRes.push_back(argv[k]);
}
L1.InitIfMatchEq(&aRes,argc-k,argv+k,ElGramArgMain::StdGram,VerifInit,AccUnK);
setlocale(LC_ALL,"C");
return aRes;
}
void ElInitArgMain
(
const std::string & aNameI,
const LArgMain & LGlob,
const LArgMain & L1,
const std::string & aFirstArg
)
{
static std::vector<char *> VNames;
VNames.clear();
static std::vector<char> aName;
aName.clear();
static std::string aBid = "Bid ";
std::copy(aBid.begin(),aBid.end(),std::back_inserter(aName));
std::copy(aNameI.begin(),aNameI.end(),std::back_inserter(aName));
aName.push_back(0);
char * pC = &aName[0];
bool LastVide = true;
for (char * Cur = pC+1; *Cur ; Cur++)
{
if ((*Cur==' ')&&(Cur[-1]!= 0)&&(Cur[-1]!=' '))
{
*Cur = 0;
VNames.push_back(pC);
pC = Cur+1;
LastVide = true;
}
else if (*Cur !=' ')
LastVide = false;
}
if (! LastVide)
VNames.push_back(pC);
ElInitArgMain((int) VNames.size(),&(VNames[0]),LGlob,L1, aFirstArg);
}
INT GenFileInitArgs
(
const ElGramArgMain & aGram,
INT aCarCommentaire,
INT FirstLineUsed,
INT FirstCarInLine,
const ElSTDNS string & NameFile,
const LArgMain & L1 ,
INT StopCar,
bool anAcceptUnknown
)
{
FILE * fp = ElFopen(NameFile.c_str(),"r");
if (fp==0)
{
cout << "CANT OPEN" << NameFile << "\n";
ELISE_ASSERT(fp!=0,"SphInitArgs, cannot open FILE");
}
INT aLine = 0;
bool cont = true;
size_t buflen=0;
while (cont && fgets(buf,SzBuf,fp))
{
buflen = strlen(buf); //remove all endline chars
while ( (buflen>0) && ((buf[buflen-1]=='\r')||(buf[buflen-1]=='\n')) )
{
buf[buflen-1]= '\0';
buflen--;
}
if (*buf == StopCar)
cont = false;
else
{
if (*buf != aCarCommentaire)
{
if (aLine >= FirstLineUsed)
{
for (char * c=buf; *c ; c++)
if(*c== '\t') *c=' ';
L1.OneInitIfMatchEq(buf+FirstCarInLine,aGram,anAcceptUnknown);
}
}
aLine++;
}
}
//L1.VerifInitialize();
INT res = ftell(fp);
ElFclose(fp);
return res;
}
void SphInitArgs
(
const ElSTDNS string & NameFile,
const LArgMain & L1
)
{
GenFileInitArgs
(
ElGramArgMain::SPHGram,
-1,
0,
0,
NameFile,
L1,
EOF,
false
);
}
void StdInitArgsFromFile
(
const ElSTDNS string & NameFile,
const LArgMain & L1
)
{
GenFileInitArgs
(
ElGramArgMain::StdGram,
'#',
0,
0,
NameFile,
L1,
EOF,
false
);
}
void HdrInitArgsFromFile
(
const ElSTDNS string & NameFile,
const LArgMain & L1
)
{
GenFileInitArgs
(
ElGramArgMain::HDRGram,
'!', // aCarCommentaire
0, // FirstLineUsed
0, // FirstCarInLine
NameFile, // NameFile
L1, // LArgMain L1
EOF, // StopCar
true
);
}
INT ThomInitArgs
(
const ElSTDNS string & NameFile,
const LArgMain & L1
)
{
return GenFileInitArgs
(
ElGramArgMain::THOMGram,
'C',//-1,
1,
2,
NameFile,
L1,
'*',
// false
true // Maintenant on accepte et ignore les tag thom inconnus
);
}
bool IsThomFile (const std::string & aName)
{
FILE * fp = ElFopen(aName.c_str(),"r");
if (! fp)
return false;
char * astr = fgets(buf,SzBuf,fp);
if (! astr)
{
ElFclose(fp);
return false;
}
bool res = (strcmp(buf,"C ENTETE\n")==0);
ElFclose(fp);
return res;
}
#endif
std::string StrFromArgMain(const std::string & aStr)
{
int aL = (int)aStr.length();
aL--;
while ((aL>=0) && isspace(aStr.at(aL)))
aL--;
if (aStr.at(aL)) aL++;
std::string aRes = aStr.substr(0,aL);
// std::cout << "[" <<aStr <<"]->[" << aRes << "]\n";
return aRes;
}
/*******************************************************/
/* */
/* cAppliBatch */
/* */
/*******************************************************/
int TopSystem(const std::string & aCom)
{
return ::System(aCom,false,true,true);
}
int System(const std::string & aComOri,bool aSVP,bool AddOptGlob,bool UseTheNbIterProcess)
{
std::string aCom = aComOri;
int aNbIter = UseTheNbIterProcess ? TheNbIterProcess : 1;
if (aNbIter > 1) aSVP = true;
// Pour que les args de contextes soient automatiquement passes aux process fils
if (AddOptGlob)
{
aCom += TheStringMemoArgOptGlob ;
}
// std::cout << "Sys:"<< aCom << "\n";
int aRes = 0;
for (int aKIter = 0 ; aKIter < aNbIter ; aKIter++)
{
if (aKIter>0) SleepProcess(1); // Pour pouvoir plus facilement arreter par ^C
#if (ELISE_windows)
if ( aCom.size()!=0 && aCom[0]=='\"' )
aRes = system_call( ( string("\"")+aCom+"\"" ).c_str() );
else
aRes = system_call( aCom.c_str() );
#else
// std::cout << "SYS " << __FILE__ << __LINE__ << " " << aCom << "\n";
#ifdef __TRACE_SYSTEM__
aRes = system_call(aCom.c_str());
#else
aRes = system(aCom.c_str());
#endif
// std::cout << "SYS " << __FILE__ << __LINE__ << " " << aRes << " " << aCom << "\n";
#endif
if ((aRes != 0) && (!aSVP))
{
// Modif MPD : sur de gros chantier avec un max de MicMac en paral, il faut savoir quelle commande a plante
// sans avoir a inspecter un terminal sature
/*
std::string aFileName = Dir2Write() + GetUnikId() + ".txt";
FILE * aFP = fopen(aFileName.c_str(),"a+");
if (aFP)
{
fprintf(aFP,"Failed in command\n");
fprintf(aFP,"%s\n",aCom.c_str());
fprintf(aFP,"PID=%d\n",getpid());
fclose(aFP);
}
*/
std::cout << "FAIL IN : \n";
std::cout << aCom << "\n";
ElEXIT(-1,(std::string("System-call :") + aCom));
}
}
return aRes;
}
#ifndef __GNUC__
void ElExit(int aLine,const char * aFile,int aCode,const std::string & aMessage)
#else
void __attribute__((weak)) ElExit(int aLine,const char * aFile,int aCode,const std::string & aMessage)
#endif
{
cFileDebug::TheOne.Close(aCode);
if (aCode==0)
StdEXIT(0);
std::string aFileName = ( isUsingSeparateDirectories() ?
MMTemporaryDirectory() + "MM-Error-"+ GetUnikId() + ".txt" :
Dir2Write() + "MM-Error-"+ GetUnikId() + ".txt" );
FILE * aFP = fopen(aFileName.c_str(),"a+");
if (aFP)
{
fprintf(aFP,"Exit with code %d \n",aCode);
fprintf(aFP,"Generated from line %d of file %s \n",aLine,aFile);
fprintf(aFP,"PID=%d\n",mm_getpid());
if (aMessage!="")
fprintf(aFP,"Context=[%s]\n",aMessage.c_str());
for (int aK=0 ; aK<(int)GlobMessErrContext.size() ; aK++)
fprintf(aFP,"GMEC:%s\n",GlobMessErrContext[aK].c_str()),
fprintf(aFP,"MM3D-Command=[%s]\n",GlobArcArgv.c_str());
}
// std::cout << "ELExit " << __FILE__ << __LINE__ << " " << aCode << " " << GlobArcArgv << "\n";
StdEXIT(aCode);
}
int cAppliBatch::System(const char * aFile,const std::string & aCom,bool aSVP)
{
if ((aFile!=0) && ByMKf() && (!mIsRelancedByThis))
{
mGPAO.GetOrCreate(aFile,aCom);
return 0;
}
std::cout << aCom << "\n";
if (mModeExe== eExeDoNothing)
{
return 0;
}
else if ((mModeExe== eExeDoSys) || (mModeExe==eExeDoIfFileDontExist))
{
if (
(mModeExe==eExeDoIfFileDontExist)
&& (aFile!=0)
&& (ELISE_fp::exist_file(aFile))
)
{
return 0;
}
return ::System(aCom,aSVP);
}
else
{
ELISE_ASSERT(false,"Mode Exe non suporte");
return -1;
}
return -1;
}
int cAppliBatch::System(const std::string & aCom,bool aSVP)
{
return System((char*)0,aCom,aSVP);
}
void cAppliBatch::AddPatSauv(const std::string & aPat)
{
mPatSauv.push_back(aPat);
}
void cAppliBatch::DoPurge()
{
// std::cout << mNivPurge << " " << eNoPurge << " " << ePurgeTmp << "\n" ;
if (mPostFixWorkDir=="")
return;
if (mNivPurge==eNoPurge)
return;
if (mNivPurge == ePurgeTmp)
{
ELISE_fp::MkDir(mDirSauv);
for (int aK=0 ; aK<int(mPatSauv.size()) ; aK++)
{
std::string aCom = std::string(SYS_MV)+' '
+ mDirTmp+mPatSauv[aK] + std::string(" ")
+ mDirSauv;
System(aCom,true);
}
}
ELISE_fp::PurgeDir( mDirTmp );
}
std::string cAppliBatch::ComCommune() const
{
std::string aRes = std::string(" @WorkDir=") + mDirChantier
+ std::string(" ") + mArgAdd + std::string(" ");
if (mNbFile >= 1)
aRes = aRes + std::string(" @Im1=") + mCurF1;
if (mNbFile >= 2)
aRes = aRes + std::string(" @Im2=") + mCurF2;
return aRes;
}
const std::string & cAppliBatch::CurF1() const {return mCurF1;}
const std::string & cAppliBatch::CurF2() const {return mCurF2;}
cInterfChantierNameManipulateur * cAppliBatch::ICNM() {return mICNM;}
cInterfChantierNameManipulateur * cAppliBatch::ICNM() const {return mICNM;}
const std::string & cAppliBatch::DirChantier() const {return mDirChantier;}
const std::string & cAppliBatch::DirTmp() const {return mDirTmp;}
const std::string & cAppliBatch::DirSauv() const {return mDirSauv;}
const std::string & cAppliBatch::CurF(int aK) const
{
ELISE_ASSERT((aK>=0)&&(aK<mNbFile),"cAppliBatch::CurF");
if (aK==0) return mCurF1;
if (aK==1) return mCurF2;
ELISE_ASSERT(false,"cAppliBatch::CurF");
return mCurF1;
}
void cAppliBatch::UseLFile(const std::list<string> & aLFile1)
{
for
(
std::list<std::string>::const_iterator itF1 = aLFile1.begin() ;
itF1 != aLFile1.end() ;
itF1++
)
{
mCurF1 = *itF1;
if (mFileByPat && (mNbFile==2))
{
mCurF2 = mICNM->Assoc1To1(mPatF2,mCurF1,true);
}
DoOne();
}
}
void cAppliBatch::DoAll()
{
ELISE_ASSERT
(
mNbFile<3,
"cAppliBatch::DoAll() En Mode Pat, Multiple file non traite "
);
if (mByNameFile)
{
std::cout << "BY FILE \n";
mCurF1 = mPatF1;
if (mNbFile>=2)
mCurF2 = mPatF2;
DoOne();
return;
}
if (mFileByPat)
{
std::cout << "BY PATTERN \n";
if (mNbFile==2)
{
UseLFile(mListFile1ByPat);
/*
std::cout << "PatF2=" <<mPatF2 << "\n";
ELISE_ASSERT
(
false,
"cAppliBatch::DoAll() En Mode Pat, Multiple file non traite "
);
*/
}
else if(mNbFile==1)
{
UseLFile(mListFile1ByPat);
}
return;
}
std::cout << "BY DICO \n";
if (mNbFile==1)
{
UseLFile(mICNM->StdGetListOfFile(mPatF1));
return;
}
if (mNbFile==2)
{
const std::vector<cCpleString> * aVC = mICNM->GetRel(mPatF1);
for (int aK=0 ; aK<int(aVC->size()) ; aK++)
{
int aKC = (mReverse ? int(aVC->size()) - 1 - aK : aK);
mCurF1 = (*aVC)[aKC].N1();
mCurF2 = (*aVC)[aKC].N2();
DoOne();
}
}
}
bool cAppliBatch::NivPurgeIsInit()
{
return mNivPurgeIsInit;
}
void cAppliBatch::SetNivPurge(eNivPurge aNiv)
{
mNivPurge = aNiv;
}
bool cAppliBatch::NivExeIsInit()
{
return mExeIsInit;
}
void cAppliBatch::SetNivExe(eModeExecution aMode)
{
mModeExe = aMode;
}
cAppliBatch::eModeExecution cAppliBatch::ModeExe() const
{
return mModeExe;
}
std::string cAppliBatch::protectFilename( const string &i_filename ) const
{
return (ByMKf()?protect_spaces(i_filename):string("\"")+i_filename+"\"");
}
std::string cAppliBatch::ComForRelance()
{
std::string aRes = mDebCom;
if (mNbFile>=1)
aRes = aRes + " " + protectFilename( mCurF1 );
if (mNbFile>=2)
aRes = aRes + " " + protectFilename( mCurF2 );
aRes = aRes + mEndCom + " IsRelancedByThis=1";
return aRes;
}
void cAppliBatch::DoOne()
{
mVCurF.clear();
if (mNbFile>=1)
mVCurF.push_back(mCurF1);
if (mNbFile>=2)
mVCurF.push_back(mCurF2);
if (mDOIDE)
{
if (mNbFile==2)
{
std::string aNF = mDirChantier
+ mICNM->Assoc1ToN(mKeyDOIDE,mVCurF,true);
if(ELISE_fp::exist_file(aNF))
{
return;
}
}
}
Exec();
DoPurge();
if (! ByMKf())
{
std::cout << "\n";
std::cout << " -----------------------------\n";
std::cout << "\n";
}
}
cEl_GPAO & cAppliBatch::GPAO ()
{
return mGPAO;
}
bool cAppliBatch::ByMKf() const
{
return mMKf != "";
}
const std::string & cAppliBatch::MKf() const
{
ELISE_ASSERT(ByMKf(),"cAppliBatch::MKf");
return mMKf;
}
bool cAppliBatch::IsRelancedByThis() const
{
return mIsRelancedByThis != 0;
}
int cAppliBatch::ARGC()
{
return (int)mArgsNC.size();
}
char ** cAppliBatch::ARGV()
{
return &(mArgsNC[0]);
}
cAppliBatch::~cAppliBatch()
{
if (ByMKf() && (!mIsRelancedByThis))
{
mGPAO.GenerateMakeFile(mMKf,mModeAddMkf);
}
}
cAppliBatch::cAppliBatch
(
int argc,
char ** argv,
int aNbArgGlob,
int aNbFile,
const std::string & aPostFixWorkDir,
const std::string & aKeyDOIDE,
bool aForceDico
) :
mICNM (0),
mPostFixWorkDir (aPostFixWorkDir),
mNbFile (aNbFile),
mByNameFile (false),
mFileByPat (false),
mByDico (false),
mReverse (0),
mDOIDE (0),
mKeyDOIDE (aKeyDOIDE),
mMKf (""),
mModeAddMkf (false),
mIsRelancedByThis (0)
{
bool A1IsFile=false;
MMD_InitArgcArgv( argc, argv );
if ((argc >2) && (aNbFile>0))
{
if ( ELISE_fp::exist_file(argv[1]))
{
A1IsFile = true;
mByNameFile = true;
ELISE_ASSERT(aNbFile==1," cAppliBatch::cAppliBatch Incoherenc");
}
else
{
// check last caracter of argv[1] (which is chantier directory at this point)
// if it's not a '\' or '/', we need to add one before concatenation with argv[2]
char lastChar = argv[1][strlen(argv[1])-1];
if ( (lastChar!='\\') && (lastChar!='/') )
{
if ( lastChar==' ' )
// it may append that 'make' replaces an ending '\' by a ' '
argv[1][strlen(argv[1])-1] = ELISE_CAR_DIR;
else
{
string newArg1 = std::string( argv[1] ).append(1, ELISE_CAR_DIR);
// we don't 'delete []' argv[1] for we didn't 'new' it, it would cause some desallocation problems
// TODO: we should use a better solution later
argv[1] = new char[newArg1.length()+1];
strcpy( argv[1], newArg1.c_str() );
}
}
if ( ELISE_fp::exist_file(std::string(argv[1])+std::string(argv[2])))
{
mByNameFile = true;
}
else
{
std::string aST2(argv[2]);
if (aForceDico || aST2.find("[[")!=std::string::npos)
{
mByDico = true;
}
else
{
mListFile1ByPat = RegexListFileMatch
(
std::string(argv[1]),
std::string(argv[2]),
1,
false
);
if ( mListFile1ByPat.empty())
{
mByDico = true;
}
else
{
mFileByPat = true;
}
}
}
}
}
if (mByDico && (aNbFile==2))
aNbArgGlob--;
int aExe = -1;
int aNivPurge = -1;
std::string aICNM="";
mPatF2="";
mArgsNC = ElInitArgMain
(
argc,argv,
LArgMain() << EAM(mDirChantier)
<< EAM(mPatF1,GenElArgMain::ActifStr((aNbFile>=1) && (!A1IsFile)))
<< EAM(mPatF2,GenElArgMain::ActifStr((!mByDico) && (aNbFile>=2))),
LArgMain() << EAM(aExe,"Exe",true)
<< EAM(aICNM,"IC",true)
<< EAM(aNivPurge,"Purge",true)
<< EAM(mArgAdd,"Add",true)
<< EAM(mReverse,"Rev",true)
<< EAM(mDOIDE,"DOIDE",true)
<< EAM(mMKf,"MkF",true)
<< EAM(mModeAddMkf,"MkAdd",true)
<< EAM(mIsRelancedByThis,"IsRelancedByThis",true),
"",
true,
true,
aNbArgGlob
);
setInputDirectory( mDirChantier );
#if (ELISE_windows)
replace( mDirChantier.begin(), mDirChantier.end(),'\\', '/' );
#endif
if (!mByNameFile)
MakeFileDirCompl(mDirChantier);
if (A1IsFile)
{
// retrieve chantier directory from first file's path
std::string aFulName = mDirChantier;
SplitDirAndFile(mDirChantier,mPatF1,aFulName);
}
mDebCom = protectFilename(current_program_fullname())+" "+current_program_subcommand()+" "+protectFilename(mDirChantier)+" ";
mEndCom = "";
for (int aK=3+(mPatF2!="") ; aK<argc ; aK++)
mEndCom = mEndCom + " " + protectFilename(argv[aK]);
mExeIsInit = (aExe!=-1);
mModeExe = mExeIsInit ? (eModeExecution) aExe :eExeDoNothing;
mNivPurgeIsInit = (aNivPurge !=-1);
if (! mNivPurgeIsInit)
{
if (mByNameFile)
mNivPurge = eNoPurge;
else
mNivPurge = ePurgeTmp;
}
else
{
mNivPurge = (eNivPurge) aNivPurge;
}
//std::cout << "DIIIRCC=" << mDirChantier << "\n"; getchar();
mDirSauv = mDirChantier + "Sauv-" + mPostFixWorkDir + ELISE_CAR_DIR;
mDirTmp = mDirChantier + "Tmp-" + mPostFixWorkDir + ELISE_CAR_DIR;
cTplValGesInit<std::string> aTplICNM;
if (aICNM != "")
aTplICNM.SetVal(aICNM);
mICNM = cInterfChantierNameManipulateur::StdAlloc(argc,argv,mDirChantier,aTplICNM);
// std::cout << "Purge " << mNivPurge << "\n"; getchar();
}
/*
const std::string & cAppliBatch::ThisBin() const
{
return mThisBin;
}
*/
bool EAMIsInit(void * anAdr)
{
return (AllAddrEAM.find(anAdr)) != AllAddrEAM.end();
}
std::string StrInitOfEAM(void * anAdr) {return MapValuesEAM[anAdr];}
// protect spaces with backslashes (for use with 'make')
string protect_spaces( const string &i_str )
{
string out_str = i_str;
size_t lastPos = 0;
while ( true )
{
lastPos = out_str.find( ' ', lastPos );
if ( lastPos==string::npos ) return out_str;
out_str.insert(lastPos,1,'\\');
lastPos += 2;
}
}
/*Footer-MicMac-eLiSe-25/06/2007
Ce logiciel est un programme informatique servant � la mise en
correspondances d'images pour la reconstruction du relief.
Ce logiciel est régi par la licence CeCILL-B soumise au droit français et
respectant les principes de diffusion des logiciels libres. Vous pouvez
utiliser, modifier et/ou redistribuer ce programme sous les conditions
de la licence CeCILL-B telle que diffusée par le CEA, le CNRS et l'INRIA
sur le site "http://www.cecill.info".
En contrepartie de l'accessibilité au code source et des droits de copie,
de modification et de redistribution accordés par cette licence, il n'est
offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons,
seule une responsabilité restreinte pèse sur l'auteur du programme, le
titulaire des droits patrimoniaux et les concédants successifs.
A cet égard l'attention de l'utilisateur est attirée sur les risques
associés au chargement, � l'utilisation, � la modification et/ou au
développement et � la reproduction du logiciel par l'utilisateur étant
donné sa spécificité de logiciel libre, qui peut le rendre complexe �
manipuler et qui le réserve donc � des développeurs et des professionnels
avertis possédant des connaissances informatiques approfondies. Les
utilisateurs sont donc invités � charger et tester l'adéquation du
logiciel � leurs besoins dans des conditions permettant d'assurer la
sécurité de leurs systèmes et ou de leurs données et, plus généralement,
� l'utiliser et l'exploiter dans les mêmes conditions de sécurité.
Le fait que vous puissiez accéder � cet en-tête signifie que vous avez
pris connaissance de la licence CeCILL-B, et que vous en avez accepté les
termes.
Footer-MicMac-eLiSe-25/06/2007*/
| 24.835199 | 147 | 0.560937 | [
"vector"
] |
eb50e79d97805a93bd5904757f4259b68a3538bf | 9,035 | cpp | C++ | src/backend/cpu/copy.cpp | JuliaComputing/arrayfire | 93427f09ff928f97df29c0e358c3fcf6b478bec6 | [
"BSD-3-Clause"
] | 1 | 2018-06-14T23:49:18.000Z | 2018-06-14T23:49:18.000Z | src/backend/cpu/copy.cpp | JuliaComputing/arrayfire | 93427f09ff928f97df29c0e358c3fcf6b478bec6 | [
"BSD-3-Clause"
] | 1 | 2015-07-02T15:53:02.000Z | 2015-07-02T15:53:02.000Z | src/backend/cpu/copy.cpp | JuliaComputing/arrayfire | 93427f09ff928f97df29c0e358c3fcf6b478bec6 | [
"BSD-3-Clause"
] | 1 | 2018-02-26T17:11:03.000Z | 2018-02-26T17:11:03.000Z | /*******************************************************
* Copyright (c) 2014, ArrayFire
* All rights reserved.
*
* This file is distributed under 3-clause BSD license.
* The complete license agreement can be obtained at:
* http://arrayfire.com/licenses/BSD-3-Clause
********************************************************/
#include <type_traits>
#include <af/array.h>
#include <Array.hpp>
#include <copy.hpp>
#include <cstring>
#include <algorithm>
#include <complex>
#include <vector>
#include <cassert>
#include <err_cpu.hpp>
#include <math.hpp>
namespace cpu
{
template<typename T>
static void stridedCopy(T* dst, const dim4& ostrides, const T* src, const dim4 &dims, const dim4 &strides, unsigned dim)
{
if(dim == 0) {
if(strides[dim] == 1) {
//FIXME: Check for errors / exceptions
memcpy(dst, src, dims[dim] * sizeof(T));
} else {
for(dim_t i = 0; i < dims[dim]; i++) {
dst[i] = src[strides[dim]*i];
}
}
} else {
for(dim_t i = dims[dim]; i > 0; i--) {
stridedCopy<T>(dst, ostrides, src, dims, strides, dim - 1);
src += strides[dim];
dst += ostrides[dim];
}
}
}
// Assigns to single elements
template<typename T>
void copyData(T *to, const Array<T> &from)
{
if(from.isOwner()) {
// FIXME: Check for errors / exceptions
memcpy(to, from.get(), from.elements()*sizeof(T));
} else {
dim4 ostrides = calcStrides(from.dims());
stridedCopy<T>(to, ostrides, from.get(), from.dims(), from.strides(), from.ndims() - 1);
}
}
template<typename T>
Array<T> copyArray(const Array<T> &A)
{
Array<T> out = createEmptyArray<T>(A.dims());
copyData(out.get(), A);
return out;
}
template<typename inType, typename outType>
static void copy(Array<outType> &dst, const Array<inType> &src, outType default_value, double factor)
{
dim4 src_dims = src.dims();
dim4 dst_dims = dst.dims();
dim4 src_strides = src.strides();
dim4 dst_strides = dst.strides();
const inType * src_ptr = src.get();
outType * dst_ptr = dst.get();
dim_t trgt_l = std::min(dst_dims[3], src_dims[3]);
dim_t trgt_k = std::min(dst_dims[2], src_dims[2]);
dim_t trgt_j = std::min(dst_dims[1], src_dims[1]);
dim_t trgt_i = std::min(dst_dims[0], src_dims[0]);
for(dim_t l=0; l<dst_dims[3]; ++l) {
dim_t src_loff = l*src_strides[3];
dim_t dst_loff = l*dst_strides[3];
bool isLvalid = l<trgt_l;
for(dim_t k=0; k<dst_dims[2]; ++k) {
dim_t src_koff = k*src_strides[2];
dim_t dst_koff = k*dst_strides[2];
bool isKvalid = k<trgt_k;
for(dim_t j=0; j<dst_dims[1]; ++j) {
dim_t src_joff = j*src_strides[1];
dim_t dst_joff = j*dst_strides[1];
bool isJvalid = j<trgt_j;
for(dim_t i=0; i<dst_dims[0]; ++i) {
outType temp = default_value;
if (isLvalid && isKvalid && isJvalid && i<trgt_i) {
dim_t src_idx = i*src_strides[0] + src_joff + src_koff + src_loff;
temp = outType(src_ptr[src_idx])*outType(factor);
}
dim_t dst_idx = i*dst_strides[0] + dst_joff + dst_koff + dst_loff;
dst_ptr[dst_idx] = temp;
}
}
}
}
}
template<typename inType, typename outType>
Array<outType>
padArray(Array<inType> const &in, dim4 const &dims,
outType default_value, double factor)
{
Array<outType> ret = createValueArray<outType>(dims, default_value);
copy<inType, outType>(ret, in, outType(default_value), factor);
return ret;
}
template<typename inType, typename outType>
void copyArray(Array<outType> &out, Array<inType> const &in)
{
copy<inType, outType>(out, in, scalar<outType>(0), 1.0);
}
#define INSTANTIATE(T) \
template void copyData<T> (T *data, const Array<T> &from); \
template Array<T> copyArray<T>(const Array<T> &A); \
INSTANTIATE(float )
INSTANTIATE(double )
INSTANTIATE(cfloat )
INSTANTIATE(cdouble)
INSTANTIATE(int )
INSTANTIATE(uint )
INSTANTIATE(uchar )
INSTANTIATE(char )
INSTANTIATE(intl )
INSTANTIATE(uintl )
#define INSTANTIATE_PAD_ARRAY(SRC_T) \
template Array<float > padArray<SRC_T, float >(Array<SRC_T> const &src, dim4 const &dims, float default_value, double factor); \
template Array<double > padArray<SRC_T, double >(Array<SRC_T> const &src, dim4 const &dims, double default_value, double factor); \
template Array<cfloat > padArray<SRC_T, cfloat >(Array<SRC_T> const &src, dim4 const &dims, cfloat default_value, double factor); \
template Array<cdouble> padArray<SRC_T, cdouble>(Array<SRC_T> const &src, dim4 const &dims, cdouble default_value, double factor); \
template Array<int > padArray<SRC_T, int >(Array<SRC_T> const &src, dim4 const &dims, int default_value, double factor); \
template Array<uint > padArray<SRC_T, uint >(Array<SRC_T> const &src, dim4 const &dims, uint default_value, double factor); \
template Array<intl > padArray<SRC_T, intl >(Array<SRC_T> const &src, dim4 const &dims, intl default_value, double factor); \
template Array<uintl > padArray<SRC_T, uintl >(Array<SRC_T> const &src, dim4 const &dims, uintl default_value, double factor); \
template Array<uchar > padArray<SRC_T, uchar >(Array<SRC_T> const &src, dim4 const &dims, uchar default_value, double factor); \
template Array<char > padArray<SRC_T, char >(Array<SRC_T> const &src, dim4 const &dims, char default_value, double factor); \
template void copyArray<SRC_T, float >(Array<float > &dst, Array<SRC_T> const &src); \
template void copyArray<SRC_T, double >(Array<double > &dst, Array<SRC_T> const &src); \
template void copyArray<SRC_T, cfloat >(Array<cfloat > &dst, Array<SRC_T> const &src); \
template void copyArray<SRC_T, cdouble>(Array<cdouble> &dst, Array<SRC_T> const &src); \
template void copyArray<SRC_T, int >(Array<int > &dst, Array<SRC_T> const &src); \
template void copyArray<SRC_T, uint >(Array<uint > &dst, Array<SRC_T> const &src); \
template void copyArray<SRC_T, intl >(Array<intl > &dst, Array<SRC_T> const &src); \
template void copyArray<SRC_T, uintl >(Array<uintl > &dst, Array<SRC_T> const &src); \
template void copyArray<SRC_T, uchar >(Array<uchar > &dst, Array<SRC_T> const &src); \
template void copyArray<SRC_T, char >(Array<char > &dst, Array<SRC_T> const &src);
INSTANTIATE_PAD_ARRAY(float )
INSTANTIATE_PAD_ARRAY(double)
INSTANTIATE_PAD_ARRAY(int )
INSTANTIATE_PAD_ARRAY(uint )
INSTANTIATE_PAD_ARRAY(intl )
INSTANTIATE_PAD_ARRAY(uintl )
INSTANTIATE_PAD_ARRAY(uchar )
INSTANTIATE_PAD_ARRAY(char )
#define INSTANTIATE_PAD_ARRAY_COMPLEX(SRC_T) \
template Array<cfloat > padArray<SRC_T, cfloat >(Array<SRC_T> const &src, dim4 const &dims, cfloat default_value, double factor); \
template Array<cdouble> padArray<SRC_T, cdouble>(Array<SRC_T> const &src, dim4 const &dims, cdouble default_value, double factor); \
template void copyArray<SRC_T, cfloat >(Array<cfloat > &dst, Array<SRC_T> const &src); \
template void copyArray<SRC_T, cdouble >(Array<cdouble > &dst, Array<SRC_T> const &src);
INSTANTIATE_PAD_ARRAY_COMPLEX(cfloat )
INSTANTIATE_PAD_ARRAY_COMPLEX(cdouble)
#define SPECILIAZE_UNUSED_COPYARRAY(SRC_T, DST_T) \
template<> void copyArray<SRC_T, DST_T>(Array<DST_T> &out, Array<SRC_T> const &in) \
{\
CPU_NOT_SUPPORTED();\
}
SPECILIAZE_UNUSED_COPYARRAY(cfloat, double)
SPECILIAZE_UNUSED_COPYARRAY(cfloat, float)
SPECILIAZE_UNUSED_COPYARRAY(cfloat, uchar)
SPECILIAZE_UNUSED_COPYARRAY(cfloat, char)
SPECILIAZE_UNUSED_COPYARRAY(cfloat, uint)
SPECILIAZE_UNUSED_COPYARRAY(cfloat, int)
SPECILIAZE_UNUSED_COPYARRAY(cfloat, intl)
SPECILIAZE_UNUSED_COPYARRAY(cfloat, uintl)
SPECILIAZE_UNUSED_COPYARRAY(cdouble, double)
SPECILIAZE_UNUSED_COPYARRAY(cdouble, float)
SPECILIAZE_UNUSED_COPYARRAY(cdouble, uchar)
SPECILIAZE_UNUSED_COPYARRAY(cdouble, char)
SPECILIAZE_UNUSED_COPYARRAY(cdouble, uint)
SPECILIAZE_UNUSED_COPYARRAY(cdouble, int)
SPECILIAZE_UNUSED_COPYARRAY(cdouble, intl)
SPECILIAZE_UNUSED_COPYARRAY(cdouble, uintl)
}
| 42.617925 | 139 | 0.607084 | [
"vector"
] |
eb56dad571ea16b165ed75091c0f37dbdfe082eb | 33,103 | cpp | C++ | shell/ext/webcheck/postagnt.cpp | npocmaka/Windows-Server-2003 | 5c6fe3db626b63a384230a1aa6b92ac416b0765f | [
"Unlicense"
] | 17 | 2020-11-13T13:42:52.000Z | 2021-09-16T09:13:13.000Z | shell/ext/webcheck/postagnt.cpp | sancho1952007/Windows-Server-2003 | 5c6fe3db626b63a384230a1aa6b92ac416b0765f | [
"Unlicense"
] | 2 | 2020-10-19T08:02:06.000Z | 2020-10-19T08:23:18.000Z | shell/ext/webcheck/postagnt.cpp | sancho1952007/Windows-Server-2003 | 5c6fe3db626b63a384230a1aa6b92ac416b0765f | [
"Unlicense"
] | 14 | 2020-11-14T09:43:20.000Z | 2021-08-28T08:59:57.000Z | //
// Pei-Hwa Lin (peiwhal), Feb 3, 1997
//
#include "private.h"
#include "downld.h"
#include "urlmon.h"
#undef TF_THISMODULE
#define TF_THISMODULE TF_POSTAGENT
// Advanced inetcpl setting to disable channel logging
const TCHAR c_szNoChannelLogging[] = TEXT("NoChannelLogging");
const char c_szHeaders[] = "Content-Type: application/x-www-form-urlencoded\r\n";
#define c_ccHearders (ARRAYSIZE(c_szHeaders) - 1)
#define ENCODE_LOG
#ifdef ENCODE_LOG
const char c_szEncodeHeader[] = "Content-Transfer-Encoding: x-";
#define c_ccEncodeHeader (ARRAYSIZE(c_szEncodeHeader) - 1)
#endif //ENCODE_LOG
// *** W3C extended log format *** //
// text strings definitions
const char c_szUrlFields[] = "#Fields: s-URI";
#define c_ccUrlFields (ARRAYSIZE(c_szUrlFields) - 1)
const char c_szLogFields[] = "#Fields: x-context x-cache x-date x-time x-duration x-meta";
#define c_ccLogFields (ARRAYSIZE(c_szLogFields) - 1);
// *** W3C extended log format *** //
const TCHAR c_szPostRetryReg[] = TEXT("PostRetry");
const TCHAR c_szUserAgent[] = TEXT("User Agent");
extern TCHAR szInternetSettings[];
//-----------------------------------------------------------------------------
//
// CTrackingStg implementation
//
//-----------------------------------------------------------------------------
// this will empty log contents without removing the entry
//
HRESULT CTrackingStg::EmptyCacheEntry(GROUPID enumId)
{
HANDLE hEnum, hFile;
LPINTERNET_CACHE_ENTRY_INFOA lpCE = NULL;
DWORD cbSize;
HRESULT hr = S_OK;
ASSERT(enumId);
lpCE = (LPINTERNET_CACHE_ENTRY_INFOA)MemAlloc(LPTR, MY_MAX_CACHE_ENTRY_INFO);
if (!lpCE)
return E_OUTOFMEMORY;
cbSize = MY_MAX_CACHE_ENTRY_INFO;
hEnum = FindFirstUrlCacheEntryExA(_lpPfx,
0, //dwFlags
URLCACHE_FIND_DEFAULT_FILTER, //dwFilters,
0, //enumId, IE50:wininet change, not support group in extensible cache
lpCE,
&cbSize,
NULL, NULL, NULL);
if (hEnum)
{
FILETIME ftModified;
ftModified.dwHighDateTime = (DWORD)(enumId >> 32);
ftModified.dwLowDateTime = (DWORD)(0x00000000ffffffff & enumId);
for(;;)
{
if (lpCE->LastModifiedTime.dwLowDateTime == ftModified.dwLowDateTime &&
lpCE->LastModifiedTime.dwHighDateTime == ftModified.dwHighDateTime)
{
hFile = OpenItemLogFile(lpCE->lpszLocalFileName);
if (hFile != INVALID_HANDLE_VALUE)
{
CloseHandle(hFile);
DeleteFileA(lpCE->lpszLocalFileName);
DeleteUrlCacheEntryA(lpCE->lpszSourceUrlName);
TCHAR szUrl[INTERNET_MAX_URL_LENGTH];
SHAnsiToTChar(lpCE->lpszSourceUrlName, szUrl, ARRAYSIZE(szUrl));
CreateLogCacheEntry(szUrl, lpCE->ExpireTime,
ftModified, lpCE->CacheEntryType);
}
}
// reuse lpCE
if (!FindNextUrlCacheEntryExA(hEnum, lpCE, &cbSize, NULL, NULL, NULL))
{
// This code used to check GetLastError() for ERROR_NO_MORE_ITEMS before
// it would break. Well, that could put us in an infinite loop if the
// reason for failure were something else (like insufficient buffer) because
// wininet would not move forward in it's enumeration and we would not
// have done anything to address the error.
break;
}
}
FindCloseUrlCache(hEnum);
}
SAFELOCALFREE(lpCE);
return hr;
}
// this will delete url cache entries
// and delete url cache group
HRESULT CTrackingStg::RemoveCacheEntry(GROUPID enumId)
{
HANDLE hEnum;
LPINTERNET_CACHE_ENTRY_INFOA lpCE = NULL;
DWORD cbSize;
PROPVARIANT vProp = {0};
HRESULT hr = S_OK;
ASSERT(enumId);
lpCE = (LPINTERNET_CACHE_ENTRY_INFOA)MemAlloc(LPTR, MY_MAX_CACHE_ENTRY_INFO);
if (!lpCE)
return E_OUTOFMEMORY;
cbSize = MY_MAX_CACHE_ENTRY_INFO;
hEnum = FindFirstUrlCacheEntryExA(_lpPfx,
0, //dwFlags
URLCACHE_FIND_DEFAULT_FILTER, //dwFilters,
0, //enumId, IE50: wininet change
lpCE,
&cbSize,
NULL, NULL, NULL);
if (hEnum)
{
FILETIME ftModified;
ftModified.dwHighDateTime = (DWORD)(enumId >> 32);
ftModified.dwLowDateTime = (DWORD)(0x00000000ffffffff & enumId);
for(;;)
{
if (lpCE->LastModifiedTime.dwLowDateTime == ftModified.dwLowDateTime &&
lpCE->LastModifiedTime.dwHighDateTime == ftModified.dwHighDateTime)
{
DeleteUrlCacheEntryA(lpCE->lpszSourceUrlName);
vProp.vt = VT_UI4;
vProp.ulVal = 0; // clear tracking flag
TCHAR szUrl[INTERNET_MAX_URL_LENGTH];
SHAnsiToTChar(lpCE->lpszSourceUrlName+lstrlenA(_lpPfx), szUrl, ARRAYSIZE(szUrl));
hr = IntSiteHelper(szUrl,
&c_rgPropRead[PROP_TRACKING], &vProp, 1, TRUE);
PropVariantClear( &vProp );
}
// reuse lpCE
if (!FindNextUrlCacheEntryExA(hEnum, lpCE, &cbSize, NULL, NULL, NULL))
{
break;
}
}
FindCloseUrlCache(hEnum);
}
SAFELOCALFREE(lpCE);
return hr;
}
HANDLE CTrackingStg::OpenItemLogFile(LPCSTR lpFile)
{
HANDLE hFile = NULL;
hFile = CreateFileA(lpFile,
GENERIC_READ | GENERIC_WRITE,
0, //no sharing
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL);
return hFile;
}
DWORD CTrackingStg::ReadLogFile(LPCSTR lpFile, LPSTR* lplpbuf)
{
HANDLE hFile = NULL;
DWORD cbFile = 0;
DWORD cbRead;
hFile = OpenItemLogFile(lpFile);
if (hFile == INVALID_HANDLE_VALUE)
return 0;
cbFile = GetFileSize(hFile, NULL);
if (cbFile == 0xFFFFFFFF)
{
CloseHandle(hFile);
return 0;
}
*lplpbuf = (LPSTR)MemAlloc(LPTR, (cbFile + 2) * sizeof(CHAR));
cbRead = 0;
if (!ReadFile(hFile, *lplpbuf, cbFile, &cbRead, NULL))
{
cbRead = 0;
}
ASSERT((cbRead == cbFile));
CloseHandle(hFile);
return cbRead;
}
void CTrackingStg::AppendLogEntries(LPINTERNET_CACHE_ENTRY_INFOA lpce)
{
LPSTR lpbuf = NULL;
DWORD cbsize, cbWritten;
cbsize = ReadLogFile(lpce->lpszLocalFileName, &lpbuf);
cbWritten = 0;
if (lpbuf && (cbsize > c_ccEmptyLog)) //change this threshold if modify
{ //CreatePrefixedCacheEntry in trkcache.cpp
AppendLogUrlField(lpce);
WriteFile(_hLogFile, lpbuf, cbsize, &cbWritten, NULL);
ASSERT((cbsize == cbWritten));
}
SAFELOCALFREE(lpbuf);
return;
}
void CTrackingStg::AppendLogUrlField(LPINTERNET_CACHE_ENTRY_INFOA lpce)
{
DWORD dwWritten = 0;
LPSTR lpbuf = NULL;
DWORD cb;
// lpce->lpszSourcesUrlName contains prefixed string
DWORD cchAlloc = lstrlenA(lpce->lpszSourceUrlName) - lstrlenA(_lpPfx) + c_ccUrlFields
+ c_ccLogFields;
cb = (cchAlloc + 7) * sizeof(CHAR);
lpbuf = (LPSTR)MemAlloc(LPTR, cb);
if (lpbuf)
{
wnsprintfA(lpbuf, cb, "%s\r\n%s\r\n%s\r\n", c_szUrlFields,
lpce->lpszSourceUrlName+lstrlenA(_lpPfx), c_szLogFields);
WriteFile(_hLogFile, lpbuf, lstrlenA(lpbuf), &dwWritten, NULL);
}
SAFELOCALFREE(lpbuf);
return;
}
HRESULT CTrackingStg::Enumeration(LONGLONG enumId)
{
HRESULT hr = E_FAIL;
HANDLE hEnum;
LPINTERNET_CACHE_ENTRY_INFOA lpCE = NULL;
lpCE = (LPINTERNET_CACHE_ENTRY_INFOA)MemAlloc(LPTR, MY_MAX_CACHE_ENTRY_INFO);
if (!lpCE)
return E_OUTOFMEMORY;
DWORD cbSize = MY_MAX_CACHE_ENTRY_INFO;
hEnum = FindFirstUrlCacheEntryExA(_lpPfx,
0, //dwFlags
URLCACHE_FIND_DEFAULT_FILTER, //dwFilters,
0, //enumId, IE50: wininet change, not support group in extensible cache
lpCE,
&cbSize,
NULL, NULL, NULL);
if (hEnum)
{
FILETIME ftModified;
ftModified.dwHighDateTime = (DWORD)(enumId >> 32);
ftModified.dwLowDateTime = (DWORD)(0x00000000ffffffff & enumId);
for(;;)
{
if (!StrCmpNIA(lpCE->lpszSourceUrlName, _lpPfx, lstrlenA(_lpPfx))
&& lpCE->LastModifiedTime.dwLowDateTime == ftModified.dwLowDateTime
&& lpCE->LastModifiedTime.dwHighDateTime == ftModified.dwHighDateTime)
{
AppendLogEntries(lpCE);
}
// reuse lpCE
cbSize = MY_MAX_CACHE_ENTRY_INFO;
if (!FindNextUrlCacheEntryExA(hEnum, lpCE, &cbSize, NULL, NULL, NULL))
{
break;
}
}
FindCloseUrlCache(hEnum);
hr = S_OK;
}
SAFELOCALFREE(lpCE);
return hr;
}
HRESULT CTrackingStg::RetrieveLogData(ISubscriptionItem* pCDFItem)
{
HRESULT hr = E_FAIL;
// heck: wininet does not support multiple groups to same URL
// have to enumerate new and old groups to cover
GROUPID newId;
ReadLONGLONG(pCDFItem, c_szTrackingCookie, &newId);
if (newId)
{
hr = Enumeration(newId);
}
// heck: end
hr = Enumeration(_groupId);
CloseLogFile();
return hr;
}
HRESULT CTrackingStg::RetrieveAllLogStream(ISubscriptionItem* pCDFItem, LPCSTR lpFile)
{
HRESULT hr = E_FAIL;
LPTSTR lpPfx = ReadTrackingPrefix();
if (lpPfx)
{
int len = lstrlenW(lpPfx) + 1;
_lpPfx = (LPSTR)MemAlloc(LPTR, len * sizeof(CHAR));
if (_lpPfx)
{
SHUnicodeToAnsi(lpPfx, _lpPfx, len);
}
MemFree(lpPfx);
}
_hLogFile = CreateFileA(lpFile,
GENERIC_WRITE,
0, //no sharing
NULL,
CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL,
NULL);
if (_hLogFile == INVALID_HANDLE_VALUE) //turn-around is read into a buffer.
return hr;
hr = RetrieveLogData(pCDFItem);
return S_OK;
}
//
// Validate the Posting by
// 1. attempt to post this log does not exceed limits set in registry
// 2. the log itself is valid
//
BOOL CTrackingStg::IsExpired(ISubscriptionItem* pItem)
{
BOOL bret;
DWORD regRetry = 3; // Intelligent default so we don't need the registry value set.
ReadRegValue(HKEY_LOCAL_MACHINE, MY_WEBCHECK_POST_REG,
c_szPostRetryReg, (void *)®Retry, sizeof(regRetry));
bret = (_dwRetry < regRetry) ? FALSE : TRUE;
if (bret) return bret;
// read the purgetime from subscription property bag
DATE dt = 0.0;
if (SUCCEEDED(ReadDATE(pItem, c_szPostPurgeTime, &dt)) && dt != 0)
{
SYSTEMTIME st, expiredst;
FILETIME ft, expiredft;
VariantTimeToSystemTime(dt, &expiredst);
SystemTimeToFileTime(&expiredst, &expiredft);
GetLocalTime(&st);
SystemTimeToFileTime(&st, &ft);
bret = (CompareFileTime(&ft, &expiredft) > 0) ? TRUE : FALSE;
}
return bret;
}
CTrackingStg::CTrackingStg
(
)
{
_pwszURL = NULL;
_groupId = 0;
_dwRetry = 0;
_lpPfx = NULL;
}
CTrackingStg::~CTrackingStg()
{
//
// Release/delete any resources
//
DBG("CTrackingStg d'tor");
SAFEFREEOLESTR(_pwszURL);
SAFELOCALFREE(_lpPfx);
if (_hLogFile)
CloseHandle(_hLogFile);
}
//------------------------------------------------------------
//
// CWCPostAgent implementation
//
//------------------------------------------------------------
//------------------------------------------------------------
// virtual functions overriding CDeliveryAgent
//------------------------------------------------------------
ISubscriptionMgr2 *
CWCPostAgent::GetSubscriptionMgr()
{
ISubscriptionMgr2* pSubsMgr=NULL;
CoCreateInstance(CLSID_SubscriptionMgr, NULL, CLSCTX_INPROC_SERVER,
IID_ISubscriptionMgr2, (void**)&pSubsMgr);
return pSubsMgr;
}
//
// Re-stamp a set of tracking URLs from old group to new group
// without losing logging data
//
void
CWCPostAgent :: MergeGroupOldToNew()
{
GROUPID newId;
HANDLE hEnum;
LPINTERNET_CACHE_ENTRY_INFO lpCE = NULL;
DWORD cbSize;
LPTSTR lpPfx = NULL;
newId = 0;
ReadLONGLONG(_pCDFItem, c_szTrackingCookie, &newId);
if (!newId && !_pUploadStream->_groupId)
return;
ASSERT(newId);
lpCE = (LPINTERNET_CACHE_ENTRY_INFO)MemAlloc(LPTR, MY_MAX_CACHE_ENTRY_INFO);
if (!lpCE)
{
SetLastError(ERROR_OUTOFMEMORY);
return;
}
lpPfx = ReadTrackingPrefix();
if (!lpPfx)
{
MemFree(lpCE);
return;
}
cbSize = MY_MAX_CACHE_ENTRY_INFO;
hEnum = FindFirstUrlCacheEntryEx(lpPfx,
0, //dwFlags
URLCACHE_FIND_DEFAULT_FILTER, //dwFilters,
0, //_pUploadStream->_groupId, IE50 changed
lpCE,
&cbSize,
NULL, NULL, NULL);
if (hEnum)
{
FILETIME ftModified, ftOld;
ftModified.dwHighDateTime = (DWORD)(newId >> 32);
ftModified.dwLowDateTime = (DWORD)(0x00000000ffffffff & newId);
ftOld.dwHighDateTime = (DWORD)(_pUploadStream->_groupId >> 32);
ftOld.dwLowDateTime = (DWORD)(0x00000000ffffffff & _pUploadStream->_groupId);
for(;;)
{
if (!StrCmpNI(lpCE->lpszSourceUrlName, lpPfx, lstrlen(lpPfx))
&& lpCE->LastModifiedTime.dwLowDateTime == ftOld.dwLowDateTime
&& lpCE->LastModifiedTime.dwHighDateTime == ftOld.dwHighDateTime)
{
// commit changes to url cache
lpCE->LastModifiedTime.dwHighDateTime = ftModified.dwHighDateTime;
lpCE->LastModifiedTime.dwLowDateTime = ftModified.dwLowDateTime;
SetUrlCacheEntryInfo(lpCE->lpszSourceUrlName, lpCE, CACHE_ENTRY_MODTIME_FC);
}
// reuse lpCE
cbSize = MY_MAX_CACHE_ENTRY_INFO;
if (!FindNextUrlCacheEntryEx(hEnum, lpCE, &cbSize, NULL, NULL, NULL))
{
break;
}
}
FindCloseUrlCache(hEnum);
}
SAFELOCALFREE(lpCE);
return;
}
HRESULT CWCPostAgent::InitRequest
(
LPCSTR lpszVerb
)
{
char hostName[INTERNET_MAX_HOST_NAME_LENGTH+1];
char userName[INTERNET_MAX_USER_NAME_LENGTH+1];
char password[INTERNET_MAX_PASSWORD_LENGTH+1];
char urlPath[INTERNET_MAX_PATH_LENGTH+1];
URL_COMPONENTSA uc;
BOOL bRet;
LPSTR pszPostURL;
int iLen;
TCHAR pszUA[128];
HRESULT hr = E_FAIL;
if ( !_pUploadStream->_pwszURL )
return S_OK; //do nothing if post url doesn't exist
iLen = lstrlenW(_pUploadStream->_pwszURL) + 1;
pszPostURL = new CHAR[iLen];
if (!pszPostURL)
return E_OUTOFMEMORY;
SHUnicodeToAnsi(_pUploadStream->_pwszURL, pszPostURL, iLen);
memset(&uc, 0, sizeof(uc));
uc.dwStructSize = sizeof(uc);
uc.lpszHostName = hostName;
uc.dwHostNameLength = sizeof(hostName);
uc.nPort = INTERNET_INVALID_PORT_NUMBER;
uc.lpszUserName = userName;
uc.dwUserNameLength = sizeof(userName);
uc.lpszPassword = password;
uc.dwPasswordLength = sizeof(password);
uc.lpszUrlPath = urlPath;
uc.dwUrlPathLength = sizeof(urlPath);
bRet = InternetCrackUrlA(pszPostURL, lstrlenA(pszPostURL),
ICU_DECODE, &uc);
if (!bRet)
{
DBG("InternetCrackUrl failed");
goto _exitInit;
}
// read User Agent string
if (!ReadRegValue(HKEY_CURRENT_USER, szInternetSettings, c_szUserAgent, pszUA, sizeof(pszUA)))
StrCpyN(pszUA, TEXT("PostAgent"), ARRAYSIZE(pszUA));
_hSession = InternetOpen(pszUA, // used in User-Agent: header
INTERNET_OPEN_TYPE_PRECONFIG, //INTERNET_OPEN_TYPE_DIRECT,
NULL,
NULL,
//INTERNET_FLAG_ASYNC);
0); //synchronous operation
if ( !_hSession )
{
DBG("!_hSession");
goto _exitInit;
}
_hHttpSession = InternetConnectA(_hSession,
uc.lpszHostName, //"peihwalap",
uc.nPort, //INTERNET_INVALID_PORT_NUMBER,
uc.lpszUserName, //NULL,
uc.lpszPassword, //NULL,
INTERNET_SERVICE_HTTP,
INTERNET_FLAG_KEEP_CONNECTION,
0);
//(DWORD)this); //dwContext.
// InternetSetStatusCallback(m_hSession, CWCPostAgent::PostCallback);
if ( !_hHttpSession )
{
DBG( "!_hHttpSession");
CloseRequest();
goto _exitInit;
}
// ignore security problem
_hHttpRequest = HttpOpenRequestA(_hHttpSession, lpszVerb,
uc.lpszUrlPath,
HTTP_VERSIONA,
NULL, //lpszReferer
NULL, //lpszAcceptTyypes
//INTERNET_FLAG_IGNORE_CERT_CN_INVALID |
//INTERNET_FLAG_IGNORE_CERT_DATE_INVALID |
//INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTPS |
//INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTP |
INTERNET_FLAG_NO_COOKIES,
0);
//(DWORD)this); //dwContext
if ( !_hHttpRequest )
{
DBG_WARN("Post Agent: !_hHttpRequest");
CloseRequest();
goto _exitInit;
}
else
hr = S_OK;
_exitInit:
delete [] pszPostURL;
return hr;
}
HRESULT CWCPostAgent::SendRequest
(
LPCSTR lpszHeaders,
LPDWORD lpdwHeadersLength,
LPCSTR lpszOption,
LPDWORD lpdwOptionLength
)
{
BOOL bRet=FALSE;
HttpAddRequestHeadersA(_hHttpRequest,
(LPCSTR)c_szHeaders,
(DWORD)-1L,
HTTP_ADDREQ_FLAG_ADD);
if (lpszHeaders && *lpszHeaders) // don't bother if it's empty
bRet = HttpAddRequestHeadersA(_hHttpRequest,
(LPCSTR)lpszHeaders,
*lpdwHeadersLength,
HTTP_ADDREQ_FLAG_ADD | HTTP_ADDREQ_FLAG_REPLACE);
/*
bRet = HttpSendRequest(_hHttpRequest,
(LPCTSTR)lpszHeaders, //HEADER_ENCTYPE,
*lpdwHeadersLength, //sizeof(HEADER_ENCTYPE),
(LPVOID)lpszOption,
*lpdwOptionLength);
*/
bRet = HttpSendRequest(_hHttpRequest,
NULL, //HEADER_ENCTYPE,
0, //sizeof(HEADER_ENCTYPE),
(LPVOID)lpszOption,
*lpdwOptionLength);
if ( !bRet )
{
DWORD dwLastError = GetLastError();
TraceMsg(TF_ERROR, "HttpSendRequest failed: Error = %lx", dwLastError);
DBG_WARN("Post Agent: HttpSendRequest failed");
return E_FAIL;
}
DWORD dwBuffLen;
TCHAR buff[1024];
dwBuffLen = sizeof(buff);
bRet = HttpQueryInfo(_hHttpRequest,
//HTTP_QUERY_CONTENT_TYPE, //HTTP_QUERY_REQUEST_METHOD,
HTTP_QUERY_STATUS_CODE, //HTTP_QUERY_RAW_HEADERS,
buff,
&dwBuffLen,
NULL);
if ( !bRet )
{
DWORD dwLastError = GetLastError();
TraceMsg(TF_ERROR, "HttpQueryInfo failed: Error = %lx", dwLastError);
DBG_WARN("Post Agent: HttpQueryInfo failed");
}
else
{
int iretcode = StrToInt(buff);
if (iretcode == 200) // || iretcode == 100) //HTTP_STATUS_OK
return S_OK; //100: too many semaphors
//501: required not supported
//502: bad gateway
}
return E_FAIL;
}
HRESULT CWCPostAgent::CloseRequest
(
void
)
{
InternetCloseHandle(_hSession);
_hSession = _hHttpSession = _hHttpRequest = 0;
return S_OK;
}
// Called if upload failed
// just increase retry number
HRESULT CWCPostAgent::OnPostFailed()
{
WriteDWORD(_pCDFItem, c_szPostingRetry, _pUploadStream->_dwRetry+1);
MergeGroupOldToNew();
return S_OK;
}
// Called if upload succeeded
// 1) remove PostUrl from item
// 2) delete tracking cache entry (Doh!)
HRESULT CWCPostAgent::OnPostSuccess()
{
GROUPID newId = 0;
if (!_pCDFItem)
return E_INVALIDARG;
ReadLONGLONG(_pCDFItem, c_szTrackingCookie, &newId);
_pUploadStream->RemoveCacheEntry(_pUploadStream->_groupId);
if (newId == _pUploadStream->_groupId)
{
BSTR bstrURL = NULL;
ReadBSTR(_pCDFItem, c_szTrackingPostURL, &bstrURL);
if (!StrCmpIW(bstrURL, _pUploadStream->_pwszURL))
{
WriteOLESTR(_pCDFItem, c_szTrackingPostURL, bstrURL);
}
SAFEFREEBSTR(bstrURL);
}
else
_pUploadStream->EmptyCacheEntry(newId);
return S_OK;
}
HRESULT
CWCPostAgent::FindCDFStartItem()
{
IServiceProvider *pSP;
if (_pCDFItem)
return S_OK;
if (SUCCEEDED(m_pAgentEvents->QueryInterface(IID_IServiceProvider, (void **)&pSP)) && pSP)
{
pSP->QueryService(CLSID_ChannelAgent, IID_ISubscriptionItem, (void **)&_pCDFItem);
pSP->Release();
}
if (NULL == _pCDFItem)
{
TraceMsg(TF_THISMODULE, "PostAgent : FindCDFStartItem failed");
}
return (_pCDFItem) ? S_OK : E_NOINTERFACE;
}
HRESULT CWCPostAgent::DoFileUpload()
{
HRESULT hr;
DWORD dwLen, dwHdr;
SAFELOCALFREE(_pszPostStream);
dwLen = _pUploadStream->ReadLogFile(_lpLogFile, &_pszPostStream);
if (dwLen == 0)
{
// no log to post, should clean up cache entries for this group.
OnPostSuccess();
return S_OK;
}
if (FAILED(hr = InitRequest("POST")))
return hr;
#ifdef ENCODE_LOG
CHAR lpEncodeHdr[c_ccEncodeHeader+MAX_PATH];
lpEncodeHdr[0] = '\0';
if (SUCCEEDED(ReadBSTR(m_pSubscriptionItem, c_szPostHeader, &_pwszEncoding)))
{
if (_pwszEncoding && *_pwszEncoding)
{
IEncodingFilterFactory* pEflt = NULL;
IDataFilter* pDF = NULL;
CoCreateInstance(CLSID_StdEncodingFilterFac, NULL, CLSCTX_INPROC_SERVER,
IID_IEncodingFilterFactory, (void**)&pEflt);
if (pEflt)
{
pEflt->GetDefaultFilter(_pwszEncoding, L"text", &pDF);
if (pDF)
{
LONG lInUsed = 0;
LONG lOutUsed = 0;
LPSTR pInBuf = _pszPostStream;
LPSTR pOutBuf = NULL;
HRESULT hrCode = NOERROR;
pOutBuf = (LPSTR)MemAlloc(LPTR, dwLen);
if (pOutBuf == NULL)
goto do_upload;
hrCode = pDF->DoEncode(
0,
dwLen,
(BYTE *)pInBuf,
dwLen,
(BYTE *)pOutBuf,
dwLen,
&lInUsed,
&lOutUsed,
0);
if (SUCCEEDED(hrCode))
{
// add encoding header information, e.g.
// "Content-Transfer-Encoding: x-gzip\r\n"
wnsprintfA(lpEncodeHdr, ARRAYSIZE(lpEncodeHdr), "%s%S\r\n",
c_szEncodeHeader, _pwszEncoding);
SAFELOCALFREE(_pszPostStream);
_pszPostStream = (LPSTR)MemAlloc(LPTR, lOutUsed+2);
if (_pszPostStream)
{
memcpy(_pszPostStream, pOutBuf, lOutUsed); //do I need to append CR?
dwLen = (DWORD)lOutUsed;
}
else
{
hr = E_OUTOFMEMORY;
}
}
pDF->Release();
SAFELOCALFREE(pOutBuf);
}
pEflt->Release();
}
} // if (_pwszEncoding && *_pwszEncoding)
} //ReadBSTR
do_upload:
dwHdr = lstrlenA(lpEncodeHdr);
hr = SendRequest(lpEncodeHdr, &dwHdr, _pszPostStream, &dwLen);
#else
dwHdr = lstrlenA("");
hr = SendRequest(NULL, &dwHdr, _pszPostStream, &dwLen);
#endif //ENCODE_LOG
CloseRequest();
if (FAILED(hr))
{
TraceMsg(TF_THISMODULE, "PostAgent failed to SendRequest");
OnPostFailed();
}
else
{
TraceMsg(TF_THISMODULE, "PostAgent Posted data");
OnPostSuccess();
}
return hr;
}
BOOL CWCPostAgent::GetTmpLogFileName()
{
char szPath[MAX_PATH];
if (GetTempPathA(MAX_PATH, szPath) > 0)
{
_lpLogFile = (LPSTR)MemAlloc(LPTR, MAX_PATH+1);
if (GetTempFileNameA(szPath, "trk", 0, _lpLogFile))
{
return TRUE;
}
}
return FALSE;
}
HRESULT CWCPostAgent::DoPost()
{
HRESULT hr = E_FAIL;
_pUploadStream->_groupId = 0L;
if (FAILED(ReadLONGLONG(m_pSubscriptionItem, c_szTrackingCookie, &_pUploadStream->_groupId)))
return hr;
if (FAILED(ReadDWORD(m_pSubscriptionItem, c_szPostingRetry, &_pUploadStream->_dwRetry)))
_pUploadStream->_dwRetry = 0;
if (_pUploadStream->IsExpired(m_pSubscriptionItem))
{
// post is expired, clean up log cache entries
OnPostSuccess();
return hr;
}
if (!GetTmpLogFileName())
{
if (NULL != _lpLogFile)
{
MemFree(_lpLogFile);
}
int nLen = MAX_PATH + 1;
_lpLogFile = (LPSTR)MemAlloc(LPTR, nLen * sizeof(CHAR));
if (_lpLogFile)
{
StrCpyNA(_lpLogFile, "trkad.tmp", nLen);
}
}
if (FAILED(hr = _pUploadStream->RetrieveAllLogStream(_pCDFItem, _lpLogFile)))
return hr;
hr = DoFileUpload();
if (_lpLogFile)
DeleteFileA(_lpLogFile);
return hr;
}
// OnInetOnline
HRESULT CWCPostAgent::StartDownload()
{
HRESULT hr;
ASSERT(_pUploadStream && _pUploadStream->_pwszURL);
hr = FindCDFStartItem();
if (SUCCEEDED(hr))
{
BSTR bstrChannelURL = NULL;
hr = ReadBSTR(m_pSubscriptionItem, c_szPropURL, &bstrChannelURL);
ASSERT(SUCCEEDED(hr) && *bstrChannelURL);
if (SUCCEEDED(hr) && !SHRestricted2W(REST_NoChannelLogging, bstrChannelURL, 0)
&& !ReadRegDWORD(HKEY_CURRENT_USER, c_szRegKey, c_szNoChannelLogging))
{
hr = DoPost();
}
else
{
OnPostSuccess(); // log is off, clean up log cache entries
}
SAFEFREEBSTR(bstrChannelURL);
}
SAFERELEASE(_pCDFItem);
SetEndStatus(S_OK);
CleanUp();
return S_OK;
}
// OnAgentStart
HRESULT CWCPostAgent::StartOperation()
{
if (_pUploadStream)
{
DBG_WARN("Agent busy, returning failure");
SetEndStatus(E_FAIL);
SendUpdateNone();
return E_FAIL;
}
_pUploadStream = NULL;
_pUploadStream = new CTrackingStg();
if (!_pUploadStream)
{
DBG("failed to allocate CTrackStg");
SetEndStatus(E_OUTOFMEMORY);
SendUpdateNone();
return E_OUTOFMEMORY;
}
SAFEFREEOLESTR(_pUploadStream->_pwszURL);
if (FAILED(ReadOLESTR(m_pSubscriptionItem, c_szTrackingPostURL, &_pUploadStream->_pwszURL)) ||
!CUrlDownload::IsValidURL(_pUploadStream->_pwszURL))
{
DBG_WARN("Couldn't get valid URL from start item (aborting)");
SetEndStatus(E_INVALIDARG);
SendUpdateNone();
return E_INVALIDARG;
}
// After calling this, we'll reenter either in "StartDownload" or in
// "AbortUpdate" with m_scEndStatus = E_ACCESSDENIED
return CDeliveryAgent::StartOperation();
}
//------------------------------------------------------------
//
// override CDeliveryAgent virtual functions
//
//------------------------------------------------------------
// OnInetOffline
// Forcibly abort current operation
HRESULT CWCPostAgent::AgentAbort(DWORD dwFlags)
{
DBG("CWCPostAgent::AbortUpdate");
if (_pUploadStream)
{
if (SUCCEEDED(FindCDFStartItem()))
{
OnPostFailed();
}
}
return CDeliveryAgent::AgentAbort(dwFlags);
}
void CWCPostAgent::CleanUp()
{
SAFEDELETE(_pUploadStream);
if (_lpLogFile)
DeleteFileA(_lpLogFile);
SAFEFREEBSTR(_pwszEncoding);
SAFELOCALFREE(_lpLogFile);
SAFELOCALFREE(_pszPostStream);
CDeliveryAgent::CleanUp();
}
//------------------------------------------------------------
//
// CWCPostAgent Constructor/D'Constr
//
//------------------------------------------------------------
CWCPostAgent::CWCPostAgent()
{
DBG("Creating CWCPostAgent object");
//
// Maintain global count of objects in webcheck.dll
//
DllAddRef();
//
// Initialize object member variables
//
_pUploadStream = NULL;
_pwszEncoding = NULL;
_pszPostStream = NULL;
_lpLogFile = NULL;
_hSession = _hHttpSession = _hHttpRequest = 0;
}
CWCPostAgent::~CWCPostAgent()
{
SAFERELEASE(_pCDFItem);
//
// Maintain global count of objects
//
DllRelease();
//
// Release/delete any resources
//
DBG("Destroyed CWCPostAgent object");
}
| 29.768885 | 122 | 0.515633 | [
"object"
] |
eb574ae4ae83281a4857d11fe134824cd42c9fa9 | 5,740 | cpp | C++ | Android/00-Code/NDK/BionicAPI/app/src/main/cpp/local-server.cpp | hiloWang/notes | 64a637a86f734e4e80975f4aa93ab47e8d7e8b64 | [
"Apache-2.0"
] | 2 | 2020-10-08T13:22:08.000Z | 2021-07-28T14:45:41.000Z | Android/NDK/BionicAPI/app/src/main/cpp/local-server.cpp | flyfire/Programming-Notes-Code | 4b1bdd74c1ba0c007c504834e4508ec39f01cd94 | [
"Apache-2.0"
] | null | null | null | Android/NDK/BionicAPI/app/src/main/cpp/local-server.cpp | flyfire/Programming-Notes-Code | 4b1bdd74c1ba0c007c504834e4508ec39f01cd94 | [
"Apache-2.0"
] | 6 | 2020-08-20T07:19:17.000Z | 2022-03-02T08:16:21.000Z | #include "JniBridge.h"
#include "socket-api.h"
#include <jni.h>
#include <stdio.h>
// va_list, vsnprintf
#include <stdarg.h>
// errno
#include <errno.h>
// strerror_r, memset
#include <string.h>
// socket, bind, getsockname, listen, accept, recv, send, connect
#include <sys/types.h>
#include <sys/socket.h>
// sockaddr_un
#include <sys/un.h>
// htons, sockaddr_in
#include <netinet/in.h>
// inet_ntop
#include <arpa/inet.h>
// close, unlink
#include <unistd.h>
// offsetof
#include <stddef.h>
/**
* Constructs a new Local UNIX socket.
*
* @param env JNIEnv interface.
* @param obj object instance.
* @return socket descriptor.
* @throws IOException
*/
static int NewLocalSocket(JNIEnv *env, jobject obj) {
// Construct socket
LogMessage(env, obj, "Constructing a new Local UNIX socket...");
int localSocket = socket(PF_LOCAL, SOCK_STREAM, 0);
// Check if socket is properly constructed
if (-1 == localSocket) {
// Throw an exception with error number
ThrowErrnoException(env, "java/io/IOException", errno);
}
return localSocket;
}
/**
* Binds a local UNIX socket to a name.
*
* @param env JNIEnv interface.
* @param obj object instance.
* @param sd socket descriptor.
* @param name socket name.
* @throws IOException
*/
static void BindLocalSocketToName(
JNIEnv *env,
jobject obj,
int sd,
const char *name) {
struct sockaddr_un address;
// Name length
const size_t nameLength = strlen(name);
// Path length is initiall equal to name length
size_t pathLength = nameLength;
// If name is not starting with a slash it is
// in the abstract namespace
bool abstractNamespace = ('/' != name[0]);
// Abstract namespace requires having the first
// byte of the path to be the zero byte, update
// the path length to include the zero byte
if (abstractNamespace) {
pathLength++;
}
// Check the path length
if (pathLength > sizeof(address.sun_path)) {
// Throw an exception with error number
ThrowException(env, "java/io/IOException", "Name is too big.");
} else {
// Clear the address bytes
memset(&address, 0, sizeof(address));
address.sun_family = PF_LOCAL;
// Socket path
char *sunPath = address.sun_path;
// First byte must be zero to use the abstract namespace
if (abstractNamespace) {
*sunPath++ = NULL;
}
// Append the local name
strcpy(sunPath, name);
// Address length
socklen_t addressLength =
(offsetof(struct sockaddr_un, sun_path))
+ pathLength;
// Unlink if the socket name is already binded
unlink(address.sun_path);
// Bind socket
LogMessage(env, obj, "Binding to local name %s%s.", (abstractNamespace) ? "(null)" : "",
name);
if (-1 == bind(sd, (struct sockaddr *) &address, addressLength)) {
// Throw an exception with error number
ThrowErrnoException(env, "java/io/IOException", errno);
}
}
}
/**
* Blocks and waits for incoming client connections on the
* given socket.
*
* @param env JNIEnv interface.
* @param obj object instance.
* @param sd socket descriptor.
* @return client socket.
* @throws IOException
*/
static int AcceptOnLocalSocket(JNIEnv *env, jobject obj, int sd) {
// Blocks and waits for an incoming client connection
// and accepts it
LogMessage(env, obj, "Waiting for a client connection...");
int clientSocket = accept(sd, NULL, NULL);
// If client socket is not valid
if (-1 == clientSocket) {
// Throw an exception with error number
ThrowErrnoException(env, "java/io/IOException", errno);
}
return clientSocket;
}
void
Java_com_ztiany_bionic_tcpudp_LocalEchoActivity_nativeStartLocalServer(JNIEnv *env, jobject obj,
jstring name) {
// Construct a new local UNIX socket.
int serverSocket = NewLocalSocket(env, obj);
if (NULL == env->ExceptionOccurred()) {
// Get name as C string
const char *nameText = env->GetStringUTFChars(name, NULL);
if (NULL == nameText)
goto exit;
// Bind socket to a port number
BindLocalSocketToName(env, obj, serverSocket, nameText);
// Release the name text
env->ReleaseStringUTFChars(name, nameText);
// If bind is failed
if (NULL != env->ExceptionOccurred())
goto exit;
// Listen on socket with a backlog of 4 pending connections
ListenOnSocket(env, obj, serverSocket, 4);
if (NULL != env->ExceptionOccurred())
goto exit;
// Accept a client connection on socket
int clientSocket = AcceptOnLocalSocket(env, obj, serverSocket);
if (NULL != env->ExceptionOccurred())
goto exit;
char buffer[MAX_BUFFER_SIZE];
ssize_t recvSize;
ssize_t sentSize;
// Receive and send back the data
while (1) {
// Receive from the socket
recvSize = ReceiveFromSocket(env, obj, clientSocket, buffer, MAX_BUFFER_SIZE);
if ((0 == recvSize) || (NULL != env->ExceptionOccurred()))
break;
// Send to the socket
sentSize = SendToSocket(env, obj, clientSocket, buffer, (size_t) recvSize);
if ((0 == sentSize) || (NULL != env->ExceptionOccurred()))
break;
}
// Close the client socket
close(clientSocket);
}
exit:
if (serverSocket > 0) {
close(serverSocket);
}
}
| 28 | 96 | 0.611324 | [
"object"
] |
eb5c25b751efb3f86183c00d62ca4c7bac6ae4dd | 4,045 | c++ | C++ | src/extern/inventor/apps/examples/Mentor/CXX/17.1.ColorIndex.c++ | OpenXIP/xip-libraries | 9f0fef66038b20ff0c81c089d7dd0038e3126e40 | [
"Apache-2.0"
] | 2 | 2020-05-21T07:06:07.000Z | 2021-06-28T02:14:34.000Z | src/extern/inventor/apps/examples/Mentor/CXX/17.1.ColorIndex.c++ | OpenXIP/xip-libraries | 9f0fef66038b20ff0c81c089d7dd0038e3126e40 | [
"Apache-2.0"
] | null | null | null | src/extern/inventor/apps/examples/Mentor/CXX/17.1.ColorIndex.c++ | OpenXIP/xip-libraries | 9f0fef66038b20ff0c81c089d7dd0038e3126e40 | [
"Apache-2.0"
] | 6 | 2016-03-21T19:53:18.000Z | 2021-06-08T18:06:03.000Z | /*
*
* Copyright (C) 2000 Silicon Graphics, Inc. All Rights Reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* Further, this software is distributed without any warranty that it is
* free of the rightful claim of any third person regarding infringement
* or the like. Any license provided herein, whether implied or
* otherwise, applies only to this software file. Patent licenses, if
* any, provided herein do not apply to combinations of this program with
* other software, or any other product whatsoever.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
* Mountain View, CA 94043, or:
*
* http://www.sgi.com
*
* For further information regarding this notice, see:
*
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
*
*/
/*------------------------------------------------------------
* This is an example from The Inventor Mentor
* chapter 17, example 1.
*
* This examples shows how the user can create a custom
* X visual for doing color index rendering with
* an Inventor Viewer. This shows how to create the right
* visual, as well as load the color map with the wanted
* colors.
*-----------------------------------------------------------*/
#include <stdlib.h>
#include <Inventor/SoDB.h>
#include <Inventor/SoInput.h>
#include <Inventor/nodes/SoNode.h>
#include <Inventor/Xt/SoXt.h>
#include <Inventor/Xt/viewers/SoXtExaminerViewer.h>
#include <GL/glx.h>
// window attribute list to create a color index visual.
// This will create a double buffered color index window
// with the maximum number of bits and a zbuffer.
int attribList[] = {
GLX_DOUBLEBUFFER,
GLX_BUFFER_SIZE, 1,
GLX_DEPTH_SIZE, 1,
None };
// list of colors to load in the color map
static float colors[3][3] = {{.2, .2, .2}, {.5, 1, .5}, {.5, .5, 1}};
static char *sceneBuffer = "\
#Inventor V2.0 ascii\n\
\
Separator { \
LightModel { model BASE_COLOR } \
ColorIndex { index 1 } \
Coordinate3 { point [ -1 -1 -1, -1 1 -1, 1 1 1, 1 -1 1] } \
FaceSet {} \
ColorIndex { index 2 } \
Coordinate3 { point [ -1 -1 1, -1 1 1, 1 1 -1, 1 -1 -1] } \
FaceSet {} \
} ";
int
main(int , char **argv)
{
// Initialize Inventor and Xt
Widget myWindow = SoXt::init(argv[0]);
// read the scene graph in
SoInput in;
SoNode *scene;
in.setBuffer((void *)sceneBuffer, (size_t) strlen(sceneBuffer));
if (! SoDB::read(&in, scene) || scene == NULL) {
printf("Couldn't read scene\n");
exit(1);
}
// create the color index visual
XVisualInfo *vis = glXChooseVisual(XtDisplay(myWindow),
XScreenNumberOfScreen(XtScreen(myWindow)), attribList);
if (! vis) {
printf("Couldn't create visual\n");
exit(1);
}
// allocate the viewer, set the scene, the visual and
// load the color map with the wanted colors.
//
// Color 0 will be used for the background (default) while
// color 1 and 2 are used by the objects.
//
SoXtExaminerViewer *myViewer = new SoXtExaminerViewer(myWindow);
myViewer->setNormalVisual(vis);
myViewer->setColorMap(0, 3, (SbColor *) colors);
myViewer->setSceneGraph(scene);
myViewer->setTitle("Color Index Mode");
// Show the viewer and loop forever...
myViewer->show();
XtRealizeWidget(myWindow);
SoXt::mainLoop();
}
| 33.429752 | 77 | 0.658591 | [
"model"
] |
eb5efa75036c94d61cf87d8d01fbeabaedf99075 | 1,621 | cpp | C++ | Mockvita2/DigitPairs.cpp | sachanakshat/Competitive_Practice | 63170d87398bf5bd163febecdcfef8db21c632c7 | [
"MIT"
] | null | null | null | Mockvita2/DigitPairs.cpp | sachanakshat/Competitive_Practice | 63170d87398bf5bd163febecdcfef8db21c632c7 | [
"MIT"
] | null | null | null | Mockvita2/DigitPairs.cpp | sachanakshat/Competitive_Practice | 63170d87398bf5bd163febecdcfef8db21c632c7 | [
"MIT"
] | null | null | null | #include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <chrono>
#include <string>
using namespace std;
using namespace std::chrono;
#include <bits/stdc++.h>
using namespace std;
void show(int arr[], int n)
{
cout<<"\n------------------------"<<endl;
for(int i=0; i<n; i++)
{
cout<<arr[i]<<" ";
}
cout<<"\n------------------------"<<endl;
}
int bitscore(int n)
{
int h,t,o;
o = n%10;
n/=10;
t = n%10;
n/=10;
h = n%10;
n/=10;
int maxi = max(h,max(t,o));
int mini = min(h,min(t,o));
int sum = maxi*11 + mini*7;
return sum%100;
}
int main()
{
int n,inp,i;
cin>>n;
int *bs = (int*)malloc(sizeof(int)*n);
// int bs[n];
for(i=0; i<n; i++)
{
cin>>inp;
bs[i] = bitscore(inp); //Bitscores calculated
}
vector<int> oddb,evenb;
for(i=0; i<n; i++)
{
if(i%2==0)
{
evenb.push_back(bs[i]);
}
else
{
oddb.push_back(bs[i]);
}
}
//Odd and even indices separated
int o[10]={0}, e[10]={0}, oe[10];
int siz1 = oddb.size();
int siz2 = evenb.size();
for(i=0; i<siz1; i++)
o[oddb[i]/10]++;
for(i=0; i<siz2; i++)
e[evenb[i]/10]++;
//Number of digits in odd and even arrays
for(i=0; i<10; i++)
{
int t1 = o[i];
int t2 = e[i];
oe[i] = (t1*(t1-1))/2 + (t2*(t2-1))/2;
if(oe[i]>=2)
oe[i] = 2;
}
int sum=0;
for(i=0;i<10; i++)
{
sum+=oe[i];
}
cout<<sum;
return 0;
} | 17.813187 | 54 | 0.436767 | [
"vector"
] |
eb60078ff599694defd0d4e38588dd1c55f07cf0 | 8,614 | cpp | C++ | src/MainFunctions.cpp | adslbarxatov/OpenGLSample | 581a6da9da78c662f8fb403b0f8876170803c2dd | [
"MIT"
] | null | null | null | src/MainFunctions.cpp | adslbarxatov/OpenGLSample | 581a6da9da78c662f8fb403b0f8876170803c2dd | [
"MIT"
] | null | null | null | src/MainFunctions.cpp | adslbarxatov/OpenGLSample | 581a6da9da78c662f8fb403b0f8876170803c2dd | [
"MIT"
] | null | null | null | // Общая библиотека
#include "OpenGLSample.h"
// Указатель на 3D-объект
GLUquadricObj *QObj;
// Пусковая консольная функция
void main (void)
{
// Матрицы материала
GLfloat Mat_AmDf[] = {0.0f, 0.0f, 0.0f, 1.0f}, // Матрица света и диффузии
Mat_Spec[] = {1.0f, 1.0f, 1.0f, 1.0f}, // Матрица зеркальности
Mat_Emis[] = {0.0f, 0.0f, 0.0f, 1.0f}, // Матрица внутреннего света
Shin = 75.0; // Блеск ([0; 128]; чем меньше, тем ярче
// Матрицы освещения
GLfloat Pos[4] = {5.0, 5.0, 5.0f}, // Позиции осветителей
Dir[3] = {-1.0, -1.0, -1.0f}, // Их направление
Amb_Color[4] = {1.0f, 1.0f, 1.0f, 1.0f}, // Цвет освещения
Attn = 1.5f; // Ослабление
// Выдача справки по клавиатуре
printf ("\n Keyboard usage:\n");
printf (" \x18\x19\x1A\x1B - model roration;\n");
printf (" 1 / 2 - model zoom in / out;\n");
printf (" 4 / 5 - acceleration / deceleration of rings rotation\n");
printf (" (negative speed = rotation reverse);\n");
printf (" Mouse - model rotation");
printf ("\n\n Press any key to continue...");
_getch ();
// Инициализация окна
auxInitPosition (WX0, WY0, WXM, WYM); // Стартовая позиция окна
auxInitDisplayMode (AUX_RGB | AUX_DEPTH | AUX_DOUBLE); // Формат окна
auxInitWindow (WTITLE); // Заголовок окна
// Функции отображения
auxIdleFunc (Display); // Отображение
auxReshapeFunc (Resize); // Изменение размеров окна
// Главный осветитель и включение дополнительных прожекторов
glEnable (GL_LIGHTING); // Включение режима освещения
glEnable (GL_LIGHT0); // Номер осветителя
glEnable (GL_DEPTH_TEST); // Включение света
// Параметры материала
glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, Mat_AmDf);
glMaterialfv (GL_FRONT_AND_BACK, GL_SPECULAR, Mat_Spec);
glMaterialfv (GL_FRONT_AND_BACK, GL_EMISSION, Mat_Emis); // Внутренний свет
glMaterialf (GL_FRONT_AND_BACK, GL_SHININESS, Shin);
glEnable (GL_COLOR_MATERIAL); // Включение цвета материала
// Параметры осветителя
glLightfv (GL_LIGHT0, GL_POSITION, Pos); // Позиция
glLightfv (GL_LIGHT0, GL_SPOT_DIRECTION, Dir); // Направление
glLightfv (GL_LIGHT0, GL_AMBIENT, Amb_Color); // Цвет осветителя
glLightfv (GL_LIGHT0, GL_SPECULAR, Amb_Color); // Блеск
glLightf (GL_LIGHT0, GL_LINEAR_ATTENUATION, Attn); // Ослабление
// Функции обработки клавиш (описаны в BaseFunctions)
auxKeyFunc (AUX_LEFT, Key_LEFT);
auxKeyFunc (AUX_RIGHT, Key_RIGHT);
auxKeyFunc (AUX_UP, Key_UP);
auxKeyFunc (AUX_DOWN, Key_DOWN);
auxKeyFunc ('1', Key_ZoomIn);
auxKeyFunc ('2', Key_ZoomOut);
auxKeyFunc ('4', Key_SpeedUp);
auxKeyFunc ('5', Key_SpeedDown);
// Функция обработки мыши
auxMouseFunc (AUX_LEFTBUTTON, AUX_MOUSELOC, MouseMove);
// Функция рисования (цикл)
auxMainLoop (Display);
}
// Главная функция отображения
void CALLBACK Display (void)
{
// Вращение
Angle (Speed (0));
// Очистка экрана
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glClearColor (BACKGROUND_COLOR, 0.0f); // Цвет фона
glPushMatrix ();
// Направления вращения и исходная позиция
glRotated (Alpha (0), 0, 1, 0);
glRotated (Beta (0), 1, 0, 0);
glRotated (45, 0, -1, 0);
// Подключение и наложение цвета
QObj = gluNewQuadric ();
gluQuadricDrawStyle (QObj, GLU_FILL);
////////////////////////////////
// С-образные опоры
glColor3d (FRAMES_COLOR);
glTranslated (0.0, 0.0, -RING_HEIGHT);
glRotated (180, 1, 0, 0);
gluPartialDisk (QObj, RADIUS1 + 1.0, RADIUS1 + 2.0, RESOLUTION, RESOLUTION, 225, 180);
glTranslated (0.0, 0.0, -(RING_HEIGHT + 0.01)); // Отрицательное смещение из-за разворота
gluPartialDisk (QObj, RADIUS1 + 1.0, RADIUS1 + 2.0, RESOLUTION, RESOLUTION, 225, 180);
glTranslated (0.0, 0.0, -RING_HEIGHT); // Отрицательное смещение из-за разворота
gluPartialDisk (QObj, RADIUS1 + 1.0, RADIUS1 + 2.0, RESOLUTION, RESOLUTION, 225, 180);
glRotated (180, -1, 0, 0);
glTranslated (0.0, 0.0, 0.01);
gluPartialDisk (QObj, RADIUS1 + 1.0, RADIUS1 + 2.0, RESOLUTION, RESOLUTION, 135, 180);
glTranslated (0.0, 0.0, -RING_HEIGHT + 0.01);
gluPartialDisk (QObj, RADIUS1 + 1.0, RADIUS1 + 2.0, RESOLUTION, RESOLUTION, 135, 180);
glTranslated (0.0, 0.0, -RING_HEIGHT);
gluPartialDisk (QObj, RADIUS1 + 1.0, RADIUS1 + 2.0, RESOLUTION, RESOLUTION, 135, 180);
glTranslated (0.0, 0.0, RING_HEIGHT - 0.01);
// Держатели внешнего кольца
glRotated (45, 0, 0, 1);
glTranslated (0.0, (RADIUS1 + 1.5), 0.0);
auxSolidBox (1.0, 1.0, 2 * RING_HEIGHT);
glTranslated (0.0, -2 * (RADIUS1 + 1.5), 0.0);
auxSolidBox (1.0, 1.0, 2 * RING_HEIGHT);
glTranslated (0.0, (RADIUS1 + 1.5), 0.0);
glRotated (45, 0, 0, -1);
// Опора и площадка
glTranslated (0.0, -(RADIUS1 + 2.0), 0.0);
auxSolidBox (2.0, 2.0, 2 * RING_HEIGHT);
glColor3d (BASE_COLOR);
glTranslated (0.0, -1.0, 0.0);
auxSolidBox (4.0, RING_HEIGHT, 7.0);
glTranslated (0.0, (RADIUS1 + 3.0), 0.0);
////////////////////////////////
// Внешнее кольцо
glColor3d (RING1_COLOR);
glRotated (45, 0, 0, 1);
glTranslated (0, RADIUS1, 0);
glRotated (90, -1, 0, 0);
gluCylinder (QObj, RING_HEIGHT / 2.0, RING_HEIGHT / 2.0, 1.0, RESOLUTION, RESOLUTION);
glRotated (90, 1, 0, 0);
glTranslated (0, -2 * RADIUS1, 0);
glRotated (90, 1, 0, 0);
gluCylinder (QObj, RING_HEIGHT / 2.0, RING_HEIGHT / 2.0, 1.0, RESOLUTION, RESOLUTION);
glRotated (90, -1, 0, 0);
glTranslated (0, RADIUS1, 0);
// Начало внешнего вращения
glRotated (RING1_ANGLE_OFFSET * Angle (0), 0, 1, 0);
// Внешнее кольцо
Ring (QObj, RADIUS1, RING_WIDTH, RING_HEIGHT, RESOLUTION);
// Возврат внешней опоры
glRotated (45, 0, 0, -1);
////////////////////////////////
// Средняя опора
glColor3d (RING2_COLOR);
glRotated (-45, 0, 0, 1);
glTranslated (0, RADIUS2 - RING_WIDTH, 0);
glRotated (90, -1, 0, 0);
gluCylinder (QObj, RING_HEIGHT / 2.0, RING_HEIGHT / 2.0, RADIUS1 - RADIUS2, RESOLUTION, RESOLUTION);
glRotated (90, 1, 0, 0);
glTranslated (0, -2 * (RADIUS2 - RING_WIDTH), 0);
glRotated (90, 1, 0, 0);
gluCylinder (QObj, RING_HEIGHT / 2.0, RING_HEIGHT / 2.0, RADIUS1 - RADIUS2, RESOLUTION, RESOLUTION);
glRotated (90, -1, 0, 0);
glTranslated (0, RADIUS2 - RING_WIDTH, 0);
// Начало внутреннего вращения
glRotated (RING2_ANGLE_OFFSET * Angle (0), 0, 1, 0);
// Какой-нибудь неточный коэффициент (для эффекта случайности)
// Кольцо
Ring (QObj, RADIUS2, RING_WIDTH, RING_HEIGHT, RESOLUTION);
// Возврат опоры
glRotated (-45, 0, 0, -1);
////////////////////////////////
// Внутренняя опора
glColor3d (RING3_COLOR);
glRotated (45, 0, 0, 1);
glTranslated (0, RADIUS3 - RING_WIDTH, 0);
glRotated (90, -1, 0, 0);
gluCylinder (QObj, RING_HEIGHT / 2.0, RING_HEIGHT / 2.0, RADIUS2 - RADIUS3, RESOLUTION, RESOLUTION);
glRotated (90, 1, 0, 0);
glTranslated (0, -2 * (RADIUS3 - RING_WIDTH), 0);
glRotated (90, 1, 0, 0);
gluCylinder (QObj, RING_HEIGHT / 2.0, RING_HEIGHT / 2.0, RADIUS2 - RADIUS3, RESOLUTION, RESOLUTION);
glRotated (90, -1, 0, 0);
glTranslated (0, RADIUS3 - RING_WIDTH, 0);
// Начало внутреннего вращения
glRotated (RING3_ANGLE_OFFSET * Angle (0), 0, 1, 0);
// Внутреннее кольцо
Ring (QObj, RADIUS3, RING_WIDTH, RING_HEIGHT, RESOLUTION);
// Возврат внутренней опоры
glRotated (45, 0, 0, -1);
////////////////////////////////
// Конец внутреннего вращения
glRotated (RING3_ANGLE_OFFSET * Angle (0), 0, -1, 0);
////////////////////////////////
// Конец среднего вращения
glRotated (RING2_ANGLE_OFFSET * Angle (0), 0, -1, 0);
////////////////////////////////
// Конец внешнего вращения
glRotated (RING1_ANGLE_OFFSET * Angle (0), 0, -1, 0);
// Завершение
glFlush ();
gluDeleteQuadric (QObj);
glPopMatrix ();
auxSwapBuffers ();
}
// Функция изображения кольца
void Ring (GLUquadricObj *QO, double Radius, double Width, double Height, int Resolution)
{
// Верхняя крышка
glTranslated (0.0, 0.0, Height / 2); // Задание точки отображения
gluDisk (QO, Radius - Width, Radius, Resolution, Resolution);
// Нижняя крышка
glTranslated (0.0, 0.0, -Height);
glRotated (180, 1, 0, 0);
gluDisk (QO, Radius - Width, Radius, Resolution, Resolution);
glRotated (180, -1, 0, 0);
glTranslated (0.0, 0.0, Height / 2);
// Цилиндры
glTranslated (0.0, 0.0, -Height / 2);
gluCylinder (QO, Radius, Radius, Height, Resolution, Resolution);
gluCylinder (QO, Radius - Width, Radius - Width, Height, Resolution, Resolution);
glTranslated (0.0, 0.0, Height / 2);
}
| 34.874494 | 104 | 0.640121 | [
"model",
"3d"
] |
eb6212fa18c3479c9aea6a65f4e842fdb2f83d88 | 2,178 | cpp | C++ | src/ufrn_lp1/lab5/src/main.cpp | Mazuh/MISC-Algs | 7fccb3d4eb27a2511bda4b1e408ab96b0cccd5ae | [
"MIT"
] | 3 | 2017-04-25T19:36:22.000Z | 2018-02-08T18:22:44.000Z | src/ufrn_lp1/lab5/src/main.cpp | Mazuh/MISC-Algs | 7fccb3d4eb27a2511bda4b1e408ab96b0cccd5ae | [
"MIT"
] | 1 | 2017-04-26T10:15:26.000Z | 2017-04-26T12:19:11.000Z | src/ufrn_lp1/lab5/src/main.cpp | Mazuh/MISC-Algs | 7fccb3d4eb27a2511bda4b1e408ab96b0cccd5ae | [
"MIT"
] | 1 | 2017-04-25T23:59:48.000Z | 2017-04-25T23:59:48.000Z | #include <iostream>
#include <algorithm>
#include <vector>
#include <list>
#include <set>
#include "questao1.hpp"
#include "questao2.hpp"
#include "questao3.hpp"
using std::cout;
using std::endl;
void test_q1();
void test_q2();
void test_q3();
/**
* @brief Execução principal, rodando os testes das questões.
*/
int main(){
cout << "LAB5/LP1" << endl << endl;
test_q1();
cout << endl;
test_q2();
cout << endl;
test_q3();
return 0;
}
/**
* @brief Questão 1.
*/
void test_q1(){
cout << "Testes unitários da `closest2mean`" << endl;
cout << "Cenário com vector... ";
std::vector<int> v = {1, 2, 3, 30, 40, 50};
auto rv = *closest2mean(v.begin(), v.end());
if (rv == 30)
cout << "OK." << endl;
else
cout << "Falhou. Esperava 30, obteve " << rv << "." << endl;
cout << "Cenário com set... ";
std::set<int> s = {50, 40, 30, 3, 2, 1};
auto rs = *closest2mean(s.begin(), s.end());
if (rs == 30)
cout << "OK." << endl;
else
cout << "Falhou. Esperava 30. " << rs << "." << endl;
cout << "Cenário com list... ";
std::list<float> l = {5.5, 355, 42, 30, -1};
auto rl = *closest2mean(l.begin(), l.end());
if (rl == 42)
cout << "OK." << endl;
else
cout << "Falhou. Esperava 42 (keep calm!), obteve " << rl << "." << endl;
}
/**
* @brief Questão 2.
*/
void test_q2(){
cout << "Testes de impressão da `print_numbers`" << endl;
std::set<int> numbers;
numbers.insert(3);
numbers.insert(1);
numbers.insert(4);
numbers.insert(1);
numbers.insert(2);
numbers.insert(5);
print_elements(numbers, "Set: ");
print_elements(numbers, "CSV Set: ", ';');
}
/**
* @brief Questão 3.
*/
void test_q3(){
cout << "Testes de impressão com uso do predicado `isPrime`" << endl;
std::vector<int> v = {0, 1, 22, 2, 3, 30, 40, 11, 50, 13, 15, 80, 101};
isPrime isPrime;
auto found = std::find_if(v.begin(), v.end(), isPrime);
while (found != v.end()){
cout << *found << ' ';
std::advance(found, 1);
found = std::find_if(found, v.end(), isPrime);
}
cout << endl;
}
| 22.926316 | 81 | 0.536272 | [
"vector"
] |
eb62d293e3da2020eaffadd369f3c2e9128f81ce | 2,407 | cpp | C++ | kickstart/2021D/D.cpp | s9v/toypuct | 68e65e6da5922af340de72636a9a4f136454c70d | [
"MIT"
] | null | null | null | kickstart/2021D/D.cpp | s9v/toypuct | 68e65e6da5922af340de72636a9a4f136454c70d | [
"MIT"
] | null | null | null | kickstart/2021D/D.cpp | s9v/toypuct | 68e65e6da5922af340de72636a9a4f136454c70d | [
"MIT"
] | null | null | null | #include <iostream>
#include <vector>
using namespace std;
typedef long long i64;
const i64 LARGE = 1000LL * 1000 * 1000 * 1000;
i64 pow[41];
struct FenwickTree {
vector<int> bit;
int n;
FenwickTree(int n) {
this->n = n;
bit.assign(n, 0);
}
FenwickTree(vector<int> a) : FenwickTree(a.size()) {
for (size_t i = 0; i < a.size(); i++)
add(i, a[i]);
}
int sum(int r) {
int ret = 0;
for (; r >= 0; r = (r & (r + 1)) - 1)
ret += bit[r];
return ret;
}
int sum(int l, int r) {
return sum(r) - sum(l - 1);
}
void add(int idx, int delta) {
for (; idx < n; idx = idx | (idx + 1))
bit[idx] += delta;
}
void set(int idx, int val) {
int delta = val - (sum(idx) - sum(idx-1));
add(idx, delta);
}
};
int V(i64 x) {
int lo = 0, hi = 40;
int ans = lo;
while (lo <= hi) {
int mi = (lo + hi)/2;
if (x % pow[mi] == 0) {
ans = max(ans, mi);
lo = mi+1;
} else {
hi = mi-1;
}
}
return ans;
}
int main() {
std::ios_base::sync_with_stdio(false);
int tests;
cin >> tests;
for (int caseno = 1; caseno <= tests; caseno++) {
int n, q, p;
cin >> n >> q >> p;
vector<FenwickTree> fts(4, FenwickTree(n));
vector<int> a(n);
for (int i = 0; i < n; i++) {
int pos, val, val_mod;
pos = i;
cin >> val;
val_mod = val % p;
i64 val_pow = 1LL;
i64 val_mod_pow = 1LL;
for (int i = 0; i < 4; i++) {
val_pow *= val;
val_mod_pow *= val_mod;
fts[i].set(pos, V(val_pow - val_mod_pow));
}
}
pow[0] = 1;
for (int i = 1; i <= 40; i++) {
if (pow[i-1] != LARGE + 1 && pow[i-1]*p <= LARGE)
pow[i] = pow[i-1]*p;
else
pow[i] = LARGE + 1;
}
cout << "Case #" << caseno << ": ";
for (int query = 0; query < q; query++) {
int type;
cin >> type;
if (type == 1) {
int pos, val, val_mod;
cin >> pos >> val;
val_mod = val % p;
i64 val_pow = 1LL;
i64 val_mod_pow = 1LL;
for (int i = 0; i < 4; i++) {
val_pow *= val;
val_mod_pow *= val_mod;
fts[i].set(pos, V(val_pow - val_mod_pow));
}
} else if (type == 2) {
int s, l, r;
cin >> s >> l >> r;
cout << fts[s-1].sum(l-1, r-1) << " ";
}
}
cout << endl;
}
return 0;
}
| 18.952756 | 55 | 0.452015 | [
"vector"
] |
eb65443e36beda111c2c2dfc3d4125692640f753 | 8,850 | hh | C++ | src/common/Mesh.hh | nherment/gazebo | fff0aa30b4b5748e43c2b0aa54ffcd366e9f042a | [
"ECL-2.0",
"Apache-2.0"
] | 5 | 2016-01-17T20:41:39.000Z | 2018-05-01T12:02:58.000Z | src/common/Mesh.hh | nherment/gazebo | fff0aa30b4b5748e43c2b0aa54ffcd366e9f042a | [
"ECL-2.0",
"Apache-2.0"
] | null | null | null | src/common/Mesh.hh | nherment/gazebo | fff0aa30b4b5748e43c2b0aa54ffcd366e9f042a | [
"ECL-2.0",
"Apache-2.0"
] | 5 | 2015-09-29T02:30:16.000Z | 2022-03-30T12:11:22.000Z | /*
* Copyright 2011 Nate Koenig & Andrew Howard
*
* 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.
*
*/
#ifndef MESH_HH
#define MESH_HH
#include <vector>
#include <string>
#include "math/Vector3.hh"
#include "math/Vector2d.hh"
namespace gazebo
{
namespace common
{
class Material;
class SubMesh;
class Skeleton;
/// \addtogroup gazebo_common Common
/// \{
/// \brief A 3D mesh
class Mesh
{
/// \brief Constructor
public: Mesh();
/// \brief Destructor
public: virtual ~Mesh();
/// \brief Set the path which contains the mesh resource
public: void SetPath(const std::string &_path);
/// \brief Get the path which contains the mesh resource
public: std::string GetPath() const;
/// \brief Set the name of this mesh
public: void SetName(const std::string &_n);
/// \brief Get the name of this mesh
public: std::string GetName() const;
/// \brief Get the maximun X, Y, Z values
public: math::Vector3 GetMax() const;
/// \brief Get the minimum X, Y, Z values
public: math::Vector3 GetMin() const;
/// \brief Return the number of vertices
public: unsigned int GetVertexCount() const;
/// \brief Return the number of normals
public: unsigned int GetNormalCount() const;
/// \brief Return the number of indicies
public: unsigned int GetIndexCount() const;
/// \brief Return the number of texture coordinates
public: unsigned int GetTexCoordCount() const;
/// \brief Add a submesh mesh
public: void AddSubMesh(SubMesh *_child);
/// \brief Get the number of children
public: unsigned int GetSubMeshCount() const;
/// \brief Add a material to the mesh
/// \return Index of this material
public: unsigned int AddMaterial(Material *_mat);
/// \brief Get the number of materials
public: unsigned int GetMaterialCount() const;
/// \brief Get a material
public: const Material *GetMaterial(int index) const;
/// \brief Get a child
public: const SubMesh *GetSubMesh(unsigned int i) const;
/// \brief Put all the data into flat arrays
public: void FillArrays(float **_vertArr, int **_indArr) const;
/// \brief Recalculate all the normals.
public: void RecalculateNormals();
/// \brief Get AABB coordinate
public: void GetAABB(math::Vector3 &_center, math::Vector3 &_min_xyz,
math::Vector3 &_max_xyz) const;
/// \brief Generate texture coordinates using spherical projection
/// from center
public: void GenSphericalTexCoord(const math::Vector3 &_center);
/// \brief Get the skeleton to which this mesh is attached.
/// \return pointer to skeleton, or NULL if none is present.
public: Skeleton* GetSkeleton() const;
/// \brief Set the mesh skeleton
public: void SetSkeleton(Skeleton *_skel);
/// \brief Return true if mesh is attached to a skeleton.
public: bool HasSkeleton() const;
private: std::string name;
private: std::string path;
private: std::vector<SubMesh *> submeshes;
private: std::vector<Material *> materials;
private: Skeleton *skeleton;
};
struct NodeAssignment
{
unsigned int vertexIndex;
unsigned int nodeIndex;
float weight;
};
/// \brief A child mesh
class SubMesh
{
public: enum PrimitiveType {POINTS, LINES, LINESTRIPS, TRIANGLES,
TRIFANS, TRISTRIPS};
/// \brief Constructor
public: SubMesh();
/// \brief Destructor
public: virtual ~SubMesh();
/// \brief Set the primitive type
public: void SetPrimitiveType(PrimitiveType _type);
/// \brief Get the primitive type
public: PrimitiveType GetPrimitiveType() const;
/// \brief Copy vertices from a vector
public: void CopyVertices(const std::vector<math::Vector3> &_verts);
/// \brief Copy normals from a vector
public: void CopyNormals(const std::vector<math::Vector3> &_norms);
/// \brief Resize the vertex array
public: void SetVertexCount(unsigned int _count);
/// \brief Resize the index array
public: void SetIndexCount(unsigned int _count);
/// \brief Resize the normal array
public: void SetNormalCount(unsigned int _count);
/// \brief Resize the texture coordinate array
public: void SetTexCoordCount(unsigned int _count);
/// \brief Add an index to the mesh
public: void AddIndex(unsigned int _i);
/// \brief Add a vertex to the mesh
public: void AddVertex(const math::Vector3 &_v);
/// \brief Add a vertex to the mesh
public: void AddVertex(double _x, double _y, double _z);
/// \brief Add a normal to the mesh
public: void AddNormal(const math::Vector3 &_n);
/// \brief Add a normal to the mesh
public: void AddNormal(double _x, double _y, double _z);
/// \brief Add a texture coord to the mesh
public: void AddTexCoord(double _u, double _v);
/// \brief Add a vertex - skeleton node assignment
public: void AddNodeAssignment(unsigned int _vertex, unsigned int _node,
float _weight);
/// \brief Get a vertex
public: math::Vector3 GetVertex(unsigned int _i) const;
/// \brief Set a vertex
public: void SetVertex(unsigned int _i, const math::Vector3 &_v);
/// \brief Get a normal
public: math::Vector3 GetNormal(unsigned int _i) const;
/// \brief Set a normal
public: void SetNormal(unsigned int _i, const math::Vector3 &_n);
/// \brief Get a tex coord
public: math::Vector2d GetTexCoord(unsigned int _i) const;
/// \brief Get a vertex - skeleton node assignment
public: NodeAssignment GetNodeAssignment(unsigned int _i) const;
/// \brief Set a tex coord
public: void SetTexCoord(unsigned int _i, const math::Vector2d &_t);
/// \brief Get an index
public: unsigned int GetIndex(unsigned int _i) const;
/// \brief Get the maximun X, Y, Z values
public: math::Vector3 GetMax() const;
/// \brief Get the minimum X, Y, Z values
public: math::Vector3 GetMin() const;
/// \brief Return the number of vertices
public: unsigned int GetVertexCount() const;
/// \brief Return the number of normals
public: unsigned int GetNormalCount() const;
/// \brief Return the number of indicies
public: unsigned int GetIndexCount() const;
/// \brief Return the number of texture coordinates
public: unsigned int GetTexCoordCount() const;
/// \brief Return the number of vertex - skeleton node assignments
public: unsigned int GetNodeAssignmentsCount() const;
/// \brief Get the highest index value
public: unsigned int GetMaxIndex() const;
/// \brief Set the material index. Relates to the parent mesh material
/// list
public: void SetMaterialIndex(unsigned int _index);
/// \brief Get the material index
public: unsigned int GetMaterialIndex() const;
/// \brief Return true if this submesh has the vertex
public: bool HasVertex(const math::Vector3 &_v) const;
/// \brief Get the index of the vertex
public: unsigned int GetVertexIndex(const math::Vector3 &_v) const;
/// \brief Put all the data into flat arrays
public: void FillArrays(float **_vertArr, int **_indArr) const;
/// \brief Recalculate all the normals.
public: void RecalculateNormals();
/// \brief Reset mesh center to geometric center
public: void SetSubMeshCenter(math::Vector3 _center);
/// \brief Generate texture coordinates using spherical projection
/// from center
public: void GenSphericalTexCoord(const math::Vector3 &_center);
private: std::vector< math::Vector3 > vertices;
private: std::vector< math::Vector3 > normals;
private: std::vector< math::Vector2d > texCoords;
private: std::vector<unsigned int> indices;
private: std::vector<NodeAssignment> nodeAssignments;
private: PrimitiveType primitiveType;
private: int materialIndex;
};
/// \}
}
}
#endif
| 31.72043 | 78 | 0.649831 | [
"mesh",
"vector",
"3d"
] |
eb669c81bc8de21111f9c579c465571b318cee4c | 6,932 | cc | C++ | web_transport/sdk/impl/web_transport_server_session.cc | seaoverall/owt-sdk-quic | 5c6919e8fcaaa8916942b2e13056fd36044c1767 | [
"Apache-2.0"
] | 37 | 2019-04-26T02:46:53.000Z | 2021-05-18T05:58:16.000Z | web_transport/sdk/impl/web_transport_server_session.cc | seaoverall/owt-sdk-quic | 5c6919e8fcaaa8916942b2e13056fd36044c1767 | [
"Apache-2.0"
] | 5 | 2020-12-01T05:54:00.000Z | 2021-03-24T02:16:39.000Z | web_transport/sdk/impl/web_transport_server_session.cc | seaoverall/owt-sdk-quic | 5c6919e8fcaaa8916942b2e13056fd36044c1767 | [
"Apache-2.0"
] | 24 | 2019-04-28T02:59:39.000Z | 2021-01-29T09:46:48.000Z | /*
* Copyright (C) 2021 Intel Corporation
*
* SPDX-License-Identifier: Apache-2.0
*/
// Copyright (c) 2019 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.
// Most classes in this file and its implementations are borrowed from
// Chromium/net/third_party/quiche/src/quic/tools/quic_simple_server_session.cc
// with modifications.
#include "impl/web_transport_server_session.h"
#include <vector>
#include "impl/web_transport_stream_impl.h"
#include "net/third_party/quiche/src/quic/core/http/quic_server_initiated_spdy_stream.h"
#include "net/third_party/quiche/src/quic/core/http/quic_spdy_stream.h"
#include "owt/web_transport/sdk/impl/utilities.h"
namespace owt {
namespace quic {
// Copied from net/quic/dedicated_web_transport_http3_client.cc.
class WebTransportVisitorProxy : public ::quic::WebTransportVisitor {
public:
explicit WebTransportVisitorProxy(::quic::WebTransportVisitor* visitor)
: visitor_(visitor) {}
void OnSessionReady() override { visitor_->OnSessionReady(); }
void OnIncomingBidirectionalStreamAvailable() override {
visitor_->OnIncomingBidirectionalStreamAvailable();
}
void OnIncomingUnidirectionalStreamAvailable() override {
visitor_->OnIncomingUnidirectionalStreamAvailable();
}
void OnDatagramReceived(absl::string_view datagram) override {
visitor_->OnDatagramReceived(datagram);
}
void OnCanCreateNewOutgoingBidirectionalStream() override {
visitor_->OnCanCreateNewOutgoingBidirectionalStream();
}
void OnCanCreateNewOutgoingUnidirectionalStream() override {
visitor_->OnCanCreateNewOutgoingUnidirectionalStream();
}
private:
::quic::WebTransportVisitor* visitor_;
};
WebTransportServerSession::WebTransportServerSession(
::quic::WebTransportHttp3* session,
::quic::QuicSpdySession* http3_session,
base::SingleThreadTaskRunner* io_runner,
base::SingleThreadTaskRunner* event_runner)
: session_(session),
http3_session_(http3_session),
io_runner_(io_runner),
event_runner_(event_runner),
visitor_(nullptr) {
CHECK(session_);
CHECK(http3_session_);
CHECK(io_runner_);
CHECK(event_runner_);
session_->SetVisitor(std::make_unique<WebTransportVisitorProxy>(this));
}
WebTransportServerSession::~WebTransportServerSession() {}
WebTransportStreamInterface*
WebTransportServerSession::CreateBidirectionalStream() {
if (io_runner_->BelongsToCurrentThread()) {
return CreateBidirectionalStreamOnCurrentThread();
}
WebTransportStreamInterface* result(nullptr);
base::WaitableEvent done(base::WaitableEvent::ResetPolicy::AUTOMATIC,
base::WaitableEvent::InitialState::NOT_SIGNALED);
io_runner_->PostTask(
FROM_HERE,
base::BindOnce(
[](WebTransportServerSession* session,
WebTransportStreamInterface** result, base::WaitableEvent* event) {
*result = session->CreateBidirectionalStreamOnCurrentThread();
event->Signal();
},
base::Unretained(this), base::Unretained(&result),
base::Unretained(&done)));
done.Wait();
return result;
}
MessageStatus WebTransportServerSession::SendOrQueueDatagram(uint8_t* data,
size_t length) {
DCHECK(http3_session_ && http3_session_->connection() &&
http3_session_->connection()->helper());
auto* allocator =
http3_session_->connection()->helper()->GetStreamSendBufferAllocator();
::quic::QuicBuffer buffer = ::quic::QuicBuffer::Copy(
allocator, absl::string_view(reinterpret_cast<char*>(data), length));
if (io_runner_->BelongsToCurrentThread()) {
auto message_result =
session_->SendOrQueueDatagram(::quic::QuicMemSlice(std::move(buffer)));
return Utilities::ConvertMessageStatus(message_result);
}
MessageStatus result;
base::WaitableEvent done(base::WaitableEvent::ResetPolicy::AUTOMATIC,
base::WaitableEvent::InitialState::NOT_SIGNALED);
io_runner_->PostTask(
FROM_HERE,
base::BindOnce(
[](WebTransportServerSession* session, ::quic::QuicMemSlice slice,
MessageStatus& result, base::WaitableEvent* event) {
result = Utilities::ConvertMessageStatus(
session->session_->SendOrQueueDatagram(std::move(slice)));
event->Signal();
},
base::Unretained(this), ::quic::QuicMemSlice(std::move(buffer)),
std::ref(result), base::Unretained(&done)));
done.Wait();
return result;
}
WebTransportStreamInterface*
WebTransportServerSession::CreateBidirectionalStreamOnCurrentThread() {
::quic::WebTransportStream* wt_stream =
session_->OpenOutgoingBidirectionalStream();
std::unique_ptr<WebTransportStreamInterface> stream =
std::make_unique<WebTransportStreamImpl>(
wt_stream,
http3_session_->GetOrCreateStream(wt_stream->GetStreamId()),
io_runner_, event_runner_);
WebTransportStreamInterface* stream_ptr(stream.get());
streams_.push_back(std::move(stream));
return stream_ptr;
}
uint64_t WebTransportServerSession::SessionId() const {
return session_->id();
}
const char* WebTransportServerSession::ConnectionId() const {
const std::string& session_id_str =
http3_session_->connection_id().ToString();
char* id = new char[session_id_str.size() + 1];
strcpy(id, session_id_str.c_str());
return id;
}
bool WebTransportServerSession::IsSessionReady() const {
// A WebTransport session is created after a HTTP/3 session is ready.
return true;
}
void WebTransportServerSession::SetVisitor(
WebTransportSessionInterface::Visitor* visitor) {
visitor_ = visitor;
}
const ConnectionStats& WebTransportServerSession::GetStats() {
const auto& stats = http3_session_->connection()->GetStats();
stats_.estimated_bandwidth = stats.estimated_bandwidth.ToBitsPerSecond();
return stats_;
}
void WebTransportServerSession::OnIncomingBidirectionalStreamAvailable() {
auto* stream = session_->AcceptIncomingBidirectionalStream();
AcceptIncomingStream(stream);
}
void WebTransportServerSession::OnIncomingUnidirectionalStreamAvailable() {
auto* stream = session_->AcceptIncomingUnidirectionalStream();
AcceptIncomingStream(stream);
}
void WebTransportServerSession::AcceptIncomingStream(
::quic::WebTransportStream* stream) {
LOG(INFO) << "Accept incoming stream.";
std::unique_ptr<WebTransportStreamInterface> wt_stream =
std::make_unique<WebTransportStreamImpl>(
stream, http3_session_->GetOrCreateStream(stream->GetStreamId()),
io_runner_, event_runner_);
WebTransportStreamInterface* stream_ptr = wt_stream.get();
streams_.push_back(std::move(wt_stream));
if (visitor_) {
visitor_->OnIncomingStream(stream_ptr);
}
}
} // namespace quic
} // namespace owt | 36.293194 | 88 | 0.731968 | [
"vector"
] |
eb68b3bd024edac5df5e7a3ef561dd6ce4288b94 | 1,086 | cpp | C++ | lib/huffman-lib/huffman_encryptor.cpp | mikeTerentev/huffman-archiver-cpp | 22ab230f5e4d4e71fc1da22e191ceac5b165a9af | [
"MIT"
] | null | null | null | lib/huffman-lib/huffman_encryptor.cpp | mikeTerentev/huffman-archiver-cpp | 22ab230f5e4d4e71fc1da22e191ceac5b165a9af | [
"MIT"
] | null | null | null | lib/huffman-lib/huffman_encryptor.cpp | mikeTerentev/huffman-archiver-cpp | 22ab230f5e4d4e71fc1da22e191ceac5b165a9af | [
"MIT"
] | null | null | null | //
// Created by Mike Terentyev on 09/05/18.
//
#include "huffman_encryptor.h"
Encryptor::Encryptor(Frequency const &frequency) : HuffmanAlgorithm(frequency) {};
void Encryptor::encode(Input_stream &reader, Output_stream &writer) {
auto const &codes = get_codes();
for (size_t i = 0; i < 256; i++) {
auto const &code = codes[i];
writer.write_ui8(static_cast<uint8_t>(i)); //char
writer.write_ui16(static_cast<uint16_t>(code.get_bit_size())); //bit_size
writer.write_ui16(static_cast<uint16_t>(code.get_data().size())); //data blocks
writer.write_vector_ui8(code.get_data());
}
while (!reader.isEof()) {
writer.write_encoded_symbol(encode_symbol(reader.read_ui8()));
}
writer.complete_buffer();
}
encoded_symbol const &Encryptor::encode_symbol(uint8_t c) {
return huffman_codes[c];
}
std::vector<encoded_symbol> Encryptor::encode_string(std::string const &data) {
std::vector<encoded_symbol> res;
for (char symbol : data) {
res.push_back(huffman_codes[symbol]);
}
return res;
}
| 27.846154 | 87 | 0.674033 | [
"vector"
] |
eb6db469194081414785a42b7b9528d37126a388 | 16,417 | cpp | C++ | SFDateTime.cpp | zswdjh/ECE180_Calendrical_Computations | dbc08a4c3be2a2d84be3441f92d4f8737ce9c850 | [
"MIT"
] | null | null | null | SFDateTime.cpp | zswdjh/ECE180_Calendrical_Computations | dbc08a4c3be2a2d84be3441f92d4f8737ce9c850 | [
"MIT"
] | null | null | null | SFDateTime.cpp | zswdjh/ECE180_Calendrical_Computations | dbc08a4c3be2a2d84be3441f92d4f8737ce9c850 | [
"MIT"
] | null | null | null | //
// SFDateTime.cpp
// my_assignment3
//
// Created by Jing Liang on 2/19/18.
// Copyright © 2018 Jing Liang. All rights reserved.
//
#include "SFDateTime.hpp"
#include <string>
#include <iostream>
#include <sstream>
#include <map>
namespace SoftwareFoundations{
SFDateTime::SFDateTime(SFTimezone *aTimezone):SFTime(),SFDate(){ //init a new datetime based on GMT, unless a valid timezone is provided
const char* GMT = "GMT";
SFTimezone gmt(GMT);
std::map<std::string,int> tzmap = { {"GMT",0},{"PST",-8},{"CST",-6},{"EST",-5} };
int timeadjust = 0;
if(aTimezone==nullptr){
SFDTzone.SFTZsetTimezone(GMT);
}
else{
timeadjust = tzmap.find("GMT")->second - tzmap.find(aTimezone->SFTZgetTimezone())->second;
adjustByHours(timeadjust);
SFDTzone.SFTZsetTimezone(GMT);
setTimezone(*aTimezone);
}
}
SFDateTime::SFDateTime(const SFDateTime &aCopy):SFTime(aCopy),SFDate(aCopy){
SFDTzone = aCopy.SFDTzone;
} //copy construct
SFDateTime::SFDateTime(int aMonth, int aDay, int aYear, int anHour, int aMinutes, int aSeconds, SFTimezone *aTimezone){
setDay(aDay);
setMonth(aMonth);
setYear(aYear);
setSecond(aSeconds);
setMinute(aMinutes);
setHour(anHour);
std::map<std::string,int> tzmap = { {"GMT",0},{"PST",-8},{"CST",-6},{"EST",-5} };
const char* GMT = "GMT";
SFTimezone gmt(GMT);
if(aTimezone==nullptr){
setTimezone(gmt);
}
else{
std::string current = aTimezone->SFTZgetTimezone(); //current timezone
int timeadjust = 0; //first to adjust to GMT time zone
timeadjust = tzmap.find("GMT")->second - tzmap.find(current)->second;
adjustByHours(timeadjust);
SFDTzone.SFTZsetTimezone(GMT);
setTimezone(*aTimezone);
}
}
SFDateTime::SFDateTime(const char* aString, SFTimezone *aTimezone){ //parse the given string of the form "MM/DD/YYYY HH:MM:SS"
if(isdigit(aString[0])){
std::stringstream fullstring(aString); //separate MM/DD/YYYY and HH:MM:SS
std::string date;
std::string time;
fullstring>>date>>time;
auto pos1 = date.find("/");
std::string month = date.substr(0,pos1);
date = date.erase(0,pos1+1);
pos1 = date.find("/");
std::string day = date.substr(0,pos1);
date = date.erase(0,pos1+1);
std::string year = date;
auto pos2 = time.find(":");
std::string hour = time.substr(0,pos2);
time = time.erase(0,pos2+1);
pos2 = time.find(":");
std::string minute = time.substr(0,pos2);
time = time.erase(0,pos2+1);
std::string second = time;
(*this).setDay(std::stoi(day));
(*this).setMonth(std::stoi(month));
(*this).setYear(std::stoi(year));
(*this).setSecond(std::stoi(second));
(*this).setMinute(std::stoi(minute));
(*this).setHour(std::stoi(hour));
}
if(isalpha(aString[0])){ //seperate "Jan 1,1961 12:24:25"
std::map<std::string,int>monthname = { {"Jan",1},{"Feb",2},{"Mar",3},{"Apr",4},{"May",5},{"Jun",6},{"Jul",7},{"Aug",8},{"Sep",9},{"Sept",9},{"Oct",10},{"Nov",11},{"Dec",12},{"January",1},{"February",2},{"March",3},{"April",4},{"June",6},{"July",7},{"August",8},{"September",9},{"October",10},{"November",11},{"December",12}};
std::stringstream fullstring(aString);
std::string month;
std::string day;
std::string year;
std::string dayplusyear;
std::string time;
fullstring>>month>>dayplusyear>>time;
setMonth(monthname.find(month)->second);
auto pos = dayplusyear.find(",");
day = dayplusyear.substr(0,pos);
setDay(std::stoi(day));
dayplusyear = dayplusyear.erase(0,pos+1);
setYear(std::stoi(dayplusyear));
auto pos1 = time.find(":");
std::string hour = time.substr(0,pos1);
time = time.erase(0,pos1+1);
pos1 = time.find(":");
std::string min = time.substr(0,pos1);
time = time.erase(0,pos1+1);
std::string sec = time;
setHour(std::stoi(hour));
setMinute(std::stoi(min));
setSecond(std::stoi(sec));
}
const char* GMT = "GMT";
SFTimezone gmt(GMT);
std::map<std::string,int> tzmap = { {"GMT",0},{"PST",-8},{"CST",-6},{"EST",-5} };
int timeadjust = 0;
if(aTimezone==nullptr){
SFDTzone.SFTZsetTimezone(GMT);
}
else{
timeadjust = tzmap.find("GMT")->second - tzmap.find(aTimezone->SFTZgetTimezone())->second;
adjustByHours(timeadjust);
// SFDTzone.SFTZsetTimezone(GMT);
setTimezone(*aTimezone);
}
}
SFDateTime::SFDateTime(const SFDate &aDate, const SFTime &aTime, SFTimezone *aTimezone):SFTime(aTime),SFDate(aDate){
const char* GMT = "GMT";
SFTimezone gmt(GMT);
std::map<std::string,int> tzmap = { {"GMT",0},{"PST",-8},{"CST",-6},{"EST",-5} };
int timeadjust = 0;
if(aTimezone==nullptr){
const char* GMT = "GMT";
SFTimezone gmt(GMT);
setTimezone(gmt);
}
else{
timeadjust = tzmap.find("GMT")->second - tzmap.find(aTimezone->SFTZgetTimezone())->second;
adjustByHours(timeadjust);
// SFDTzone.SFTZsetTimezone(GMT);
setTimezone(*aTimezone);
}
}
SFInterval SFDateTime::operator-(const SFDateTime &aother){ //determine interval between two objects...
SFTimezone thistz = getTimezone();
SFTimezone aothertz = aother.getTimezone();
SFDateTime other(aother.getMonth(),aother.getDay(),aother.getYear(),aother.getHour(),aother.getMinutes(),aother.getSeconds(),&aothertz);
SFInterval timedatediff;
if((*this).operator<(other)==true){
other.setTimezone(thistz);
(*this).SFTime::operator-(other);
timedatediff.setSeconds((*this).SFTime::operator-(other).SFIgetSeconds());
timedatediff.setMinutes((*this).SFTime::operator-(other).SFIgetMinutes());
timedatediff.setHours((*this).SFTime::operator-(other).SFIgetHours());
adjustByDays(getDayAdjust());
(*this).SFDate::operator-(other);
timedatediff.setDays((*this).SFTime::operator-(other).SFIgetDays());
timedatediff.setMonths((*this).SFTime::operator-(other).SFIgetMonths());
timedatediff.setYears((*this).SFTime::operator-(other).SFIgetYears());
}
else{
(*this).setTimezone(aothertz);
(other).SFTime::operator-((*this));
timedatediff.setSeconds(other.SFTime::operator-((*this)).SFIgetSeconds());
timedatediff.setMinutes(other.SFTime::operator-((*this)).SFIgetMinutes());
timedatediff.setHours(other.SFTime::operator-((*this)).SFIgetHours());
other.adjustByDays(other.getDayAdjust());
other.SFDate::operator-((*this));
timedatediff.setDays(other.SFTime::operator-((*this)).SFIgetDays());
timedatediff.setMonths(other.SFTime::operator-((*this)).SFIgetMonths());
timedatediff.setYears(other.SFTime::operator-((*this)).SFIgetYears());
}
return timedatediff;
/*
SFDateTime newadate(aother);
SFTime newtime(newadate.getHour(),newadate.getMinutes(),newadate.getSeconds());
SFDate newdate(newadate.getMonth(),newadate.getDay(),newadate.getYear());
SFInterval finaldiff;
int time2hour = 0;
int time2min = 0;
int time2sec = 0;
int secdiff = 0;
int mindiff = 0;
int hourdiff = 0;
if( (*this).SFTime::operator<(newtime)){
if(getSeconds()>newtime.getSeconds()){
time2sec = newtime.getSeconds()+60;
time2min = newtime.getMinutes() -1;
secdiff = time2sec - getSeconds();
}else{
secdiff = newtime.getSeconds() - getSeconds();
time2min = newtime.getMinutes();
}
if(getMinutes()>time2min){
mindiff = time2min+60-getMinutes();
time2hour = newtime.getHour()-1;
}else{
mindiff = time2min - getMinutes();
time2hour = newtime.getHour();
}
hourdiff = time2hour - getHour();
finaldiff.setSeconds(secdiff);
finaldiff.setMinutes(mindiff);
finaldiff.setHours(hourdiff);
}
else{
time2hour = newtime.getHour()+24;
newdate.adjustByDays(-1);
if(getSeconds()>newtime.getSeconds()){
time2sec = newtime.getSeconds()+60;
time2min = newtime.getMinutes() -1;
secdiff = time2sec - getSeconds();
}else{
secdiff = newtime.getSeconds() - getSeconds();
time2min = newtime.getMinutes();
}
if(getMinutes()>time2min){
mindiff = time2min+60-getMinutes();
time2hour -=time2hour-1;
}else{
mindiff = time2min - getMinutes();
}
hourdiff = time2hour - getHour();
finaldiff.setSeconds(secdiff);
finaldiff.setMinutes(mindiff);
finaldiff.setHours(hourdiff);
}
//adjust the day
int month[13] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
int bigday = 0;
int daydiff = 0;
int monthdate1 = 0;
int monthdiff = 0;
int monthdate2 = 0;
int yeardate1 = 0;
int yeardate2 = 0;
int yeardiff = 0;
if( (*this).SFDate::operator<(newdate)){ //first variable is smaller than second, in the future
if(newdate.getDay()<getDay()){
bigday = newdate.getDay()+ month[getMonth()];
if( getMonth() ==2 && checkleap())
bigday +=1;
daydiff = bigday-getDay();
monthdate1 = getMonth()+1;
}
else{
daydiff = newdate.getDay() -getDay();
monthdate1 = getMonth();
}
if(newdate.getMonth()< monthdate1){
monthdate2 = 12 + newdate.getMonth();
monthdiff = monthdate2 - monthdate1;
yeardate2 = newdate.getYear() - 1;
}
else{
monthdate2 = newdate.getMonth();
monthdiff = monthdate2 - monthdate1;
yeardate2 = newdate.getYear();
}
yeardiff = yeardate2-getYear();
finaldiff.setDays( daydiff );
finaldiff.setMonths(monthdiff);
finaldiff.setYears(yeardiff);
}else{
if(getDay()<newdate.getDay()){
bigday = getDay()+ month[newdate.getMonth()];
if( newdate.getMonth() ==2 && newdate.checkleap())
bigday +=1;
daydiff = bigday-newdate.getDay();
monthdate2 = newdate.getMonth()+1;
}
else{
daydiff = getDay() -newdate.getDay();
monthdate2 = newdate.getMonth();
}
if(getMonth()< monthdate2){
monthdate1 = 12 + getMonth();
monthdiff = monthdate1 - monthdate2;
yeardate1 = getYear() - 1;
}
else{
monthdate1 = getMonth();
monthdiff = monthdate1 - monthdate2;
yeardate1 = getYear();
}
yeardiff = yeardate1-yeardate2;
finaldiff.setDays( -daydiff );
finaldiff.setMonths(-monthdiff);
finaldiff.setYears(-yeardiff);
}
return finaldiff;
*/
}
SFTimezone SFDateTime::getTimezone() const { //retrieve timezone currently associated with this object
return SFDTzone;
}
SFDateTime& SFDateTime::setTimezone(SFTimezone &aTimezone){ //change timezone, also need to change time.
SFTimezone oldtz = getTimezone();
SFTimezone newtz = aTimezone;
std::string oldtimezone(oldtz);
std::string newtimezone(newtz);
std::map<std::string,int> tzmap = { {"GMT",0},{"PST",-8},{"CST",-6},{"EST",-5} };
int timeadjust = 0;
timeadjust = tzmap.find(newtimezone)->second - tzmap.find(oldtimezone)->second;
adjustByHours(timeadjust); // no change
SFDTzone.SFTZsetTimezone(newtimezone.c_str());
return *this;
}
//ADD RELATIONAL OPERATORS HERE... >, <, <=, >=, !=, ==
bool SFDateTime::operator>(const SFDateTime &adatetime) {
bool result = false;
SFTimezone returntz = adatetime.getTimezone();
SFDateTime newadate(adatetime.getMonth(), adatetime.getDay(), adatetime.getYear(), adatetime.getHour(), adatetime.getMinutes(), adatetime.getSeconds(),&returntz);
std::map<std::string,int> tzmap = { {"GMT",0},{"PST",-8},{"CST",-6},{"EST",-5} };
SFTimezone oldtz = getTimezone();
newadate.setTimezone(oldtz);
if( (*this).SFDate::operator>(newadate) ){
result = true;
}
else if( (*this).SFDate::operator==(newadate) && (*this).SFTime::operator>(newadate)){
result = true;
}
else{
result = false;
}
return result;
}
bool SFDateTime::operator<(const SFDateTime &adatetime) {
return (!operator>(adatetime) && !operator==(adatetime));
}
bool SFDateTime::operator>=(const SFDateTime &adatetime){
return !operator<(adatetime);
}
bool SFDateTime::operator<=(const SFDateTime &adatetime) {
return !operator>(adatetime);
}
bool SFDateTime::operator==(const SFDateTime &adatetime) {
bool result = false;
SFTimezone returntz = adatetime.getTimezone();
SFDateTime newadate(adatetime.getMonth(), adatetime.getDay(), adatetime.getYear(), adatetime.getHour(), adatetime.getMinutes(), adatetime.getSeconds(),&returntz);
std::map<std::string,int> tzmap = { {"GMT",0},{"PST",-8},{"CST",-6},{"EST",-5} };
SFTimezone oldtz = getTimezone();
newadate.setTimezone(oldtz);
if( (*this).SFDate::operator==(newadate) && (*this).SFTime::operator==(newadate)){
result = true;
}
else{
result = false;
}
return result;
}
bool SFDateTime::operator!=(const SFDateTime &adatetime){
return !operator==(adatetime);
}
SFDateTime::operator const char*(){
std::string str = toDateTimeString();
const char* c = str.c_str();
return c;
} //Returns string of the form "MON DATE, YEAR HH:MM:SS TIMEZONE" Ex. Jan 4, 1961 09:15:00 PST
SFDateTime::operator SFDate() {
return *this;
}
SFDateTime::operator SFTime() {
return *this;
}
SFDateTime::operator SFTimezone(){
return SFDTzone;
}
std::string SFDateTime::toDateTimeString(){
std::string outputstr;
std::map<int,std::string> month = { {1,"Jan"},{2,"Feb"},{3,"Mar"},{4,"Apr"},{5,"May"},{6,"Jun"},{7,"July"},{8,"Aug"},{9,"Sep"},{10,"Oct"},{11,"Nov"},{12,"Dec"} };
outputstr = month.find(getMonth())->second + " " +std::to_string(getDay()) + ", "+std::to_string(getYear())+" "+ SFTime::toTimeString()+" "+ std::string(SFDTzone);
return outputstr;
} //Jan 4, 1961 09:15:00 PST (always this format)
}
| 38.902844 | 337 | 0.530669 | [
"object"
] |
eb70fac9d1fab6941b959955ba19a0f62bc8bb15 | 4,934 | cc | C++ | video_engine/vie_remb.cc | aleonliao/webrtc-3.31 | a282cc166883aea82a8149d64e82ca29aa9f27f1 | [
"DOC",
"BSD-3-Clause"
] | null | null | null | video_engine/vie_remb.cc | aleonliao/webrtc-3.31 | a282cc166883aea82a8149d64e82ca29aa9f27f1 | [
"DOC",
"BSD-3-Clause"
] | null | null | null | video_engine/vie_remb.cc | aleonliao/webrtc-3.31 | a282cc166883aea82a8149d64e82ca29aa9f27f1 | [
"DOC",
"BSD-3-Clause"
] | null | null | null | /*
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "video_engine/vie_remb.h"
#include <algorithm>
#include <cassert>
#include "modules/rtp_rtcp/interface/rtp_rtcp.h"
#include "modules/utility/interface/process_thread.h"
#include "system_wrappers/interface/critical_section_wrapper.h"
#include "system_wrappers/interface/tick_util.h"
#include "system_wrappers/interface/trace.h"
namespace webrtc {
const int kRembTimeOutThresholdMs = 2000;
const int kRembSendIntervallMs = 1000;
const unsigned int kRembMinimumBitrateKbps = 50;
// % threshold for if we should send a new REMB asap.
const unsigned int kSendThresholdPercent = 97;
VieRemb::VieRemb()
: list_crit_(CriticalSectionWrapper::CreateCriticalSection()),
last_remb_time_(TickTime::MillisecondTimestamp()),
last_send_bitrate_(0),
bitrate_(0) {}
VieRemb::~VieRemb() {}
void VieRemb::AddReceiveChannel(RtpRtcp* rtp_rtcp) {
assert(rtp_rtcp);
WEBRTC_TRACE(kTraceStateInfo, kTraceVideo, -1,
"VieRemb::AddReceiveChannel(%p)", rtp_rtcp);
CriticalSectionScoped cs(list_crit_.get());
if (std::find(receive_modules_.begin(), receive_modules_.end(), rtp_rtcp) !=
receive_modules_.end())
return;
WEBRTC_TRACE(kTraceInfo, kTraceVideo, -1, "AddRembChannel");
// The module probably doesn't have a remote SSRC yet, so don't add it to the
// map.
receive_modules_.push_back(rtp_rtcp);
}
void VieRemb::RemoveReceiveChannel(RtpRtcp* rtp_rtcp) {
assert(rtp_rtcp);
WEBRTC_TRACE(kTraceStateInfo, kTraceVideo, -1,
"VieRemb::RemoveReceiveChannel(%p)", rtp_rtcp);
CriticalSectionScoped cs(list_crit_.get());
for (RtpModules::iterator it = receive_modules_.begin();
it != receive_modules_.end(); ++it) {
if ((*it) == rtp_rtcp) {
receive_modules_.erase(it);
break;
}
}
}
void VieRemb::AddRembSender(RtpRtcp* rtp_rtcp) {
assert(rtp_rtcp);
WEBRTC_TRACE(kTraceStateInfo, kTraceVideo, -1,
"VieRemb::AddRembSender(%p)", rtp_rtcp);
CriticalSectionScoped cs(list_crit_.get());
// Verify this module hasn't been added earlier.
if (std::find(rtcp_sender_.begin(), rtcp_sender_.end(), rtp_rtcp) !=
rtcp_sender_.end())
return;
rtcp_sender_.push_back(rtp_rtcp);
}
void VieRemb::RemoveRembSender(RtpRtcp* rtp_rtcp) {
assert(rtp_rtcp);
WEBRTC_TRACE(kTraceStateInfo, kTraceVideo, -1,
"VieRemb::RemoveRembSender(%p)", rtp_rtcp);
CriticalSectionScoped cs(list_crit_.get());
for (RtpModules::iterator it = rtcp_sender_.begin();
it != rtcp_sender_.end(); ++it) {
if ((*it) == rtp_rtcp) {
rtcp_sender_.erase(it);
return;
}
}
}
bool VieRemb::InUse() const {
CriticalSectionScoped cs(list_crit_.get());
if (receive_modules_.empty() && rtcp_sender_.empty())
return false;
else
return true;
}
void VieRemb::OnReceiveBitrateChanged(std::vector<unsigned int>* ssrcs,
unsigned int bitrate) {
WEBRTC_TRACE(kTraceStream, kTraceVideo, -1,
"VieRemb::UpdateBitrateEstimate(bitrate: %u)", bitrate);
assert(ssrcs);
list_crit_->Enter();
// If we already have an estimate, check if the new total estimate is below
// kSendThresholdPercent of the previous estimate.
if (last_send_bitrate_ > 0) {
unsigned int new_remb_bitrate = last_send_bitrate_ - bitrate_ + bitrate;
if (new_remb_bitrate < kSendThresholdPercent * last_send_bitrate_ / 100) {
// The new bitrate estimate is less than kSendThresholdPercent % of the
// last report. Send a REMB asap.
last_remb_time_ = TickTime::MillisecondTimestamp() - kRembSendIntervallMs;
}
}
bitrate_ = bitrate;
// Calculate total receive bitrate estimate.
int64_t now = TickTime::MillisecondTimestamp();
if (now - last_remb_time_ < kRembSendIntervallMs) {
list_crit_->Leave();
return;
}
last_remb_time_ = now;
if (ssrcs->empty() || receive_modules_.empty()) {
list_crit_->Leave();
return;
}
// Send a REMB packet.
RtpRtcp* sender = NULL;
if (!rtcp_sender_.empty()) {
sender = rtcp_sender_.front();
} else {
sender = receive_modules_.front();
}
last_send_bitrate_ = bitrate_;
// Never send a REMB lower than last_send_bitrate_.
if (last_send_bitrate_ < kRembMinimumBitrateKbps) {
last_send_bitrate_ = kRembMinimumBitrateKbps;
}
list_crit_->Leave();
if (sender) {
// TODO(holmer): Change RTP module API to take a vector pointer.
sender->SetREMBData(bitrate_, ssrcs->size(), &(*ssrcs)[0]);
}
}
} // namespace webrtc
| 30.269939 | 80 | 0.697608 | [
"vector"
] |
eb780f0d98fcfb1715bbe51dda22add65ad43478 | 50,869 | cpp | C++ | src/OrbitVulkanLayer/DispatchTableTest.cpp | tufeigunchu/orbit | 407354cf7c9159ff7e3177c603a6850b95509e3a | [
"BSD-2-Clause"
] | 1,847 | 2020-03-24T19:01:42.000Z | 2022-03-31T13:18:57.000Z | src/OrbitVulkanLayer/DispatchTableTest.cpp | tufeigunchu/orbit | 407354cf7c9159ff7e3177c603a6850b95509e3a | [
"BSD-2-Clause"
] | 1,100 | 2020-03-24T19:41:13.000Z | 2022-03-31T14:27:09.000Z | src/OrbitVulkanLayer/DispatchTableTest.cpp | tufeigunchu/orbit | 407354cf7c9159ff7e3177c603a6850b95509e3a | [
"BSD-2-Clause"
] | 228 | 2020-03-25T05:32:08.000Z | 2022-03-31T11:27:39.000Z | // Copyright (c) 2020 The Orbit 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 <gtest/gtest.h>
#include "DispatchTable.h"
namespace orbit_vulkan_layer {
// Note the following for all the following tests:
// We cannot create an actual VkInstance/VkDevice, but the first bytes of any dispatchable type in
// Vulkan will be a pointer to a dispatch table. This characteristic will be used by our dispatch
// table wrapper, so we need to mimic it.
// Thus, we will create VkLayer(Instance)DispatchTables and cast its address to VkInstance/VkDevice.
TEST(DispatchTable, CanInitializeInstance) {
VkLayerInstanceDispatchTable some_dispatch_table = {};
auto instance = absl::bit_cast<VkInstance>(&some_dispatch_table);
PFN_vkGetInstanceProcAddr next_get_instance_proc_addr_function =
+[](VkInstance /*instance*/, const char * /*name*/) -> PFN_vkVoidFunction { return nullptr; };
DispatchTable dispatch_table = {};
dispatch_table.CreateInstanceDispatchTable(instance, next_get_instance_proc_addr_function);
EXPECT_EQ(instance, dispatch_table.GetInstance(instance));
}
TEST(DispatchTable, CannotInitializeInstanceTwice) {
VkLayerInstanceDispatchTable some_dispatch_table = {};
auto instance = absl::bit_cast<VkInstance>(&some_dispatch_table);
PFN_vkGetInstanceProcAddr next_get_instance_proc_addr_function =
+[](VkInstance /*instance*/, const char * /*name*/) -> PFN_vkVoidFunction { return nullptr; };
DispatchTable dispatch_table = {};
dispatch_table.CreateInstanceDispatchTable(instance, next_get_instance_proc_addr_function);
EXPECT_DEATH(
{
dispatch_table.CreateInstanceDispatchTable(instance, next_get_instance_proc_addr_function);
},
"");
}
TEST(DispatchTable, CanRemoveInstance) {
VkLayerInstanceDispatchTable some_dispatch_table = {};
auto instance = absl::bit_cast<VkInstance>(&some_dispatch_table);
PFN_vkGetInstanceProcAddr next_get_instance_proc_addr_function =
+[](VkInstance /*instance*/, const char * /*name*/) -> PFN_vkVoidFunction { return nullptr; };
DispatchTable dispatch_table = {};
dispatch_table.CreateInstanceDispatchTable(instance, next_get_instance_proc_addr_function);
dispatch_table.RemoveInstanceDispatchTable(instance);
}
TEST(DispatchTable, CanReinitializeInstanceAfterRemove) {
VkLayerInstanceDispatchTable some_dispatch_table = {};
auto instance = absl::bit_cast<VkInstance>(&some_dispatch_table);
PFN_vkGetInstanceProcAddr next_get_instance_proc_addr_function =
+[](VkInstance /*instance*/, const char * /*name*/) -> PFN_vkVoidFunction { return nullptr; };
DispatchTable dispatch_table = {};
dispatch_table.CreateInstanceDispatchTable(instance, next_get_instance_proc_addr_function);
dispatch_table.RemoveInstanceDispatchTable(instance);
dispatch_table.CreateInstanceDispatchTable(instance, next_get_instance_proc_addr_function);
}
TEST(DispatchTable, CanInitializeDevice) {
VkLayerDispatchTable some_dispatch_table = {};
auto device = absl::bit_cast<VkDevice>(&some_dispatch_table);
PFN_vkGetDeviceProcAddr next_get_device_proc_addr_function =
+[](VkDevice /*instance*/, const char * /*name*/) -> PFN_vkVoidFunction { return nullptr; };
DispatchTable dispatch_table = {};
dispatch_table.CreateDeviceDispatchTable(device, next_get_device_proc_addr_function);
}
TEST(DispatchTable, CannotInitializeDeviceTwice) {
VkLayerDispatchTable some_dispatch_table = {};
auto device = absl::bit_cast<VkDevice>(&some_dispatch_table);
PFN_vkGetDeviceProcAddr next_get_device_proc_addr_function =
+[](VkDevice /*instance*/, const char * /*name*/) -> PFN_vkVoidFunction { return nullptr; };
DispatchTable dispatch_table = {};
dispatch_table.CreateDeviceDispatchTable(device, next_get_device_proc_addr_function);
EXPECT_DEATH(
{ dispatch_table.CreateDeviceDispatchTable(device, next_get_device_proc_addr_function); },
"");
}
TEST(DispatchTable, CanRemoveDevice) {
VkLayerDispatchTable some_dispatch_table = {};
auto device = absl::bit_cast<VkDevice>(&some_dispatch_table);
PFN_vkGetDeviceProcAddr next_get_device_proc_addr_function =
+[](VkDevice /*instance*/, const char * /*name*/) -> PFN_vkVoidFunction { return nullptr; };
DispatchTable dispatch_table = {};
dispatch_table.CreateDeviceDispatchTable(device, next_get_device_proc_addr_function);
dispatch_table.RemoveDeviceDispatchTable(device);
}
TEST(DispatchTable, CanReinitializeDeviceAfterRemove) {
VkLayerDispatchTable some_dispatch_table = {};
auto device = absl::bit_cast<VkDevice>(&some_dispatch_table);
PFN_vkGetDeviceProcAddr next_get_device_proc_addr_function =
+[](VkDevice /*instance*/, const char * /*name*/) -> PFN_vkVoidFunction { return nullptr; };
DispatchTable dispatch_table = {};
dispatch_table.CreateDeviceDispatchTable(device, next_get_device_proc_addr_function);
dispatch_table.RemoveDeviceDispatchTable(device);
dispatch_table.CreateDeviceDispatchTable(device, next_get_device_proc_addr_function);
}
TEST(DispatchTable, NoDeviceExtensionAvailable) {
VkLayerDispatchTable some_dispatch_table = {};
auto device = absl::bit_cast<VkDevice>(&some_dispatch_table);
PFN_vkGetDeviceProcAddr next_get_device_proc_addr_function =
+[](VkDevice /*device*/, const char * /*name*/) -> PFN_vkVoidFunction { return nullptr; };
DispatchTable dispatch_table = {};
dispatch_table.CreateDeviceDispatchTable(device, next_get_device_proc_addr_function);
EXPECT_FALSE(dispatch_table.IsDebugUtilsExtensionSupported(device));
EXPECT_FALSE(dispatch_table.IsDebugMarkerExtensionSupported(device));
}
TEST(DispatchTable, NoInstanceExtensionAvailable) {
VkLayerInstanceDispatchTable some_dispatch_table = {};
auto instance = absl::bit_cast<VkInstance>(&some_dispatch_table);
PFN_vkGetInstanceProcAddr next_get_instance_proc_addr_function =
+[](VkInstance /*instance*/, const char * /*name*/) -> PFN_vkVoidFunction { return nullptr; };
DispatchTable dispatch_table = {};
dispatch_table.CreateInstanceDispatchTable(instance, next_get_instance_proc_addr_function);
EXPECT_FALSE(dispatch_table.IsDebugUtilsExtensionSupported(instance));
EXPECT_FALSE(dispatch_table.IsDebugReportExtensionSupported(instance));
}
TEST(DispatchTable, CanSupportDeviceDebugUtilsExtension) {
VkLayerDispatchTable some_dispatch_table = {};
auto device = absl::bit_cast<VkDevice>(&some_dispatch_table);
PFN_vkGetDeviceProcAddr next_get_device_proc_addr_function =
+[](VkDevice /*device*/, const char* name) -> PFN_vkVoidFunction {
if (strcmp(name, "vkCmdBeginDebugUtilsLabelEXT") == 0) {
PFN_vkCmdBeginDebugUtilsLabelEXT begin_function =
+[](VkCommandBuffer /*command_buffer*/, const VkDebugUtilsLabelEXT* /*label_info*/) {};
return absl::bit_cast<PFN_vkVoidFunction>(begin_function);
}
if (strcmp(name, "vkCmdEndDebugUtilsLabelEXT") == 0) {
PFN_vkCmdEndDebugUtilsLabelEXT end_function = +[](VkCommandBuffer /*command_buffer*/) {};
return absl::bit_cast<PFN_vkVoidFunction>(end_function);
}
if (strcmp(name, "vkCmdInsertDebugUtilsLabelEXT") == 0) {
PFN_vkCmdInsertDebugUtilsLabelEXT function =
+[](VkCommandBuffer /*command_buffer*/, const VkDebugUtilsLabelEXT* /*label_info*/) {};
return absl::bit_cast<PFN_vkVoidFunction>(function);
}
if (strcmp(name, "vkSetDebugUtilsObjectNameEXT") == 0) {
PFN_vkSetDebugUtilsObjectNameEXT function =
+[](VkDevice /*device*/, const VkDebugUtilsObjectNameInfoEXT *
/*name_info*/) -> VkResult { return VK_SUCCESS; };
return absl::bit_cast<PFN_vkVoidFunction>(function);
}
if (strcmp(name, "vkSetDebugUtilsObjectTagEXT") == 0) {
PFN_vkSetDebugUtilsObjectTagEXT function =
+[](VkDevice /*device*/, const VkDebugUtilsObjectTagInfoEXT *
/*tag_info*/) -> VkResult { return VK_SUCCESS; };
return absl::bit_cast<PFN_vkVoidFunction>(function);
}
if (strcmp(name, "vkQueueBeginDebugUtilsLabelEXT") == 0) {
PFN_vkQueueBeginDebugUtilsLabelEXT function =
+[](VkQueue /*queue*/, const VkDebugUtilsLabelEXT*
/*label_info*/) {};
return absl::bit_cast<PFN_vkVoidFunction>(function);
}
if (strcmp(name, "vkQueueEndDebugUtilsLabelEXT") == 0) {
PFN_vkQueueEndDebugUtilsLabelEXT function = +[](VkQueue /*queue*/) {};
return absl::bit_cast<PFN_vkVoidFunction>(function);
}
if (strcmp(name, "vkQueueInsertDebugUtilsLabelEXT") == 0) {
PFN_vkQueueInsertDebugUtilsLabelEXT function =
+[](VkQueue /*queue*/, const VkDebugUtilsLabelEXT*
/*label_info*/) {};
return absl::bit_cast<PFN_vkVoidFunction>(function);
}
return nullptr;
};
DispatchTable dispatch_table = {};
dispatch_table.CreateDeviceDispatchTable(device, next_get_device_proc_addr_function);
EXPECT_TRUE(dispatch_table.IsDebugUtilsExtensionSupported(device));
}
TEST(DispatchTable, CanSupportInstanceDebugUtilsExtension) {
VkLayerInstanceDispatchTable some_dispatch_table = {};
auto instance = absl::bit_cast<VkInstance>(&some_dispatch_table);
PFN_vkGetInstanceProcAddr next_get_instance_proc_addr_function =
+[](VkInstance /*instance*/, const char* name) -> PFN_vkVoidFunction {
if (strcmp(name, "vkCreateDebugUtilsMessengerEXT") == 0) {
PFN_vkCreateDebugUtilsMessengerEXT function =
+[](VkInstance /*instance*/, const VkDebugUtilsMessengerCreateInfoEXT* /*create_info*/,
const VkAllocationCallbacks* /*allocator*/, VkDebugUtilsMessengerEXT *
/*messenger*/) -> VkResult { return VK_SUCCESS; };
return absl::bit_cast<PFN_vkVoidFunction>(function);
}
if (strcmp(name, "vkDestroyDebugUtilsMessengerEXT") == 0) {
PFN_vkDestroyDebugUtilsMessengerEXT function =
+[](VkInstance /*instance*/, VkDebugUtilsMessengerEXT /*messenger*/,
const VkAllocationCallbacks* /*allocator*/) {};
return absl::bit_cast<PFN_vkVoidFunction>(function);
}
if (strcmp(name, "vkSubmitDebugUtilsMessageEXT") == 0) {
PFN_vkSubmitDebugUtilsMessageEXT function =
+[](VkInstance /*instance*/, VkDebugUtilsMessageSeverityFlagBitsEXT /*message_severity*/,
VkDebugUtilsMessageTypeFlagsEXT /*message_types*/,
const VkDebugUtilsMessengerCallbackDataEXT* /*callback_data*/) {};
return absl::bit_cast<PFN_vkVoidFunction>(function);
}
return nullptr;
};
DispatchTable dispatch_table = {};
dispatch_table.CreateInstanceDispatchTable(instance, next_get_instance_proc_addr_function);
EXPECT_TRUE(dispatch_table.IsDebugUtilsExtensionSupported(instance));
}
TEST(DispatchTable, CanSupportDebugReportExtension) {
VkLayerInstanceDispatchTable some_dispatch_table = {};
auto instance = absl::bit_cast<VkInstance>(&some_dispatch_table);
PFN_vkGetInstanceProcAddr next_get_instance_proc_addr_function =
+[](VkInstance /*instance*/, const char* name) -> PFN_vkVoidFunction {
if (strcmp(name, "vkCreateDebugReportCallbackEXT") == 0) {
PFN_vkCreateDebugReportCallbackEXT function =
+[](VkInstance /*instance*/, const VkDebugReportCallbackCreateInfoEXT* /*create_info*/,
const VkAllocationCallbacks* /*allocator*/, VkDebugReportCallbackEXT *
/*messenger*/) -> VkResult { return VK_SUCCESS; };
return absl::bit_cast<PFN_vkVoidFunction>(function);
}
if (strcmp(name, "vkDestroyDebugReportCallbackEXT") == 0) {
PFN_vkDestroyDebugReportCallbackEXT function =
+[](VkInstance /*instance*/, VkDebugReportCallbackEXT /*messenger*/,
const VkAllocationCallbacks* /*allocator*/) {};
return absl::bit_cast<PFN_vkVoidFunction>(function);
}
if (strcmp(name, "vkDebugReportMessageEXT") == 0) {
PFN_vkDebugReportMessageEXT function =
+[](VkInstance /*instance*/, VkDebugReportFlagsEXT /*flags*/,
VkDebugReportObjectTypeEXT /*object_type*/, uint64_t /*object*/, size_t /*location*/,
int32_t /*message_code*/, const char* /*layer_prefix*/, const char* /*message*/) {};
return absl::bit_cast<PFN_vkVoidFunction>(function);
}
return nullptr;
};
DispatchTable dispatch_table = {};
dispatch_table.CreateInstanceDispatchTable(instance, next_get_instance_proc_addr_function);
EXPECT_TRUE(dispatch_table.IsDebugReportExtensionSupported(instance));
}
TEST(DispatchTable, CanSupportDebugMarkerExtension) {
VkLayerDispatchTable some_dispatch_table = {};
auto device = absl::bit_cast<VkDevice>(&some_dispatch_table);
PFN_vkGetDeviceProcAddr next_get_device_proc_addr_function =
+[](VkDevice /*instance*/, const char* name) -> PFN_vkVoidFunction {
if (strcmp(name, "vkCmdDebugMarkerBeginEXT") == 0) {
PFN_vkCmdDebugMarkerBeginEXT begin_function =
+[](VkCommandBuffer /*command_buffer*/,
const VkDebugMarkerMarkerInfoEXT* /*label_info*/) {};
return absl::bit_cast<PFN_vkVoidFunction>(begin_function);
}
if (strcmp(name, "vkCmdDebugMarkerEndEXT") == 0) {
PFN_vkCmdDebugMarkerEndEXT end_function = +[](VkCommandBuffer /*command_buffer*/) {};
return absl::bit_cast<PFN_vkVoidFunction>(end_function);
}
if (strcmp(name, "vkCmdDebugMarkerInsertEXT") == 0) {
PFN_vkCmdDebugMarkerInsertEXT function =
+[](VkCommandBuffer /*command_buffer*/,
const VkDebugMarkerMarkerInfoEXT* /*marker_info*/) {};
return absl::bit_cast<PFN_vkVoidFunction>(function);
}
if (strcmp(name, "vkDebugMarkerSetObjectTagEXT") == 0) {
PFN_vkDebugMarkerSetObjectTagEXT function =
+[](VkDevice /*device*/, const VkDebugMarkerObjectTagInfoEXT * /*tag_info*/) -> VkResult {
return VK_SUCCESS;
};
return absl::bit_cast<PFN_vkVoidFunction>(function);
}
if (strcmp(name, "vkDebugMarkerSetObjectNameEXT") == 0) {
PFN_vkDebugMarkerSetObjectNameEXT function =
+[](VkDevice /*device*/, const VkDebugMarkerObjectNameInfoEXT *
/*name_info*/) -> VkResult { return VK_SUCCESS; };
return absl::bit_cast<PFN_vkVoidFunction>(function);
}
return nullptr;
};
DispatchTable dispatch_table = {};
dispatch_table.CreateDeviceDispatchTable(device, next_get_device_proc_addr_function);
EXPECT_TRUE(dispatch_table.IsDebugMarkerExtensionSupported(device));
}
TEST(DispatchTable, CanCallEnumerateDeviceExtensionProperties) {
VkLayerInstanceDispatchTable some_dispatch_table = {};
auto instance = absl::bit_cast<VkInstance>(&some_dispatch_table);
PFN_vkGetInstanceProcAddr next_get_instance_proc_addr_function =
+[](VkInstance /*instance*/, const char* name) -> PFN_vkVoidFunction {
if (strcmp(name, "vkEnumerateDeviceExtensionProperties") == 0) {
PFN_vkEnumerateDeviceExtensionProperties function =
+[](VkPhysicalDevice /*physical_device*/, const char* /*layer_name*/,
uint32_t* property_count, VkExtensionProperties *
/*properties*/) -> VkResult {
*property_count = 42;
return VK_SUCCESS;
};
return absl::bit_cast<PFN_vkVoidFunction>(function);
}
return nullptr;
};
DispatchTable dispatch_table = {};
dispatch_table.CreateInstanceDispatchTable(instance, next_get_instance_proc_addr_function);
VkPhysicalDevice device = {};
uint32_t property_count;
VkResult result = dispatch_table.EnumerateDeviceExtensionProperties(instance)(
device, nullptr, &property_count, nullptr);
EXPECT_EQ(result, VK_SUCCESS);
EXPECT_EQ(property_count, 42);
}
TEST(DispatchTable, CanCallGetPhysicalDeviceProperties) {
VkLayerInstanceDispatchTable some_dispatch_table = {};
auto instance = absl::bit_cast<VkInstance>(&some_dispatch_table);
// This bool needs to be static, as it will be used in the lambda below, which must not capture
// anything in order to convert it to a function pointer.
static bool was_called = false;
PFN_vkGetInstanceProcAddr next_get_instance_proc_addr_function =
+[](VkInstance /*instance*/, const char* name) -> PFN_vkVoidFunction {
if (strcmp(name, "vkGetPhysicalDeviceProperties") == 0) {
PFN_vkGetPhysicalDeviceProperties function =
+[](VkPhysicalDevice /*physical_device*/, VkPhysicalDeviceProperties*
/*properties*/) { was_called = true; };
return absl::bit_cast<PFN_vkVoidFunction>(function);
}
return nullptr;
};
DispatchTable dispatch_table = {};
dispatch_table.CreateInstanceDispatchTable(instance, next_get_instance_proc_addr_function);
VkPhysicalDevice device = {};
dispatch_table.GetPhysicalDeviceProperties(instance)(device, nullptr);
EXPECT_TRUE(was_called);
was_called = false;
}
TEST(DispatchTable, CanCallGetInstanceProcAddr) {
VkLayerInstanceDispatchTable some_dispatch_table = {};
auto instance = absl::bit_cast<VkInstance>(&some_dispatch_table);
static bool was_called = false;
PFN_vkGetInstanceProcAddr next_get_instance_proc_addr_function =
+[](VkInstance /*instance*/, const char* name) -> PFN_vkVoidFunction {
if (strcmp(name, "vkGetInstanceProcAddr") == 0) {
PFN_vkGetInstanceProcAddr function = +[](VkInstance /*instance*/, const char *
/*name*/) -> PFN_vkVoidFunction {
was_called = true;
return nullptr;
};
return absl::bit_cast<PFN_vkVoidFunction>(function);
}
return nullptr;
};
DispatchTable dispatch_table = {};
dispatch_table.CreateInstanceDispatchTable(instance, next_get_instance_proc_addr_function);
dispatch_table.GetInstanceProcAddr(instance)(instance, "");
EXPECT_TRUE(was_called);
was_called = false;
}
TEST(DispatchTable, CanCallGetDeviceProcAddr) {
VkLayerDispatchTable some_dispatch_table = {};
auto device = absl::bit_cast<VkDevice>(&some_dispatch_table);
static bool was_called = false;
PFN_vkGetDeviceProcAddr next_get_device_proc_addr_function =
+[](VkDevice /*device*/, const char* name) -> PFN_vkVoidFunction {
if (strcmp(name, "vkGetDeviceProcAddr") == 0) {
PFN_vkGetDeviceProcAddr function = +[](VkDevice /*device*/, const char *
/*name*/) -> PFN_vkVoidFunction {
was_called = true;
return nullptr;
};
return absl::bit_cast<PFN_vkVoidFunction>(function);
}
return nullptr;
};
DispatchTable dispatch_table = {};
dispatch_table.CreateDeviceDispatchTable(device, next_get_device_proc_addr_function);
dispatch_table.GetDeviceProcAddr(device)(device, "");
EXPECT_TRUE(was_called);
was_called = false;
}
TEST(DispatchTable, CanCallResetCommandPool) {
VkLayerDispatchTable some_dispatch_table = {};
auto device = absl::bit_cast<VkDevice>(&some_dispatch_table);
PFN_vkGetDeviceProcAddr next_get_device_proc_addr_function =
+[](VkDevice /*device*/, const char* name) -> PFN_vkVoidFunction {
if (strcmp(name, "vkResetCommandPool") == 0) {
PFN_vkResetCommandPool function =
+[](VkDevice /*device*/, VkCommandPool /*command_pool*/,
VkCommandPoolResetFlags /*flags*/) -> VkResult { return VK_SUCCESS; };
return absl::bit_cast<PFN_vkVoidFunction>(function);
}
return nullptr;
};
DispatchTable dispatch_table = {};
dispatch_table.CreateDeviceDispatchTable(device, next_get_device_proc_addr_function);
VkCommandPool command_pool = {};
VkResult result = dispatch_table.ResetCommandPool(device)(device, command_pool, 0);
EXPECT_EQ(result, VK_SUCCESS);
}
TEST(DispatchTable, CanCallAllocateCommandBuffers) {
VkLayerDispatchTable some_dispatch_table = {};
auto device = absl::bit_cast<VkDevice>(&some_dispatch_table);
PFN_vkGetDeviceProcAddr next_get_device_proc_addr_function =
+[](VkDevice /*device*/, const char* name) -> PFN_vkVoidFunction {
if (strcmp(name, "vkAllocateCommandBuffers") == 0) {
PFN_vkAllocateCommandBuffers function =
+[](VkDevice /*device*/, const VkCommandBufferAllocateInfo* /*allocate_info*/,
VkCommandBuffer *
/*command_buffers*/) -> VkResult { return VK_SUCCESS; };
return absl::bit_cast<PFN_vkVoidFunction>(function);
}
return nullptr;
};
DispatchTable dispatch_table = {};
dispatch_table.CreateDeviceDispatchTable(device, next_get_device_proc_addr_function);
VkResult result = dispatch_table.AllocateCommandBuffers(device)(device, nullptr, nullptr);
EXPECT_EQ(result, VK_SUCCESS);
}
TEST(DispatchTable, CanCallFreeCommandBuffers) {
VkLayerDispatchTable some_dispatch_table = {};
auto device = absl::bit_cast<VkDevice>(&some_dispatch_table);
static bool was_called = false;
PFN_vkGetDeviceProcAddr next_get_device_proc_addr_function =
+[](VkDevice /*device*/, const char* name) -> PFN_vkVoidFunction {
if (strcmp(name, "vkFreeCommandBuffers") == 0) {
PFN_vkFreeCommandBuffers function =
+[](VkDevice /*device*/, VkCommandPool /*command_pool*/,
uint32_t /*command_buffer_count*/, const VkCommandBuffer*
/*command_buffers*/) { was_called = true; };
return absl::bit_cast<PFN_vkVoidFunction>(function);
}
return nullptr;
};
DispatchTable dispatch_table = {};
dispatch_table.CreateDeviceDispatchTable(device, next_get_device_proc_addr_function);
VkCommandPool command_pool = {};
dispatch_table.FreeCommandBuffers(device)(device, command_pool, 0, nullptr);
EXPECT_TRUE(was_called);
was_called = false;
}
TEST(DispatchTable, CanCallBeginCommandBuffer) {
VkLayerDispatchTable some_dispatch_table = {};
auto device = absl::bit_cast<VkDevice>(&some_dispatch_table);
PFN_vkGetDeviceProcAddr next_get_device_proc_addr_function =
+[](VkDevice /*device*/, const char* name) -> PFN_vkVoidFunction {
if (strcmp(name, "vkBeginCommandBuffer") == 0) {
PFN_vkBeginCommandBuffer function =
+[](VkCommandBuffer /*command_buffer*/, const VkCommandBufferBeginInfo *
/*begin_info*/) -> VkResult { return VK_SUCCESS; };
return absl::bit_cast<PFN_vkVoidFunction>(function);
}
return nullptr;
};
DispatchTable dispatch_table = {};
dispatch_table.CreateDeviceDispatchTable(device, next_get_device_proc_addr_function);
VkCommandBuffer command_buffer = {};
VkResult result = dispatch_table.BeginCommandBuffer(device)(command_buffer, nullptr);
EXPECT_EQ(result, VK_SUCCESS);
}
TEST(DispatchTable, CanCallEndCommandBuffer) {
VkLayerDispatchTable some_dispatch_table = {};
auto device = absl::bit_cast<VkDevice>(&some_dispatch_table);
PFN_vkGetDeviceProcAddr next_get_device_proc_addr_function =
+[](VkDevice /*device*/, const char* name) -> PFN_vkVoidFunction {
if (strcmp(name, "vkEndCommandBuffer") == 0) {
PFN_vkEndCommandBuffer function =
+[](VkCommandBuffer /*command_buffer*/) -> VkResult { return VK_SUCCESS; };
return absl::bit_cast<PFN_vkVoidFunction>(function);
}
return nullptr;
};
DispatchTable dispatch_table = {};
dispatch_table.CreateDeviceDispatchTable(device, next_get_device_proc_addr_function);
VkCommandBuffer command_buffer = {};
VkResult result = dispatch_table.EndCommandBuffer(device)(command_buffer);
EXPECT_EQ(result, VK_SUCCESS);
}
TEST(DispatchTable, CanCallResetCommandBuffer) {
VkLayerDispatchTable some_dispatch_table = {};
auto device = absl::bit_cast<VkDevice>(&some_dispatch_table);
PFN_vkGetDeviceProcAddr next_get_device_proc_addr_function =
+[](VkDevice /*device*/, const char* name) -> PFN_vkVoidFunction {
if (strcmp(name, "vkResetCommandBuffer") == 0) {
PFN_vkResetCommandBuffer function =
+[](VkCommandBuffer /*command_buffer*/, VkCommandBufferResetFlags /*flags*/) -> VkResult {
return VK_SUCCESS;
};
return absl::bit_cast<PFN_vkVoidFunction>(function);
}
return nullptr;
};
DispatchTable dispatch_table = {};
dispatch_table.CreateDeviceDispatchTable(device, next_get_device_proc_addr_function);
VkCommandBuffer command_buffer = {};
VkResult result = dispatch_table.ResetCommandBuffer(device)(command_buffer, 0);
EXPECT_EQ(result, VK_SUCCESS);
}
TEST(DispatchTable, CanCallGetDeviceQueue) {
VkLayerDispatchTable some_dispatch_table = {};
auto device = absl::bit_cast<VkDevice>(&some_dispatch_table);
static bool was_called = false;
PFN_vkGetDeviceProcAddr next_get_device_proc_addr_function =
+[](VkDevice /*device*/, const char* name) -> PFN_vkVoidFunction {
if (strcmp(name, "vkGetDeviceQueue") == 0) {
PFN_vkGetDeviceQueue function = +[](VkDevice /*device*/, uint32_t /*queue_family_index*/,
uint32_t /*queue_index*/, VkQueue*
/*queue*/) { was_called = true; };
return absl::bit_cast<PFN_vkVoidFunction>(function);
}
return nullptr;
};
DispatchTable dispatch_table = {};
dispatch_table.CreateDeviceDispatchTable(device, next_get_device_proc_addr_function);
dispatch_table.GetDeviceQueue(device)(device, 0, 0, nullptr);
EXPECT_TRUE(was_called);
was_called = false;
}
TEST(DispatchTable, CanCallGetDeviceQueue2) {
VkLayerDispatchTable some_dispatch_table = {};
auto device = absl::bit_cast<VkDevice>(&some_dispatch_table);
static bool was_called = false;
PFN_vkGetDeviceProcAddr next_get_device_proc_addr_function =
+[](VkDevice /*device*/, const char* name) -> PFN_vkVoidFunction {
if (strcmp(name, "vkGetDeviceQueue2") == 0) {
PFN_vkGetDeviceQueue2 function =
+[](VkDevice /*device*/, const VkDeviceQueueInfo2* /*queue_info*/, VkQueue*
/*queue*/) { was_called = true; };
return absl::bit_cast<PFN_vkVoidFunction>(function);
}
return nullptr;
};
DispatchTable dispatch_table = {};
dispatch_table.CreateDeviceDispatchTable(device, next_get_device_proc_addr_function);
dispatch_table.GetDeviceQueue2(device)(device, nullptr, nullptr);
EXPECT_TRUE(was_called);
was_called = false;
}
TEST(DispatchTable, CanCallQueueSubmit) {
VkLayerDispatchTable some_dispatch_table = {};
auto device = absl::bit_cast<VkDevice>(&some_dispatch_table);
PFN_vkGetDeviceProcAddr next_get_device_proc_addr_function =
+[](VkDevice /*device*/, const char* name) -> PFN_vkVoidFunction {
if (strcmp(name, "vkQueueSubmit") == 0) {
PFN_vkQueueSubmit function =
+[](VkQueue /*queue*/, uint32_t /*submit_count*/, const VkSubmitInfo* /*submit_info*/,
VkFence /*fence*/) -> VkResult { return VK_SUCCESS; };
return absl::bit_cast<PFN_vkVoidFunction>(function);
}
return nullptr;
};
DispatchTable dispatch_table = {};
dispatch_table.CreateDeviceDispatchTable(device, next_get_device_proc_addr_function);
VkQueue queue = {};
VkFence fence = {};
VkResult result = dispatch_table.QueueSubmit(device)(queue, 0, nullptr, fence);
EXPECT_EQ(result, VK_SUCCESS);
}
TEST(DispatchTable, CanCallQueuePresentKHR) {
VkLayerDispatchTable some_dispatch_table = {};
auto device = absl::bit_cast<VkDevice>(&some_dispatch_table);
PFN_vkGetDeviceProcAddr next_get_device_proc_addr_function =
+[](VkDevice /*device*/, const char* name) -> PFN_vkVoidFunction {
if (strcmp(name, "vkQueuePresentKHR") == 0) {
PFN_vkQueuePresentKHR function = +[](VkQueue /*queue*/, const VkPresentInfoKHR *
/*present_info*/) -> VkResult { return VK_SUCCESS; };
return absl::bit_cast<PFN_vkVoidFunction>(function);
}
return nullptr;
};
DispatchTable dispatch_table = {};
dispatch_table.CreateDeviceDispatchTable(device, next_get_device_proc_addr_function);
VkQueue queue = {};
VkResult result = dispatch_table.QueuePresentKHR(device)(queue, nullptr);
EXPECT_EQ(result, VK_SUCCESS);
}
TEST(DispatchTable, CanCallCreateQueryPool) {
VkLayerDispatchTable some_dispatch_table = {};
auto device = absl::bit_cast<VkDevice>(&some_dispatch_table);
PFN_vkGetDeviceProcAddr next_get_device_proc_addr_function =
+[](VkDevice /*device*/, const char* name) -> PFN_vkVoidFunction {
if (strcmp(name, "vkCreateQueryPool") == 0) {
PFN_vkCreateQueryPool function =
+[](VkDevice /*device*/, const VkQueryPoolCreateInfo* /*create_info*/,
const VkAllocationCallbacks* /*allocator*/, VkQueryPool *
/*query_pool*/) -> VkResult { return VK_SUCCESS; };
return absl::bit_cast<PFN_vkVoidFunction>(function);
}
return nullptr;
};
DispatchTable dispatch_table = {};
dispatch_table.CreateDeviceDispatchTable(device, next_get_device_proc_addr_function);
VkResult result = dispatch_table.CreateQueryPool(device)(device, nullptr, nullptr, nullptr);
EXPECT_EQ(result, VK_SUCCESS);
}
TEST(DispatchTable, CanCallResetQueryPoolEXT) {
VkLayerDispatchTable some_dispatch_table = {};
auto device = absl::bit_cast<VkDevice>(&some_dispatch_table);
static bool was_called = false;
PFN_vkGetDeviceProcAddr next_get_device_proc_addr_function =
+[](VkDevice /*device*/, const char* name) -> PFN_vkVoidFunction {
if (strcmp(name, "vkResetQueryPoolEXT") == 0) {
PFN_vkResetQueryPoolEXT function = +[](VkDevice /*device*/, VkQueryPool /*query_pool*/,
uint32_t
/*first_query*/,
uint32_t /*query_count*/) { was_called = true; };
return absl::bit_cast<PFN_vkVoidFunction>(function);
}
return nullptr;
};
DispatchTable dispatch_table = {};
dispatch_table.CreateDeviceDispatchTable(device, next_get_device_proc_addr_function);
VkQueryPool query_pool = {};
dispatch_table.ResetQueryPoolEXT(device)(device, query_pool, 0, 0);
EXPECT_TRUE(was_called);
was_called = false;
}
TEST(DispatchTable, CanCallGetQueryPoolResults) {
VkLayerDispatchTable some_dispatch_table = {};
auto device = absl::bit_cast<VkDevice>(&some_dispatch_table);
PFN_vkGetDeviceProcAddr next_get_device_proc_addr_function =
+[](VkDevice /*device*/, const char* name) -> PFN_vkVoidFunction {
if (strcmp(name, "vkGetQueryPoolResults") == 0) {
PFN_vkGetQueryPoolResults function =
+[](VkDevice /*device*/, VkQueryPool /*query_pool*/, uint32_t /*first_query*/,
uint32_t /*query_count*/, size_t /*data_size*/, void* /*data*/,
VkDeviceSize /*stride*/,
VkQueryResultFlags /*flags*/) -> VkResult { return VK_SUCCESS; };
return absl::bit_cast<PFN_vkVoidFunction>(function);
}
return nullptr;
};
DispatchTable dispatch_table = {};
dispatch_table.CreateDeviceDispatchTable(device, next_get_device_proc_addr_function);
VkQueryPool query_pool = {};
VkResult result =
dispatch_table.GetQueryPoolResults(device)(device, query_pool, 0, 0, 0, nullptr, 0, 0);
EXPECT_EQ(result, VK_SUCCESS);
}
TEST(DispatchTable, CanCallCmdWriteTimestamp) {
VkLayerDispatchTable some_dispatch_table = {};
auto device = absl::bit_cast<VkDevice>(&some_dispatch_table);
static bool was_called = false;
PFN_vkGetDeviceProcAddr next_get_device_proc_addr_function =
+[](VkDevice /*device*/, const char* name) -> PFN_vkVoidFunction {
if (strcmp(name, "vkCmdWriteTimestamp") == 0) {
PFN_vkCmdWriteTimestamp function =
+[](VkCommandBuffer /*command_buffer*/, VkPipelineStageFlagBits /*pipeline_stage*/,
VkQueryPool /*query_pool*/, uint32_t /*query*/) { was_called = true; };
return absl::bit_cast<PFN_vkVoidFunction>(function);
}
return nullptr;
};
DispatchTable dispatch_table = {};
dispatch_table.CreateDeviceDispatchTable(device, next_get_device_proc_addr_function);
VkCommandBuffer command_buffer = {};
VkQueryPool query_pool = {};
dispatch_table.CmdWriteTimestamp(device)(command_buffer, VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT,
query_pool, 0);
EXPECT_TRUE(was_called);
was_called = false;
}
TEST(DispatchTable, CanCallCmdBeginDebugUtilsLabelEXT) {
VkLayerDispatchTable some_dispatch_table = {};
auto device = absl::bit_cast<VkDevice>(&some_dispatch_table);
static bool was_called = false;
PFN_vkGetDeviceProcAddr next_get_device_proc_addr_function =
+[](VkDevice /*device*/, const char* name) -> PFN_vkVoidFunction {
if (strcmp(name, "vkCmdBeginDebugUtilsLabelEXT") == 0) {
PFN_vkCmdBeginDebugUtilsLabelEXT function =
+[](VkCommandBuffer /*command_buffer*/, const VkDebugUtilsLabelEXT* /*label_info*/) {
was_called = true;
};
return absl::bit_cast<PFN_vkVoidFunction>(function);
}
return nullptr;
};
DispatchTable dispatch_table = {};
dispatch_table.CreateDeviceDispatchTable(device, next_get_device_proc_addr_function);
VkCommandBuffer command_buffer = {};
dispatch_table.CmdBeginDebugUtilsLabelEXT(device)(command_buffer, nullptr);
EXPECT_TRUE(was_called);
was_called = false;
}
TEST(DispatchTable, CanCallCmdEndDebugUtilsLabelEXT) {
VkLayerDispatchTable some_dispatch_table = {};
auto device = absl::bit_cast<VkDevice>(&some_dispatch_table);
static bool was_called = false;
PFN_vkGetDeviceProcAddr next_get_device_proc_addr_function =
+[](VkDevice /*device*/, const char* name) -> PFN_vkVoidFunction {
if (strcmp(name, "vkCmdEndDebugUtilsLabelEXT") == 0) {
PFN_vkCmdEndDebugUtilsLabelEXT function =
+[](VkCommandBuffer /*command_buffer*/) { was_called = true; };
return absl::bit_cast<PFN_vkVoidFunction>(function);
}
return nullptr;
};
DispatchTable dispatch_table = {};
dispatch_table.CreateDeviceDispatchTable(device, next_get_device_proc_addr_function);
VkCommandBuffer command_buffer = {};
dispatch_table.CmdEndDebugUtilsLabelEXT(device)(command_buffer);
EXPECT_TRUE(was_called);
was_called = false;
}
TEST(DispatchTable, CanCallCmdInsertDebugUtilsLabelEXT) {
VkLayerDispatchTable some_dispatch_table = {};
auto device = absl::bit_cast<VkDevice>(&some_dispatch_table);
static bool was_called = false;
PFN_vkGetDeviceProcAddr next_get_device_proc_addr_function =
+[](VkDevice /*device*/, const char* name) -> PFN_vkVoidFunction {
if (strcmp(name, "vkCmdInsertDebugUtilsLabelEXT") == 0) {
PFN_vkCmdInsertDebugUtilsLabelEXT function =
+[](VkCommandBuffer /*command_buffer*/, const VkDebugUtilsLabelEXT* /*label_info*/) {
was_called = true;
};
return absl::bit_cast<PFN_vkVoidFunction>(function);
}
return nullptr;
};
DispatchTable dispatch_table = {};
dispatch_table.CreateDeviceDispatchTable(device, next_get_device_proc_addr_function);
VkCommandBuffer command_buffer = {};
dispatch_table.CmdInsertDebugUtilsLabelEXT(device)(command_buffer, nullptr);
EXPECT_TRUE(was_called);
was_called = false;
}
TEST(DispatchTable, CanCallSetDebugUtilsObjectNameEXT) {
VkLayerDispatchTable some_dispatch_table = {};
auto device = absl::bit_cast<VkDevice>(&some_dispatch_table);
PFN_vkGetDeviceProcAddr next_get_device_proc_addr_function =
+[](VkDevice /*device*/, const char* name) -> PFN_vkVoidFunction {
if (strcmp(name, "vkSetDebugUtilsObjectNameEXT") == 0) {
PFN_vkSetDebugUtilsObjectNameEXT function =
+[](VkDevice /*device*/, const VkDebugUtilsObjectNameInfoEXT *
/*name_info*/) -> VkResult { return VK_SUCCESS; };
return absl::bit_cast<PFN_vkVoidFunction>(function);
}
return nullptr;
};
DispatchTable dispatch_table = {};
dispatch_table.CreateDeviceDispatchTable(device, next_get_device_proc_addr_function);
VkResult result = dispatch_table.SetDebugUtilsObjectNameEXT(device)(device, nullptr);
EXPECT_EQ(result, VK_SUCCESS);
}
TEST(DispatchTable, CanCallSetDebugUtilsObjectTagEXT) {
VkLayerDispatchTable some_dispatch_table = {};
auto device = absl::bit_cast<VkDevice>(&some_dispatch_table);
PFN_vkGetDeviceProcAddr next_get_device_proc_addr_function =
+[](VkDevice /*device*/, const char* name) -> PFN_vkVoidFunction {
if (strcmp(name, "vkSetDebugUtilsObjectTagEXT") == 0) {
PFN_vkSetDebugUtilsObjectTagEXT function =
+[](VkDevice /*device*/, const VkDebugUtilsObjectTagInfoEXT *
/*tag_info*/) -> VkResult { return VK_SUCCESS; };
return absl::bit_cast<PFN_vkVoidFunction>(function);
}
return nullptr;
};
DispatchTable dispatch_table = {};
dispatch_table.CreateDeviceDispatchTable(device, next_get_device_proc_addr_function);
VkResult result = dispatch_table.SetDebugUtilsObjectTagEXT(device)(device, nullptr);
EXPECT_EQ(result, VK_SUCCESS);
}
TEST(DispatchTable, CanCallQueueBeginDebugUtilsLabelEXT) {
VkLayerDispatchTable some_dispatch_table = {};
auto device = absl::bit_cast<VkDevice>(&some_dispatch_table);
static bool was_called = false;
PFN_vkGetDeviceProcAddr next_get_device_proc_addr_function =
+[](VkDevice /*device*/, const char* name) -> PFN_vkVoidFunction {
if (strcmp(name, "vkQueueBeginDebugUtilsLabelEXT") == 0) {
PFN_vkQueueBeginDebugUtilsLabelEXT function =
+[](VkQueue /*queue*/, const VkDebugUtilsLabelEXT*
/*label_info*/) { was_called = true; };
return absl::bit_cast<PFN_vkVoidFunction>(function);
}
return nullptr;
};
DispatchTable dispatch_table = {};
dispatch_table.CreateDeviceDispatchTable(device, next_get_device_proc_addr_function);
VkQueue queue = {};
dispatch_table.QueueBeginDebugUtilsLabelEXT(device)(queue, nullptr);
EXPECT_TRUE(was_called);
was_called = false;
}
TEST(DispatchTable, CanCallQueueEndDebugUtilsLabelEXT) {
VkLayerDispatchTable some_dispatch_table = {};
auto device = absl::bit_cast<VkDevice>(&some_dispatch_table);
static bool was_called = false;
PFN_vkGetDeviceProcAddr next_get_device_proc_addr_function =
+[](VkDevice /*device*/, const char* name) -> PFN_vkVoidFunction {
if (strcmp(name, "vkQueueEndDebugUtilsLabelEXT") == 0) {
PFN_vkQueueEndDebugUtilsLabelEXT function = +[](VkQueue /*queue*/) { was_called = true; };
return absl::bit_cast<PFN_vkVoidFunction>(function);
}
return nullptr;
};
DispatchTable dispatch_table = {};
dispatch_table.CreateDeviceDispatchTable(device, next_get_device_proc_addr_function);
VkQueue queue = {};
dispatch_table.QueueEndDebugUtilsLabelEXT(device)(queue);
EXPECT_TRUE(was_called);
was_called = false;
}
TEST(DispatchTable, CanCallQueueInsertDebugUtilsLabelEXT) {
VkLayerDispatchTable some_dispatch_table = {};
auto device = absl::bit_cast<VkDevice>(&some_dispatch_table);
static bool was_called = false;
PFN_vkGetDeviceProcAddr next_get_device_proc_addr_function =
+[](VkDevice /*device*/, const char* name) -> PFN_vkVoidFunction {
if (strcmp(name, "vkQueueInsertDebugUtilsLabelEXT") == 0) {
PFN_vkQueueInsertDebugUtilsLabelEXT function =
+[](VkQueue /*queue*/, const VkDebugUtilsLabelEXT*
/*label_info*/) { was_called = true; };
return absl::bit_cast<PFN_vkVoidFunction>(function);
}
return nullptr;
};
DispatchTable dispatch_table = {};
dispatch_table.CreateDeviceDispatchTable(device, next_get_device_proc_addr_function);
VkQueue queue = {};
dispatch_table.QueueInsertDebugUtilsLabelEXT(device)(queue, nullptr);
EXPECT_TRUE(was_called);
was_called = false;
}
TEST(DispatchTable, CanCallCreateDebugUtilsMessengerEXT) {
VkLayerInstanceDispatchTable some_dispatch_table = {};
auto instance = absl::bit_cast<VkInstance>(&some_dispatch_table);
PFN_vkGetInstanceProcAddr next_get_instance_proc_addr_function =
+[](VkInstance /*instance*/, const char* name) -> PFN_vkVoidFunction {
if (strcmp(name, "vkCreateDebugUtilsMessengerEXT") == 0) {
PFN_vkCreateDebugUtilsMessengerEXT function =
+[](VkInstance /*instance*/, const VkDebugUtilsMessengerCreateInfoEXT* /*create_info*/,
const VkAllocationCallbacks* /*allocator*/, VkDebugUtilsMessengerEXT *
/*messenger*/) -> VkResult { return VK_SUCCESS; };
return absl::bit_cast<PFN_vkVoidFunction>(function);
}
return nullptr;
};
DispatchTable dispatch_table = {};
dispatch_table.CreateInstanceDispatchTable(instance, next_get_instance_proc_addr_function);
VkResult result =
dispatch_table.CreateDebugUtilsMessengerEXT(instance)(instance, nullptr, nullptr, nullptr);
EXPECT_EQ(result, VK_SUCCESS);
}
TEST(DispatchTable, CanCallDestroyDebugUtilsMessengerEXT) {
VkLayerInstanceDispatchTable some_dispatch_table = {};
auto instance = absl::bit_cast<VkInstance>(&some_dispatch_table);
static bool was_called = false;
PFN_vkGetInstanceProcAddr next_get_instance_proc_addr_function =
+[](VkInstance /*instance*/, const char* name) -> PFN_vkVoidFunction {
if (strcmp(name, "vkDestroyDebugUtilsMessengerEXT") == 0) {
PFN_vkDestroyDebugUtilsMessengerEXT function =
+[](VkInstance /*instance*/, VkDebugUtilsMessengerEXT /*messenger*/,
const VkAllocationCallbacks* /*allocator*/) { was_called = true; };
return absl::bit_cast<PFN_vkVoidFunction>(function);
}
return nullptr;
};
DispatchTable dispatch_table = {};
dispatch_table.CreateInstanceDispatchTable(instance, next_get_instance_proc_addr_function);
VkDebugUtilsMessengerEXT messenger{};
dispatch_table.DestroyDebugUtilsMessengerEXT(instance)(instance, messenger, nullptr);
EXPECT_TRUE(was_called);
was_called = false;
}
TEST(DispatchTable, CanCallSubmitDebugUtilsMessageEXT) {
VkLayerInstanceDispatchTable some_dispatch_table = {};
auto instance = absl::bit_cast<VkInstance>(&some_dispatch_table);
static bool was_called = false;
PFN_vkGetInstanceProcAddr next_get_instance_proc_addr_function =
+[](VkInstance /*instance*/, const char* name) -> PFN_vkVoidFunction {
if (strcmp(name, "vkSubmitDebugUtilsMessageEXT") == 0) {
PFN_vkSubmitDebugUtilsMessageEXT function =
+[](VkInstance /*instance*/, VkDebugUtilsMessageSeverityFlagBitsEXT /*message_severity*/,
VkDebugUtilsMessageTypeFlagsEXT /*message_types*/,
const VkDebugUtilsMessengerCallbackDataEXT* /*callback_data*/) { was_called = true; };
return absl::bit_cast<PFN_vkVoidFunction>(function);
}
return nullptr;
};
DispatchTable dispatch_table = {};
dispatch_table.CreateInstanceDispatchTable(instance, next_get_instance_proc_addr_function);
VkDebugUtilsMessageSeverityFlagBitsEXT message_severity{};
VkDebugUtilsMessageTypeFlagsEXT message_types{};
dispatch_table.SubmitDebugUtilsMessageEXT(instance)(instance, message_severity, message_types,
nullptr);
EXPECT_TRUE(was_called);
was_called = false;
}
TEST(DispatchTable, CanCallCreateDebugReportCallbackEXT) {
VkLayerInstanceDispatchTable some_dispatch_table = {};
auto instance = absl::bit_cast<VkInstance>(&some_dispatch_table);
PFN_vkGetInstanceProcAddr next_get_instance_proc_addr_function =
+[](VkInstance /*instance*/, const char* name) -> PFN_vkVoidFunction {
if (strcmp(name, "vkCreateDebugReportCallbackEXT") == 0) {
PFN_vkCreateDebugReportCallbackEXT function =
+[](VkInstance /*instance*/, const VkDebugReportCallbackCreateInfoEXT* /*create_info*/,
const VkAllocationCallbacks* /*allocator*/, VkDebugReportCallbackEXT *
/*messenger*/) -> VkResult { return VK_SUCCESS; };
return absl::bit_cast<PFN_vkVoidFunction>(function);
}
return nullptr;
};
DispatchTable dispatch_table = {};
dispatch_table.CreateInstanceDispatchTable(instance, next_get_instance_proc_addr_function);
VkResult result =
dispatch_table.CreateDebugReportCallbackEXT(instance)(instance, nullptr, nullptr, nullptr);
EXPECT_EQ(result, VK_SUCCESS);
}
TEST(DispatchTable, CanCallDestroyDebugReportCallbackEXT) {
VkLayerInstanceDispatchTable some_dispatch_table = {};
auto instance = absl::bit_cast<VkInstance>(&some_dispatch_table);
static bool was_called = false;
PFN_vkGetInstanceProcAddr next_get_instance_proc_addr_function =
+[](VkInstance /*instance*/, const char* name) -> PFN_vkVoidFunction {
if (strcmp(name, "vkDestroyDebugReportCallbackEXT") == 0) {
PFN_vkDestroyDebugReportCallbackEXT function =
+[](VkInstance /*instance*/, VkDebugReportCallbackEXT /*messenger*/,
const VkAllocationCallbacks* /*allocator*/) { was_called = true; };
return absl::bit_cast<PFN_vkVoidFunction>(function);
}
return nullptr;
};
DispatchTable dispatch_table = {};
dispatch_table.CreateInstanceDispatchTable(instance, next_get_instance_proc_addr_function);
VkDebugReportCallbackEXT messenger{};
dispatch_table.DestroyDebugReportCallbackEXT(instance)(instance, messenger, nullptr);
EXPECT_TRUE(was_called);
was_called = false;
}
TEST(DispatchTable, CanCallDebugReportMessageEXT) {
VkLayerInstanceDispatchTable some_dispatch_table = {};
auto instance = absl::bit_cast<VkInstance>(&some_dispatch_table);
static bool was_called = false;
PFN_vkGetInstanceProcAddr next_get_instance_proc_addr_function =
+[](VkInstance /*instance*/, const char* name) -> PFN_vkVoidFunction {
if (strcmp(name, "vkDebugReportMessageEXT") == 0) {
PFN_vkDebugReportMessageEXT function =
+[](VkInstance /*instance*/, VkDebugReportFlagsEXT /*flags*/,
VkDebugReportObjectTypeEXT /*object_type*/, uint64_t /*object*/, size_t /*location*/,
int32_t /*message_code*/, const char* /*layer_prefix*/,
const char* /*message*/) { was_called = true; };
return absl::bit_cast<PFN_vkVoidFunction>(function);
}
return nullptr;
};
DispatchTable dispatch_table = {};
dispatch_table.CreateInstanceDispatchTable(instance, next_get_instance_proc_addr_function);
VkDebugReportFlagsEXT flags{};
VkDebugReportObjectTypeEXT object_type{};
dispatch_table.DebugReportMessageEXT(instance)(instance, flags, object_type, 0, 0, 0, nullptr,
nullptr);
EXPECT_TRUE(was_called);
was_called = false;
}
TEST(DispatchTable, CanCallCmdDebugMarkerBeginEXT) {
VkLayerDispatchTable some_dispatch_table = {};
auto device = absl::bit_cast<VkDevice>(&some_dispatch_table);
static bool was_called = false;
PFN_vkGetDeviceProcAddr next_get_device_proc_addr_function =
+[](VkDevice /*device*/, const char* name) -> PFN_vkVoidFunction {
if (strcmp(name, "vkCmdDebugMarkerBeginEXT") == 0) {
PFN_vkCmdDebugMarkerBeginEXT function =
+[](VkCommandBuffer /*command_buffer*/,
const VkDebugMarkerMarkerInfoEXT* /*marker_info*/) { was_called = true; };
return absl::bit_cast<PFN_vkVoidFunction>(function);
}
return nullptr;
};
DispatchTable dispatch_table = {};
dispatch_table.CreateDeviceDispatchTable(device, next_get_device_proc_addr_function);
VkCommandBuffer command_buffer = {};
dispatch_table.CmdDebugMarkerBeginEXT(device)(command_buffer, nullptr);
EXPECT_TRUE(was_called);
was_called = false;
}
TEST(DispatchTable, CanCallCmdDebugMarkerEndEXT) {
VkLayerDispatchTable some_dispatch_table = {};
auto device = absl::bit_cast<VkDevice>(&some_dispatch_table);
static bool was_called = false;
PFN_vkGetDeviceProcAddr next_get_device_proc_addr_function =
+[](VkDevice /*device*/, const char* name) -> PFN_vkVoidFunction {
if (strcmp(name, "vkCmdDebugMarkerEndEXT") == 0) {
PFN_vkCmdDebugMarkerEndEXT function =
+[](VkCommandBuffer /*command_buffer*/) { was_called = true; };
return absl::bit_cast<PFN_vkVoidFunction>(function);
}
return nullptr;
};
DispatchTable dispatch_table = {};
dispatch_table.CreateDeviceDispatchTable(device, next_get_device_proc_addr_function);
VkCommandBuffer command_buffer = {};
dispatch_table.CmdDebugMarkerEndEXT(device)(command_buffer);
EXPECT_TRUE(was_called);
was_called = false;
}
TEST(DispatchTable, CanCallCmdDebugMarkerInsertEXT) {
VkLayerDispatchTable some_dispatch_table = {};
auto device = absl::bit_cast<VkDevice>(&some_dispatch_table);
static bool was_called = false;
PFN_vkGetDeviceProcAddr next_get_device_proc_addr_function =
+[](VkDevice /*device*/, const char* name) -> PFN_vkVoidFunction {
if (strcmp(name, "vkCmdDebugMarkerInsertEXT") == 0) {
PFN_vkCmdDebugMarkerInsertEXT function =
+[](VkCommandBuffer /*command_buffer*/,
const VkDebugMarkerMarkerInfoEXT* /*marker_info*/) { was_called = true; };
return absl::bit_cast<PFN_vkVoidFunction>(function);
}
return nullptr;
};
DispatchTable dispatch_table = {};
dispatch_table.CreateDeviceDispatchTable(device, next_get_device_proc_addr_function);
VkCommandBuffer command_buffer = {};
dispatch_table.CmdDebugMarkerInsertEXT(device)(command_buffer, nullptr);
EXPECT_TRUE(was_called);
was_called = false;
}
TEST(DispatchTable, CanCallDebugMarkerSetObjectTagEXT) {
VkLayerDispatchTable some_dispatch_table = {};
auto device = absl::bit_cast<VkDevice>(&some_dispatch_table);
PFN_vkGetDeviceProcAddr next_get_device_proc_addr_function =
+[](VkDevice /*device*/, const char* name) -> PFN_vkVoidFunction {
if (strcmp(name, "vkDebugMarkerSetObjectTagEXT") == 0) {
PFN_vkDebugMarkerSetObjectTagEXT function =
+[](VkDevice /*device*/, const VkDebugMarkerObjectTagInfoEXT * /*tag_info*/) -> VkResult {
return VK_SUCCESS;
};
return absl::bit_cast<PFN_vkVoidFunction>(function);
}
return nullptr;
};
DispatchTable dispatch_table = {};
dispatch_table.CreateDeviceDispatchTable(device, next_get_device_proc_addr_function);
VkResult result = dispatch_table.DebugMarkerSetObjectTagEXT(device)(device, nullptr);
EXPECT_EQ(result, VK_SUCCESS);
}
TEST(DispatchTable, CanCallDebugMarkerSetObjectNameEXT) {
VkLayerDispatchTable some_dispatch_table = {};
auto device = absl::bit_cast<VkDevice>(&some_dispatch_table);
PFN_vkGetDeviceProcAddr next_get_device_proc_addr_function =
+[](VkDevice /*device*/, const char* name) -> PFN_vkVoidFunction {
if (strcmp(name, "vkDebugMarkerSetObjectNameEXT") == 0) {
PFN_vkDebugMarkerSetObjectNameEXT function =
+[](VkDevice /*device*/, const VkDebugMarkerObjectNameInfoEXT *
/*name_info*/) -> VkResult { return VK_SUCCESS; };
return absl::bit_cast<PFN_vkVoidFunction>(function);
}
return nullptr;
};
DispatchTable dispatch_table = {};
dispatch_table.CreateDeviceDispatchTable(device, next_get_device_proc_addr_function);
VkResult result = dispatch_table.DebugMarkerSetObjectNameEXT(device)(device, nullptr);
EXPECT_EQ(result, VK_SUCCESS);
}
} // namespace orbit_vulkan_layer | 41.62766 | 100 | 0.729344 | [
"object"
] |
eb80410979b4d8038d84eb47029bde98df9f153c | 5,780 | cc | C++ | chromeos/dbus/ibus/ibus_lookup_table.cc | 1065672644894730302/Chromium | 239dd49e906be4909e293d8991e998c9816eaa35 | [
"BSD-3-Clause"
] | 1 | 2019-04-23T15:57:04.000Z | 2019-04-23T15:57:04.000Z | chromeos/dbus/ibus/ibus_lookup_table.cc | 1065672644894730302/Chromium | 239dd49e906be4909e293d8991e998c9816eaa35 | [
"BSD-3-Clause"
] | null | null | null | chromeos/dbus/ibus/ibus_lookup_table.cc | 1065672644894730302/Chromium | 239dd49e906be4909e293d8991e998c9816eaa35 | [
"BSD-3-Clause"
] | null | null | null | // Copyright (c) 2012 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 "chromeos/dbus/ibus/ibus_lookup_table.h"
#include <string>
#include "base/logging.h"
#include "dbus/message.h"
#include "chromeos/dbus/ibus/ibus_text.h"
#include "chromeos/dbus/ibus/ibus_object.h"
namespace chromeos {
// TODO(nona): Remove ibus namespace after complete libibus removal.
namespace ibus {
void AppendIBusLookupTable(const IBusLookupTable& table,
dbus::MessageWriter* writer) {
IBusObjectWriter ibus_lookup_table_writer("IBusLookupTable",
"uubbiavav",
writer);
ibus_lookup_table_writer.AppendUint32(table.page_size());
ibus_lookup_table_writer.AppendUint32(table.cursor_position());
ibus_lookup_table_writer.AppendBool(table.is_cursor_visible());
ibus_lookup_table_writer.AppendBool(false); // Not used in Chrome.
ibus_lookup_table_writer.AppendInt32(static_cast<int32>(table.orientation()));
const std::vector<IBusLookupTable::Entry>& candidates = table.candidates();
dbus::MessageWriter text_writer(NULL);
ibus_lookup_table_writer.OpenArray("v", &text_writer);
bool have_labels = false;
for (size_t i = 0; i < candidates.size(); ++i) {
// Write candidate string as IBusText.
AppendStringAsIBusText(candidates[i].value, &text_writer);
if (!candidates[i].label.empty())
have_labels = true;
}
ibus_lookup_table_writer.CloseContainer(&text_writer);
dbus::MessageWriter label_writer(NULL);
ibus_lookup_table_writer.OpenArray("v", &label_writer);
// If there are not any labels, don't append labels.
if (have_labels) {
for (size_t i = 0; i < candidates.size(); ++i) {
// Write label string as IBusText.
AppendStringAsIBusText(candidates[i].label, &label_writer);
}
}
ibus_lookup_table_writer.CloseContainer(&label_writer);
ibus_lookup_table_writer.CloseAll();
}
bool PopIBusLookupTable(dbus::MessageReader* reader, IBusLookupTable* table) {
IBusObjectReader ibus_object_reader("IBusLookupTable", reader);
if (!ibus_object_reader.Init())
return false;
uint32 page_size = 0;
if (!ibus_object_reader.PopUint32(&page_size)) {
LOG(ERROR) << "Invalid variant structure[IBusLookupTable]: "
<< "1st argument should be uint32.";
return false;
}
table->set_page_size(page_size);
uint32 cursor_position = 0;
if (!ibus_object_reader.PopUint32(&cursor_position)) {
LOG(ERROR) << "Invalid variant structure[IBusLookupTable]: "
<< "2nd argument should be uint32.";
return false;
}
table->set_cursor_position(cursor_position);
bool cursor_visible = true;
if (!ibus_object_reader.PopBool(&cursor_visible)) {
LOG(ERROR) << "Invalid variant structure[IBusLookupTable]: "
<< "3rd arugment should be boolean.";
return false;
}
table->set_is_cursor_visible(cursor_visible);
bool unused_round_value = true;
if (!ibus_object_reader.PopBool(&unused_round_value)) {
LOG(ERROR) << "Invalid variant structure[IBusLookupTable]: "
<< "4th argument should be boolean.";
return false;
}
int32 orientation = 0;
if (!ibus_object_reader.PopInt32(&orientation)) {
LOG(ERROR) << "Invalid variant structure[IBusLookupTable]: "
<< "5th arguemnt should be int32.";
return false;
}
table->set_orientation(
static_cast<IBusLookupTable::Orientation>(orientation));
dbus::MessageReader text_array_reader(NULL);
if (!ibus_object_reader.PopArray(&text_array_reader)) {
LOG(ERROR) << "Invalid variant structure[IBusLookupTable]: "
<< "6th argument should be array.";
return false;
}
std::vector<IBusLookupTable::Entry>* candidates = table->mutable_candidates();
while (text_array_reader.HasMoreData()) {
std::string candidate_text;
// The attributes in IBusText are not used in Chrome.
if (!PopStringFromIBusText(&text_array_reader, &candidate_text)) {
LOG(ERROR) << "Invalid variant structure[IBusLookupTable]: "
<< "6th argument should be array of IBusText.";
return false;
}
IBusLookupTable::Entry entry;
entry.value = candidate_text;
candidates->push_back(entry);
}
dbus::MessageReader label_array_reader(NULL);
if (!ibus_object_reader.PopArray(&label_array_reader)) {
LOG(ERROR) << "Invalid variant structure[IBusLookupTable]: "
<< "7th argument should be array.";
return false;
}
if (!label_array_reader.HasMoreData()) {
return true;
}
for (size_t i = 0; i < candidates->size(); ++i) {
if (!label_array_reader.HasMoreData()) {
LOG(ERROR) << "Invalid variant structure[IBusLookupTable]: "
<< "The number of label entry does not match with candidate "
<< "text. Same length or no label entry can be accepted.";
return false;
}
std::string label_text;
// The attributes in IBusText are not used in Chrome.
if (!PopStringFromIBusText(&label_array_reader, &label_text)) {
LOG(ERROR) << "Invalid variant structure[IBusLookupTable]: "
<< "7th argument should be array of IBusText.";
return false;
}
(*candidates)[i].label = label_text;
}
return true;
}
///////////////////////////////////////////////////////////////////////////////
// IBusLookupTable
IBusLookupTable::IBusLookupTable()
: page_size_(0),
cursor_position_(0),
is_cursor_visible_(true),
orientation_(IBUS_LOOKUP_TABLE_ORIENTATION_HORIZONTAL) {
}
IBusLookupTable::~IBusLookupTable() {
}
} // namespace ibus
} // namespace chromeos
| 34.819277 | 80 | 0.675606 | [
"vector"
] |
eb87dea75b0cfd0c2c155ae9eb86469018ee4c7a | 25,135 | cpp | C++ | media_driver/agnostic/Xe_M/Xe_XPM_plus/vp/hal/vphal_render_composite_xe_xpm_plus.cpp | ashakhno/media-driver | 79c20b78a539afdb55b5fd0006e959f92c12fa64 | [
"Intel",
"BSD-3-Clause",
"MIT"
] | null | null | null | media_driver/agnostic/Xe_M/Xe_XPM_plus/vp/hal/vphal_render_composite_xe_xpm_plus.cpp | ashakhno/media-driver | 79c20b78a539afdb55b5fd0006e959f92c12fa64 | [
"Intel",
"BSD-3-Clause",
"MIT"
] | null | null | null | media_driver/agnostic/Xe_M/Xe_XPM_plus/vp/hal/vphal_render_composite_xe_xpm_plus.cpp | ashakhno/media-driver | 79c20b78a539afdb55b5fd0006e959f92c12fa64 | [
"Intel",
"BSD-3-Clause",
"MIT"
] | 1 | 2022-03-14T23:38:11.000Z | 2022-03-14T23:38:11.000Z | /*===================== begin_copyright_notice ==================================
# Copyright (c) 2021, Intel Corporation
# 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.
======================= end_copyright_notice ==================================*/
//!
//! \file vphal_render_composite_xe_xpm_plus.cpp
//! \brief Composite related VPHAL functions
//! \details Unified VP HAL Composite module including render initialization,
//! resource allocation/free and rendering
//!
#include "vphal_render_composite_xe_xpm_plus.h"
extern const Kdll_Layer g_cSurfaceType_Layer[];
extern const MEDIA_WALKER_KA2_STATIC_DATA g_cInit_MEDIA_WALKER_KA2_STATIC_DATA;
CompositeStateXe_Xpm_Plus::CompositeStateXe_Xpm_Plus (
PMOS_INTERFACE pOsInterface,
PRENDERHAL_INTERFACE pRenderHal,
PVPHAL_RNDR_PERF_DATA pPerfData,
const VPHAL_COMPOSITE_CACHE_CNTL &compositeCacheCntl,
MOS_STATUS *peStatus) :
CompositeState(pOsInterface, pRenderHal, pPerfData, compositeCacheCntl, peStatus),
CompositeStateG12(pOsInterface, pRenderHal, pPerfData, compositeCacheCntl, peStatus)
{
if (pRenderHal == nullptr)
{
*peStatus = MOS_STATUS_NULL_POINTER;
return;
}
m_bFtrComputeWalker = true;
m_need3DSampler = true;
m_bFtrCSCCoeffPatchMode = false;
}
void CompositeStateXe_Xpm_Plus::SetFilterScalingRatio(
Kdll_Scalingratio* ScalingRatio)
{
VPHAL_RENDER_ASSERT(ScalingRatio);
if((m_fScaleX > (1.0f+ (1.0f/6.0f))) && (m_fScaleY > (1.0f + (1.0f / 6.0f))))
{
*ScalingRatio = Scalingratio_over1;
}
else if((m_fScaleX > 0.5f) && (m_fScaleY > 0.5f))
{
*ScalingRatio = Scalingratio_b1p2to1;
}
else if((m_fScaleX > 0.25f) && (m_fScaleY > 0.25f))
{
*ScalingRatio = Scalingratio_b1p4to1p2;
}
// disable 1/8 sclaing ratio due to kernel complex, and use Any Scaling ratio replace.
/*
else if ((m_fScaleX > 0.125f) && (m_fScaleY > 0.125f))
{
*ScalingRatio = Scalingratio_b1p8to1p4;
}*/
else
{
*ScalingRatio = Scalingratio_Any;
}
}
void CompositeStateXe_Xpm_Plus::CaculateBlockSize(
uint32_t* uiBlockSize)
{
VPHAL_RENDER_ASSERT(uiBlockSize);
if ((m_fScaleX > (1.0f + (1.0f / 6.0f))) && (m_fScaleY > (1.0f + (1.0f / 6.0f))))
{
*uiBlockSize = 16;
}
else if((m_fScaleX > 0.5f) && (m_fScaleY > 0.5f))
{
*uiBlockSize = 8;
}
else
{
*uiBlockSize = 4;
}
}
MOS_STATUS CompositeStateXe_Xpm_Plus::RenderInit(
PVPHAL_COMPOSITE_PARAMS pCompParams,
PVPHAL_RENDERING_DATA_COMPOSITE pRenderingData)
{
PRENDERHAL_INTERFACE pRenderHal;
RECT AlignedRect;
uint32_t uiMediaWalkerBlockSize;
PRECT pDst;
PVPHAL_SURFACE pSource;
MOS_STATUS eStatus = MOS_STATUS_SUCCESS;
VPHAL_RENDER_CHK_NULL(m_pRenderHal);
VPHAL_RENDER_CHK_NULL(pCompParams);
VPHAL_RENDER_CHK_NULL(pRenderingData);
pRenderHal = m_pRenderHal;
//============================
// Set rendering data
//============================
MOS_ZeroMemory(pRenderingData, sizeof(VPHAL_RENDERING_DATA_COMPOSITE));
pSource = pCompParams->pSource[0];
VPHAL_RENDER_CHK_NULL(pSource);
// Set output area
if (pCompParams->uTargetCount == 2)
{
// Output rectangle based on non-rotated target in case of dual output
pRenderingData->BbArgs.rcOutput = pCompParams->Target[1].rcDst;
pRenderingData->pTarget[1] = &pCompParams->Target[1];
}
else
{
pRenderingData->BbArgs.rcOutput = pCompParams->Target[0].rcDst;
}
pDst = &(pRenderingData->BbArgs.rcOutput);
// Set sources
pRenderingData->iLayers = 0;
pRenderingData->pTarget[0] = &pCompParams->Target[0];
pRenderingData->pColorFill = pCompParams->pColorFillParams;
pRenderingData->pCompAlpha = pCompParams->pCompAlpha;
// Set constriction parameters
pRenderingData->pConstriction = pCompParams->pConstriction;
if (pCompParams->pConstriction)
{
pRenderingData->ConstrictionOriginX = pDst->left;
pRenderingData->ConstrictionOriginY = pDst->top;
pRenderingData->fConstrictionStepX = (pDst->right - pDst->left) * 1.0f /
pCompParams->pConstriction->right;
pRenderingData->fConstrictionStepY = (pDst->bottom - pDst->top) * 1.0f /
pCompParams->pConstriction->bottom;
}
else
{
pRenderingData->ConstrictionOriginX = 0;
pRenderingData->ConstrictionOriginY = 0;
pRenderingData->fConstrictionStepX = 1.0f;
pRenderingData->fConstrictionStepY = 1.0f;
}
// Source rectangle is pre-rotated, destination rectangle is post-rotated.
if (pSource->Rotation == VPHAL_ROTATION_IDENTITY ||
pSource->Rotation == VPHAL_ROTATION_180 ||
pSource->Rotation == VPHAL_MIRROR_HORIZONTAL ||
pSource->Rotation == VPHAL_MIRROR_VERTICAL)
{
m_fScaleX = (float)(pSource->rcDst.right - pSource->rcDst.left) /
(float)(pSource->rcSrc.right - pSource->rcSrc.left);
m_fScaleY = (float)(pSource->rcDst.bottom - pSource->rcDst.top) /
(float)(pSource->rcSrc.bottom - pSource->rcSrc.top);
}
else
{
// VPHAL_ROTATION_90 || VPHAL_ROTATION_270 ||
// VPHAL_ROTATE_90_MIRROR_HORIZONTAL || VPHAL_ROTATE_90_MIRROR_VERTICAL
m_fScaleX = (float)(pSource->rcDst.right - pSource->rcDst.left) /
(float)(pSource->rcSrc.bottom - pSource->rcSrc.top);
m_fScaleY = (float)(pSource->rcDst.bottom - pSource->rcDst.top) /
(float)(pSource->rcSrc.right - pSource->rcSrc.left);
}
if (pRenderingData->pConstriction)
{
m_fScaleX /= pRenderingData->fConstrictionStepX;
m_fScaleX /= pRenderingData->fConstrictionStepY;
}
uiMediaWalkerBlockSize = 16;
CaculateBlockSize(&uiMediaWalkerBlockSize);
// Calculate aligned output area in order to determine the total # blocks to process
// in case of non-16x16 aligned target
AlignedRect = *pDst;
AlignedRect.right += uiMediaWalkerBlockSize - 1;
AlignedRect.bottom += uiMediaWalkerBlockSize - 1;
AlignedRect.left -= AlignedRect.left % uiMediaWalkerBlockSize;
AlignedRect.top -= AlignedRect.top % uiMediaWalkerBlockSize;
AlignedRect.right -= AlignedRect.right % uiMediaWalkerBlockSize;
AlignedRect.bottom -= AlignedRect.bottom % uiMediaWalkerBlockSize;
// Set number of blocks
pRenderingData->iBlocksX =
(AlignedRect.right - AlignedRect.left) / uiMediaWalkerBlockSize;
pRenderingData->iBlocksY =
(AlignedRect.bottom - AlignedRect.top) / uiMediaWalkerBlockSize;
// Set AVS and 8x8 table from renderer
pRenderingData->pAvsParams = &m_AvsParameters;
// Init extension data to nullptr
pRenderingData->pExtensionData = nullptr;
// Initialize rendering states
pRenderingData->Static = {0};
pRenderingData->Inline = {0};
pRenderingData->WalkerStatic = {0};
pRenderingData->DPFCStatic = {0};
// By default, alpha is calculated in PartBlend kernel
pRenderingData->bAlphaCalculateEnable = false;
// Reset Sampler Params
MOS_ZeroMemory(
pRenderingData->SamplerStateParams,
sizeof(pRenderingData->SamplerStateParams));
finish:
return eStatus;
}
bool CompositeStateXe_Xpm_Plus::RenderBufferComputeWalker(
PMHW_BATCH_BUFFER pBatchBuffer,
PVPHAL_RENDERING_DATA_COMPOSITE pRenderingData,
PMHW_GPGPU_WALKER_PARAMS pWalkerParams)
{
PRENDERHAL_INTERFACE pRenderHal;
MEDIA_DP_FC_STATIC_DATA *pDPWalkerStatic;
PVPHAL_BB_COMP_ARGS pBbArgs;
bool bResult;
int32_t iLayers;
uint32_t uiMediaWalkerBlockSize;
uint32_t* pdwDestXYTopLeft;
uint32_t* pdwDestXYBottomRight;
RECT AlignedRect;
MOS_UNUSED(pBatchBuffer);
bResult = false;
pRenderHal = m_pRenderHal;
pBbArgs = &pRenderingData->BbArgs;
pDPWalkerStatic = &pRenderingData->DPFCStatic;
VPHAL_RENDER_ASSERT(m_bFtrMediaWalker && !pBatchBuffer);
pdwDestXYTopLeft = (uint32_t*)(&pDPWalkerStatic->DW13);
pdwDestXYBottomRight = (uint32_t*)(&pDPWalkerStatic->DW14);
// GRF7.0-7, GRF8.0-7
for (iLayers = 0;
iLayers < pBbArgs->iLayers;
iLayers++, pdwDestXYBottomRight++, pdwDestXYTopLeft++)
{
*pdwDestXYTopLeft = (pBbArgs->rcDst[iLayers].top << 16 ) |
pBbArgs->rcDst[iLayers].left;
*pdwDestXYBottomRight = ((pBbArgs->rcDst[iLayers].bottom - 1) << 16 ) |
(pBbArgs->rcDst[iLayers].right - 1);
VPHAL_RENDER_NORMALMESSAGE("Scaling Info: layer %d, DestXTopLeft %d, DestYTopLeft %d, DestXBottomRight %d, DestYBottomRight %d",
iLayers, pBbArgs->rcDst[iLayers].left, pBbArgs->rcDst[iLayers].top, pBbArgs->rcDst[iLayers].right - 1, pBbArgs->rcDst[iLayers].bottom - 1);
}
if (pRenderingData->pTarget[1] == nullptr)
{
AlignedRect = pRenderingData->pTarget[0]->rcDst;
}
else
{
AlignedRect = pRenderingData->pTarget[1]->rcDst;
}
// Get media walker kernel block size
uiMediaWalkerBlockSize = pRenderHal->pHwSizes->dwSizeMediaWalkerBlock;
CaculateBlockSize(&uiMediaWalkerBlockSize);
// Calculate aligned output area in order to determine the total # blocks
// to process in case of non-16x16 aligned target.
AlignedRect.right += uiMediaWalkerBlockSize - 1;
AlignedRect.bottom += uiMediaWalkerBlockSize - 1;
AlignedRect.left -= AlignedRect.left % uiMediaWalkerBlockSize;
AlignedRect.top -= AlignedRect.top % uiMediaWalkerBlockSize;
AlignedRect.right -= AlignedRect.right % uiMediaWalkerBlockSize;
AlignedRect.bottom -= AlignedRect.bottom % uiMediaWalkerBlockSize;
// Set walker cmd params - Rasterscan
pWalkerParams->InterfaceDescriptorOffset = pRenderingData->iMediaID;
pWalkerParams->GroupStartingX = (AlignedRect.left / uiMediaWalkerBlockSize);
pWalkerParams->GroupStartingY = (AlignedRect.top / uiMediaWalkerBlockSize);
pWalkerParams->GroupWidth = pRenderingData->iBlocksX;
pWalkerParams->GroupHeight = pRenderingData->iBlocksY;
pWalkerParams->ThreadWidth = VPHAL_COMP_COMPUTE_WALKER_THREAD_SPACE_WIDTH;
pWalkerParams->ThreadHeight = VPHAL_COMP_COMPUTE_WALKER_THREAD_SPACE_HEIGHT;
pWalkerParams->ThreadDepth = VPHAL_COMP_COMPUTE_WALKER_THREAD_SPACE_DEPTH;
pWalkerParams->IndirectDataStartAddress = pRenderingData->iCurbeOffset;
// Indirect Data Length is a multiple of 64 bytes (size of L3 cacheline). Bits [5:0] are zero.
pWalkerParams->IndirectDataLength = MOS_ALIGN_CEIL(pRenderingData->iCurbeLength, 1 << MHW_COMPUTE_INDIRECT_SHIFT);
pWalkerParams->BindingTableID = pRenderingData->iBindingTable;
bResult = true;
return bResult;
}
bool CompositeStateXe_Xpm_Plus::SubmitStates(
PVPHAL_RENDERING_DATA_COMPOSITE pRenderingData)
{
// States and objects
PRENDERHAL_INTERFACE pRenderHal;
Kdll_State *pKernelDllState; // Kernel DLL state
Kdll_CacheEntry *pKernelEntry; // Media kernel entry
float pfCscMatrix[12]; // CSC matrix in floating point format
int32_t piCscMatrix[12]; // CSC matrix in fixed point format
PRENDERHAL_MEDIA_STATE pMediaState; // Media states
MEDIA_OBJECT_KA2_STATIC_DATA *pStatic; // Static parameters
MEDIA_DP_FC_STATIC_DATA *pDPStatic; // DP parameters
PVPHAL_SURFACE pSurface; // Surface parameters
PVPHAL_SURFACE pTarget; // Render Target parameters
RENDERHAL_SURFACE_STATE_PARAMS SurfaceParams;
// Media kernel parameters
int32_t iFilterSize, i, j;
int32_t iThreadCount;
Kdll_FilterEntry *pFilter;
Kdll_CSC_Params *pCscParams;
Kdll_CSC_Matrix *pMatrix;
Kdll_Procamp *pProcamp;
int32_t iKrnAllocation;
int32_t iCurbeOffset;
int32_t iCurbeLength;
int32_t iInlineLength;
MHW_KERNEL_PARAM MhwKernelParam;
// CSC parameters for ColorFill and Palettes
VPHAL_CSPACE src_cspace, dst_cspace;
uint8_t ColorFill_A;
float fStepX;
bool bResult = false;
MOS_STATUS eStatus;
int32_t iNumEntries;
void* pPaletteData = nullptr;
VPHAL_RENDER_ASSERT(m_pKernelDllState);
VPHAL_RENDER_CHK_NULL(m_pRenderHal);
VPHAL_RENDER_CHK_NULL(pRenderingData);
VPHAL_RENDER_CHK_NULL(pRenderingData->pKernelEntry);
ColorFill_A = 0;
pKernelDllState = m_pKernelDllState;
pRenderHal = m_pRenderHal;
pKernelEntry = pRenderingData->pKernelEntry;
// Get Pointer to rendering data
pStatic = (MEDIA_OBJECT_KA2_STATIC_DATA*)& pRenderingData->WalkerStatic;
pDPStatic = &pRenderingData->DPFCStatic;
// Get Pointer to Render Target Surface
pTarget = pRenderingData->pTarget[0];
// Get Kernel Filter description
pFilter = pKernelEntry->pFilter;
iFilterSize = pKernelEntry->iFilterSize;
// Get Kernel CSC information
pCscParams = pKernelEntry->pCscParams;
pMatrix = nullptr;
for (i = 0; i < DL_CSC_MAX; i++)
{
if (pCscParams->Matrix[i].iCoeffID == CoeffID_0)
{
pMatrix = &pCscParams->Matrix[i];
break;
}
}
// Load CSC matrix
if (pMatrix && pMatrix->bInUse && !m_bFtrCSCCoeffPatchMode)
{
// Procamp is present
if (pMatrix->iProcampID != DL_PROCAMP_DISABLED &&
pMatrix->iProcampID < VPHAL_MAX_PROCAMP)
{
// Get Procamp parameter - update matrix only if Procamp is changed
pProcamp = &pRenderingData->pProcamp[pMatrix->iProcampID];
if (pMatrix->iProcampVersion != pProcamp->iProcampVersion)
{
KernelDll_UpdateCscCoefficients(pKernelDllState, pMatrix);
}
}
// CSC coeff from static parameter only applies to primary layer
if (pMatrix->iCoeffID == CoeffID_0)
{
int16_t* pCoeff = pMatrix->Coeff;
pDPStatic->DW0.CscConstantC0 = *(pCoeff++);
pDPStatic->DW0.CscConstantC1 = *(pCoeff++);
pDPStatic->DW1.CscConstantC2 = *(pCoeff++);
pDPStatic->DW1.CscConstantC3 = *(pCoeff++);
pDPStatic->DW2.CscConstantC4 = *(pCoeff++);
pDPStatic->DW2.CscConstantC5 = *(pCoeff++);
pDPStatic->DW3.CscConstantC6 = *(pCoeff++);
pDPStatic->DW3.CscConstantC7 = *(pCoeff++);
pDPStatic->DW4.CscConstantC8 = *(pCoeff++);
pDPStatic->DW4.CscConstantC9 = *(pCoeff++);
pDPStatic->DW5.CscConstantC10 = *(pCoeff++);
pDPStatic->DW5.CscConstantC11 = *pCoeff;
}
else
{
VPHAL_RENDER_ASSERTMESSAGE("CSC matrix coefficient id is non-zero.");
goto finish;
}
}
iInlineLength = CalculateInlineDataSize(pRenderingData, pStatic);
// Set Background color (use cspace of first layer)
if (pRenderingData->pColorFill)
{
VPHAL_COLOR_SAMPLE_8 Src;
Src.dwValue = pRenderingData->pColorFill->Color;
// get src and dst colorspaces
src_cspace = pRenderingData->pColorFill->CSpace;
// if iscale enabled, set colorspace to render target color space
if ( pFilter->sampler == Sample_iScaling || pFilter->sampler == Sample_iScaling_034x || pFilter->sampler == Sample_iScaling_AVS )
{
dst_cspace = CSpace_None;
// find the filter of render target and set dst_cspace to render target color space
for (i = 0; i < iFilterSize; i++)
{
if ((pFilter + i)->layer == Layer_RenderTarget)
{
dst_cspace = (pFilter + i)->cspace;
}
}
if (dst_cspace == CSpace_None) // if color space is invlaid return false
{
VPHAL_RENDER_ASSERTMESSAGE("Failed to assign dst color spcae for iScale case.");
goto finish;
}
}
else // use selected cspace by kdll
{
if (GFX_IS_GEN_9_OR_LATER(pRenderHal->Platform))
{
dst_cspace = pKernelDllState->colorfill_cspace;
}
else
{
dst_cspace = pFilter->cspace;
}
}
// Convert BG color only if not done so before. CSC is expensive!
if ((m_csSrc.dwValue != Src.dwValue) ||
(m_CSpaceSrc != src_cspace) ||
(m_CSpaceDst != dst_cspace))
{
VpHal_CSC_8(&m_csDst, &Src, src_cspace, dst_cspace);
// store the values for next iteration
m_csSrc = Src;
m_CSpaceSrc = src_cspace;
m_CSpaceDst = dst_cspace;
}
// Set BG color
if (KernelDll_IsCspace(dst_cspace, CSpace_RGB))
{
ColorFill_A = m_csDst.A;
pStatic->DW13.ColorFill_R = m_csDst.R;
pStatic->DW13.ColorFill_G = m_csDst.G;
pStatic->DW13.ColorFill_B = m_csDst.B;
}
else
{
ColorFill_A = m_csDst.a;
pStatic->DW13.ColorFill_Y = m_csDst.Y;
pStatic->DW13.ColorFill_U = m_csDst.U;
pStatic->DW13.ColorFill_V = m_csDst.V;
}
}
// Load Palettes (layer cspace determines the output cspace)
// REMARK - Last filter entry is for Render Target
pSurface = nullptr; // initialize it as it may not be set such as for colorfill only case
for (i = 0; i < iFilterSize - 1; i++, pFilter++)
{
// Get current layer ID
pSurface = pRenderingData->pLayers[i];
if (nullptr == pSurface)
{
continue;
}
// Check for palette
if (pSurface->Palette.iNumEntries <= 0)
{
continue;
}
// Get palette CSC mode based on filter description
src_cspace = pSurface->Palette.ColorSpace;
dst_cspace = pFilter->cspace;
MOS_ZeroMemory(pfCscMatrix, sizeof(pfCscMatrix));
KernelDll_GetCSCMatrix(src_cspace, dst_cspace, pfCscMatrix);
// convert float to fixed point format
for (j = 0; j < 12; j++)
{
// multiply by 2^20 and round up
piCscMatrix[j] = (int32_t)((pfCscMatrix[j] * 1048576.0f) + 0.5f);
}
eStatus = pRenderHal->pfnGetPaletteEntry(pRenderHal,
pSurface->iPalette,
pSurface->Palette.iNumEntries,
&iNumEntries,
&pPaletteData);
if (eStatus != MOS_STATUS_SUCCESS)
{
VPHAL_RENDER_ASSERTMESSAGE("Failed to Get Palette Entry.");
goto finish;
}
eStatus = LoadPaletteData(&pSurface->Palette,
src_cspace,
dst_cspace,
piCscMatrix,
iNumEntries,
pPaletteData);
if (eStatus != MOS_STATUS_SUCCESS)
{
VPHAL_RENDER_ASSERTMESSAGE("Failed to Load Palette.");
eStatus = pRenderHal->pfnFreePaletteID(
pRenderHal,
&pSurface->iPalette);
if (eStatus != MOS_STATUS_SUCCESS)
{
VPHAL_RENDER_ASSERTMESSAGE("Failed to Free Palette ID.");
}
goto finish;
}
}
// Set primary video scaling factor
fStepX = pRenderingData->Inline.DW04.VideoXScalingStep;
if (fStepX <= 0.0f)
{
fStepX = pRenderingData->Inline.DW04.VideoXScalingStep = 1.0f;
}
// Set 1st layer step X to the Batch Buffer selection logic
pRenderingData->BbArgs.fStepX = fStepX;
// Normalize scaling factors for all layers
// Ratio of Horizontal Scaling Step to Video X Scaling Step
// Since NLAS is ZBBed, CM FC kernels simplified scaling factor calculation, no need to normalize here
if (!pRenderingData->bCmFcEnable)
{
pDPStatic->DW9.HorizontalScalingStepRatioLayer0 /= fStepX;
}
pMediaState = pRenderingData->pMediaState;
// Load media kernel for compositing
INIT_MHW_KERNEL_PARAM(MhwKernelParam, pKernelEntry);
iKrnAllocation = pRenderHal->pfnLoadKernel(
pRenderHal,
&m_KernelParams,
&MhwKernelParam,
pKernelEntry);
// Check if kernel is successfully loaded in GSH
if (iKrnAllocation < 0)
{
VPHAL_RENDER_ASSERTMESSAGE("Failed to load kernel in GSH.");
goto finish;
}
if (pSurface == nullptr)
{
VPHAL_RENDER_ASSERTMESSAGE("pSurface is nullptr.");
goto finish;
}
if (pSurface->Format == Format_A8R8G8B8)
{
pDPStatic->DW15.waFlag = 1;
}
iCurbeLength = sizeof(MEDIA_DP_FC_STATIC_DATA);
iCurbeOffset = pRenderHal->pfnLoadCurbeData(
pRenderHal,
pMediaState,
pDPStatic,
iCurbeLength);
if (iCurbeOffset < 0)
{
VPHAL_RENDER_ASSERTMESSAGE("Failed to setup CURBE data.");
goto finish;
}
// Allocate Media ID, link to kernel
pRenderingData->iMediaID = pRenderHal->pfnAllocateMediaID(
pRenderHal,
iKrnAllocation,
pRenderingData->iBindingTable,
iCurbeOffset,
iCurbeLength,
0,
nullptr);
if (pRenderingData->iMediaID < 0)
{
VPHAL_RENDER_ASSERTMESSAGE("Failed to setup Media Interface Descriptor.");
goto finish;
}
pRenderingData->iCurbeOffset = iCurbeOffset;
pRenderingData->iCurbeLength = iCurbeLength;
// Set Sampler states for this Media ID
eStatus = pRenderHal->pfnSetSamplerStates(
pRenderHal,
pRenderingData->iMediaID,
pRenderingData->SamplerStateParams,
MHW_RENDER_ENGINE_SAMPLERS_MAX);
if (MOS_FAILED(eStatus))
{
VPHAL_RENDER_ASSERTMESSAGE("Failed to setup sampler states.");
goto finish;
}
iThreadCount = GetThreadCountForVfeState(pRenderingData, pTarget);
//----------------------------------
// Setup VFE State params. Each Renderer MUST call pfnSetVfeStateParams().
//----------------------------------
VPHAL_RENDER_CHK_STATUS(pRenderHal->pfnSetVfeStateParams(
pRenderHal,
MEDIASTATE_DEBUG_COUNTER_FREE_RUNNING,
iThreadCount,
iCurbeLength,
iInlineLength,
nullptr));
bResult = true;
finish:
return bResult;
} | 37.292285 | 151 | 0.602825 | [
"render"
] |
eb8c67256e863bf609ec663f98569f63bcabfeab | 16,269 | hpp | C++ | include/xtensor-sparse/xsparse_container.hpp | gouarin/xtensor-sparse | 04c4958399d198f5d4e0772b28c8fd986352a850 | [
"BSD-3-Clause"
] | 29 | 2020-04-03T19:54:12.000Z | 2022-03-10T01:41:44.000Z | include/xtensor-sparse/xsparse_container.hpp | gouarin/xtensor-sparse | 04c4958399d198f5d4e0772b28c8fd986352a850 | [
"BSD-3-Clause"
] | 19 | 2020-04-03T13:41:42.000Z | 2021-09-01T18:22:49.000Z | include/xtensor-sparse/xsparse_container.hpp | gouarin/xtensor-sparse | 04c4958399d198f5d4e0772b28c8fd986352a850 | [
"BSD-3-Clause"
] | 5 | 2020-04-03T12:04:19.000Z | 2020-08-10T10:26:44.000Z | #ifndef XSPARSE_XSPARSE_CONTAINER_HPP
#define XSPARSE_XSPARSE_CONTAINER_HPP
#include <xtensor/xaccessible.hpp>
#include <xtensor/xiterable.hpp>
#include <xtensor/xstrides.hpp>
#include "xsparse_assign.hpp"
#include "xsparse_function.hpp"
#include "xsparse_reference.hpp"
#include "xsparse_types.hpp"
namespace xt
{
/*********************
* xsparse_container *
*********************/
template <class D>
class xsparse_container: public xiterable<D>,
private xaccessible<D>
{
public:
using derived_type = D;
using inner_types = xcontainer_inner_types<D>;
using scheme_type = typename inner_types::scheme_type;
using index_type = typename inner_types::index_type;
using storage_type = typename inner_types::storage_type;
using value_type = typename inner_types::value_type;
using reference = typename inner_types::reference;
using const_reference = typename inner_types::const_reference;
using pointer = typename inner_types::pointer;
using const_pointer = typename inner_types::const_pointer;
using size_type = typename inner_types::size_type;
using difference_type = typename inner_types::difference_type;
using bool_load_type = xt::bool_load_type<value_type>;
using temporary_type = typename inner_types::temporary_type;
using expression_tag = xsparse_expression_tag;
using assign_tag = extension::xsparse_assign_tag;
using shape_type = typename inner_types::shape_type;
using inner_shape_type = typename inner_types::inner_shape_type;
using strides_type = typename inner_types::strides_type;
using accessible_base = xaccessible<D>;
using iterable_base = xiterable<D>;
using stepper = typename iterable_base::stepper;
using const_stepper = typename iterable_base::const_stepper;
static constexpr layout_type static_layout = layout_type::row_major;
static constexpr bool contiguous_layout = false;
using nz_iterator = typename scheme_type::nz_iterator;
using const_nz_iterator = typename scheme_type::const_nz_iterator;
size_type size() const noexcept;
size_type dimension() const noexcept;
const inner_shape_type& shape() const noexcept;
template <class S = shape_type>
void resize(S&& shape, bool force);
template <class S = shape_type>
void resize(S&& shape);
template <class S = shape_type>
auto& reshape(S&& shape) &;
template <class T>
auto& reshape(std::initializer_list<T> shape) &;
template <class... Args>
reference operator()(Args... args);
template <class... Args>
const_reference operator()(Args... args) const;
using accessible_base::shape;
using accessible_base::at;
using accessible_base::operator[];
using accessible_base::periodic;
using accessible_base::in_bounds;
template <class It>
reference element(It first, It last);
template <class It>
const_reference element(It first, It last) const;
void insert_element(const index_type& index, const_reference value);
template <class S>
bool broadcast_shape(S& shape, bool reuse_cache = false) const;
const scheme_type& scheme() const;
template <class S>
bool has_linear_assign(const S& strides) const noexcept;
template <class S>
stepper stepper_begin(const S& shape) noexcept;
template <class S>
stepper stepper_end(const S& shape, layout_type l) noexcept;
template <class S>
const_stepper stepper_begin(const S& shape) const noexcept;
template <class S>
const_stepper stepper_end(const S& shape, layout_type l) const noexcept;
inline layout_type layout() const noexcept;
inline bool is_contiguous() const noexcept;
nz_iterator nz_begin();
nz_iterator nz_end();
const_nz_iterator nz_begin() const;
const_nz_iterator nz_end() const;
const_nz_iterator nz_cbegin() const;
const_nz_iterator nz_cend() const;
static const value_type ZERO;
protected:
xsparse_container() = default;
~xsparse_container() = default;
xsparse_container(const xsparse_container&) = default;
xsparse_container& operator=(const xsparse_container&) = default;
xsparse_container(xsparse_container&&) = default;
xsparse_container& operator=(xsparse_container&&) = default;
private:
template <class S = shape_type>
void reshape_impl(S&& shape, std::false_type);
template <class S = shape_type>
void reshape_impl(S&& shape, std::true_type);
index_type make_index() const;
template <class Arg, class... Args>
index_type make_index(Arg arg, Args... args) const;
template <class It>
index_type make_index_from_it(It first, It last) const;
const_reference access_impl(index_type index) const;
reference access_impl(index_type index);
derived_type& derived_cast() & noexcept;
const derived_type& derived_cast() const & noexcept;
derived_type derived_cast() && noexcept;
inner_shape_type m_shape;
strides_type m_strides;
scheme_type m_scheme;
friend class xconst_accessible<D>;
friend class xaccessible<D>;
};
/************************************
* xsparse_container implementation *
************************************/
template <class D>
const typename xsparse_container<D>::value_type
xsparse_container<D>::ZERO = 0;
template <class D>
inline auto xsparse_container<D>::size() const noexcept -> size_type
{
return compute_size(shape());
}
template <class D>
inline auto xsparse_container<D>::dimension() const noexcept -> size_type
{
return shape().size();
}
template <class D>
inline auto xsparse_container<D>::shape() const noexcept -> const inner_shape_type&
{
return m_shape;
}
template <class D>
template <class S>
inline void xsparse_container<D>::resize(S&& shape, bool force)
{
std::size_t dim = shape.size();
if (m_shape.size() != dim || !std::equal(std::begin(shape), std::end(shape), std::begin(m_shape)) || force)
{
m_shape = xtl::forward_sequence<shape_type, S>(shape);
strides_type old_strides = m_strides;
resize_container(m_strides, dim);
compute_strides(m_shape, XTENSOR_DEFAULT_LAYOUT, m_strides);
m_scheme.update_entries(old_strides, m_strides, m_shape);
}
}
template <class D>
template <class S>
inline void xsparse_container<D>::resize(S&& shape)
{
resize(std::forward<S>(shape), true);
}
template <class D>
template <class S>
inline auto& xsparse_container<D>::reshape(S&& shape) &
{
reshape_impl(std::forward<S>(shape), std::is_signed<std::decay_t<typename std::decay_t<S>::value_type>>());
return *this;
}
template <class D>
template <class T>
inline auto& xsparse_container<D>::reshape(std::initializer_list<T> shape) &
{
using sh_type = rebind_container_t<D, shape_type>;
sh_type sh = xtl::make_sequence<sh_type>(shape.size());
std::copy(shape.begin(), shape.end(), sh.begin());
reshape_impl(std::move(sh), std::is_signed<T>());
return *this;
}
template<class D>
template<class... Args>
inline auto xsparse_container<D>::operator()(Args... args) const -> const_reference
{
XTENSOR_TRY(check_index(shape(), args...));
XTENSOR_CHECK_DIMENSION(shape(), args...);
return access_impl(make_index(static_cast<size_type>(args)...));
}
template<class D>
template<class... Args>
inline auto xsparse_container<D>::operator()(Args... args) -> reference
{
XTENSOR_TRY(check_index(shape(), args...));
XTENSOR_CHECK_DIMENSION(shape(), args...);
return access_impl(make_index(static_cast<size_type>(args)...));
}
template <class D>
template <class It>
inline auto xsparse_container<D>::element(It first, It last) -> reference
{
XTENSOR_TRY(check_element_index(shape(), first, last));
return access_impl(make_index_from_it(first, last));
}
template <class D>
template <class It>
inline auto xsparse_container<D>::element(It first, It last) const -> const_reference
{
XTENSOR_TRY(check_element_index(shape(), first, last));
return access_impl(make_index_from_it(first, last));
}
template <class D>
inline void xsparse_container<D>::insert_element(const index_type& index, const_reference value)
{
m_scheme.insert_element(index, value);
}
template <class D>
template <class S>
inline bool xsparse_container<D>::broadcast_shape(S& shape, bool) const
{
return xt::broadcast_shape(this->shape(), shape);
}
template <class D>
inline auto xsparse_container<D>::scheme() const -> const scheme_type&
{
return m_scheme;
}
template <class D>
template <class S>
inline bool xsparse_container<D>::has_linear_assign(const S&) const noexcept
{
return false;
}
template <class D>
template <class S>
inline auto xsparse_container<D>::stepper_begin(const S& shape) noexcept -> stepper
{
size_type offset = shape.size() - this->dimension();
return stepper(&(this->derived_cast()), offset);
}
template <class D>
template <class S>
inline auto xsparse_container<D>::stepper_end(const S& shape, layout_type) noexcept -> stepper
{
size_type offset = shape.size() - this->dimension();
return stepper(&(this->derived_cast()), offset, true);
}
template <class D>
template <class S>
inline auto xsparse_container<D>::stepper_begin(const S& shape) const noexcept -> const_stepper
{
size_type offset = shape.size() - this->dimension();
return const_stepper(&(this->derived_cast()), offset);
}
template <class D>
template <class S>
inline auto xsparse_container<D>::stepper_end(const S& shape, layout_type) const noexcept -> const_stepper
{
size_type offset = shape.size() - this->dimension();
return const_stepper(&(this->derived_cast()), offset, true);
}
template <class D>
inline auto xsparse_container<D>::layout() const noexcept -> layout_type
{
return static_layout;
}
template <class D>
inline bool xsparse_container<D>::is_contiguous() const noexcept
{
return false;
}
template <class D>
inline auto xsparse_container<D>::nz_begin() -> nz_iterator
{
return m_scheme.nz_begin();
}
template <class D>
inline auto xsparse_container<D>::nz_end() -> nz_iterator
{
return m_scheme.nz_end();
}
template <class D>
inline auto xsparse_container<D>::nz_begin() const -> const_nz_iterator
{
return m_scheme.nz_begin();
}
template <class D>
inline auto xsparse_container<D>::nz_end() const -> const_nz_iterator
{
return m_scheme.nz_end();
}
template <class D>
inline auto xsparse_container<D>::nz_cbegin() const -> const_nz_iterator
{
return m_scheme.nz_cbegin();
}
template <class D>
inline auto xsparse_container<D>::nz_cend() const -> const_nz_iterator
{
return m_scheme.nz_cend();
}
template <class D>
template <class S>
inline void xsparse_container<D>::reshape_impl(S&& shape, std::false_type /* is unsigned */)
{
if (compute_size(shape) != this->size())
{
XTENSOR_THROW(std::runtime_error, "Cannot reshape with incorrect number of elements. Do you mean to resize?");
}
std::size_t dim = shape.size();
strides_type old_strides = m_strides;
m_shape = xtl::forward_sequence<shape_type, S>(shape);
resize_container(m_strides, dim);
compute_strides(m_shape, XTENSOR_DEFAULT_LAYOUT, m_strides);
m_scheme.update_entries(old_strides, m_strides, m_shape);
}
template <class D>
template <class S>
inline void xsparse_container<D>::reshape_impl(S&& _shape, std::true_type /* is signed */)
{
using value_type = typename std::decay_t<S>::value_type;
auto new_size = compute_size(_shape);
if (this->size() % new_size)
{
XTENSOR_THROW(std::runtime_error, "Negative axis size cannot be inferred. Shape mismatch.");
}
std::decay_t<S> shape = _shape;
value_type accumulator = 1;
std::size_t neg_idx = 0;
std::size_t i = 0;
for(auto it = shape.begin(); it != shape.end(); ++it, i++)
{
auto&& dim = *it;
if(dim < 0)
{
XTENSOR_ASSERT(dim == -1 && !neg_idx);
neg_idx = i;
}
accumulator *= dim;
}
if(accumulator < 0)
{
shape[neg_idx] = static_cast<value_type>(this->size()) / std::abs(accumulator);
}
else if(this->size() != new_size)
{
XTENSOR_THROW(std::runtime_error, "Cannot reshape with incorrect number of elements. Do you mean to resize?");
}
std::size_t dim = shape.size();
auto old_strides = m_strides;
m_shape = xtl::forward_sequence<shape_type, S>(shape);
resize_container(m_strides, dim);
compute_strides(m_shape, XTENSOR_DEFAULT_LAYOUT, m_strides);
m_scheme.update_entries(old_strides, m_strides, m_shape);
}
template <class D>
inline auto xsparse_container<D>::make_index() const -> index_type
{
return index_type();
}
template <class D>
template <class Arg, class... Args>
inline auto xsparse_container<D>::make_index(Arg arg, Args... args) const -> index_type
{
constexpr size_t argsize = sizeof...(Args) + size_t(1);
size_type dim = dimension();
if (argsize == dim)
{
return index_type{arg, args...};
}
else if(argsize > dim)
{
return make_index(args...);
}
else
{
std::array<Arg, argsize> tmp_index = {arg, args...};
index_type res = xtl::make_sequence<index_type>(dim);
std::fill(res.begin(), res.begin() + res.size() - argsize, size_type(0));
std::copy(tmp_index.cbegin(), tmp_index.cend(), res.begin() + res.size() - argsize);
return res;
}
}
template <class D>
template <class It>
inline auto xsparse_container<D>::make_index_from_it(It first, It last) const -> index_type
{
auto index = xtl::make_sequence<index_type>(static_cast<std::size_t>(std::distance(first, last)));
std::copy(first, last, index.begin());
return index;
}
template<class D>
inline auto xsparse_container<D>::access_impl(index_type index) const -> const_reference
{
auto it = m_scheme.find_element(index);
if (it)
{
return *it;
}
return ZERO;
}
template<class D>
inline auto xsparse_container<D>::access_impl(index_type index)-> reference
{
auto it = m_scheme.find_element(index);
value_type v = (it)? *it: value_type();
return reference(m_scheme, std::move(index), v);
}
template <class D>
inline auto xsparse_container<D>::derived_cast() & noexcept -> derived_type&
{
return *static_cast<derived_type*>(this);
}
template <class D>
inline auto xsparse_container<D>::derived_cast() const & noexcept -> const derived_type&
{
return *static_cast<const derived_type*>(this);
}
template <class D>
inline auto xsparse_container<D>::derived_cast() && noexcept -> derived_type
{
return *static_cast<derived_type*>(this);
}
}
#endif
| 32.088757 | 122 | 0.628434 | [
"shape"
] |
eb8e665b9ac5501d78e961a913497a53830548c3 | 15,924 | cpp | C++ | src/main/report.cpp | Matasx/mmbot | 4065c029dd17c97307bc3626f5f6afdbe79e7d8f | [
"MIT"
] | null | null | null | src/main/report.cpp | Matasx/mmbot | 4065c029dd17c97307bc3626f5f6afdbe79e7d8f | [
"MIT"
] | null | null | null | src/main/report.cpp | Matasx/mmbot | 4065c029dd17c97307bc3626f5f6afdbe79e7d8f | [
"MIT"
] | null | null | null | /*
* report.cpp
*
* Created on: 17. 5. 2019
* Author: ondra
*/
#include "report.h"
#include <imtjson/value.h>
#include <imtjson/object.h>
#include <imtjson/array.h>
#include <chrono>
#include <numeric>
#include "../shared/linear_map.h"
#include "../shared/logOutput.h"
#include "../shared/range.h"
#include "../shared/stdLogOutput.h"
#include "sgn.h"
#include "../../version.h"
#include "../imtjson/src/imtjson/string.h"
#include "alert.h"
#include "acb.h"
using ondra_shared::logError;
using namespace std::chrono;
using namespace json;
void Report::setInterval(std::uint64_t interval) {
this->interval_in_ms = interval;
}
json::Value Report::genReport_noStore() {
Object st;
exportCharts(st.object("charts"));
exportOrders(st.array("orders"));
exportTitles(st.object("info"));
exportPrices(st.object("prices"));
exportMisc(st.object("misc"));
st.set("interval", interval_in_ms);
st.set("rev", counter);
st.set("log", logLines);
st.set("performance", perfRep);
st.set("version", MMBOT_VERSION);
st.set("news", newsMessages);
return st;
}
void Report::genReport() {
while (logLines.size()>30) logLines.erase(logLines.begin());
counter++;
report->store(genReport_noStore());
if (refresh_after_clear) {
refresh_after_clear = false;
for (auto &x : streams) {
x(nullptr); //< clear cache.
x("refresh") && stream_refresh(x) && x("end_refresh");
}
} else {
for (auto &x : streams) {
x("update");
}
}
}
struct ChartData {
Array records;
double last_price = 0;
double sums = 0;
double assets = 0;
double init_price = 0;
};
template<typename ME>
void Report::sendStreamOrder(ME &me, const OKey &key, const OValue &data) {
me.sendStream(
json::Object{
{ "type", "order" },
{ "symbol", key.symb },
{ "dir", key.dir },
{ "data", data.toJson()}
});
}
void Report::setOrders(std::size_t rev, StrViewA symb, int n, const std::optional<IStockApi::Order> &buy,
const std::optional<IStockApi::Order> &sell) {
if (rev != revize) return;
const json::Value &info = infoMap[symb];
bool inverted = info["inverted"].getBool();
int buyid = inverted?-n:n;
OKey buyKey {symb, buyid};
OKey sellKey {symb, -buyid};
OValue data;
if (buy.has_value()) {
data = {inverted?1.0/buy->price:buy->price, buy->size*buyid};
} else{
data = {0, 0};
}
orderMap[buyKey] = data;
sendStreamOrder(*this,buyKey, data);
if (sell.has_value()) {
data = {inverted?1.0/sell->price:sell->price, sell->size*buyid};
} else {
data = {0, 0};
}
orderMap[sellKey] = data;
sendStreamOrder(*this,sellKey, data);
}
static double wavg(double a, double wa, double b, double wb) {
double s = wa + wb;
if (s == 0) return 0;
return (a * wa + b * wb)/s;
}
static IStatSvc::TradeRecord sumTrades(const IStatSvc::TradeRecord &a, const IStatSvc::TradeRecord &b) {
return IStatSvc::TradeRecord(
IStockApi::Trade {
b.id,b.time,
a.size+b.size,
wavg(a.price,a.size,b.price,b.size),
a.eff_size+b.eff_size,
wavg(a.eff_price,a.eff_size,b.eff_price,b.eff_size),
},
b.norm_profit,
b.norm_accum,
b.neutral_price,b.manual_trade
);
}
template<typename ME>
void Report::sendStreamTrades(ME &me, const std::string_view &symb, const json::Value &records) {
for (Value rw : records) {
me.sendStream(
json::Object{
{ "type", "trade" },
{ "symbol",symb},
{ "id", rw["iid"]},
{ "data",rw.replace("iid",json::undefined) }
});
}
}
static json::NamedEnum<AlertReason> strAlertReason({
{AlertReason::unknown, "unknown"},
{AlertReason::below_minsize, "below_minsize"},
{AlertReason::accept_loss, "accept_loss"},
{AlertReason::max_cost, "max_cost"},
{AlertReason::no_funds, "no_funds"},
{AlertReason::max_leverage, "max_leverage"},
{AlertReason::out_of_budget, "out_of_budget"},
{AlertReason::position_limit, "position_limit"},
{AlertReason::strategy_enforced, "strategy_enforced"},
{AlertReason::strategy_outofsync, "strategy_outofsync"},
{AlertReason::initial_reset, "initial_reset"}
});
void Report::setTrades(std::size_t rev, StrViewA symb, double finalPos, StringView<IStatSvc::TradeRecord> trades) {
if (rev != revize) return;
using ondra_shared::range;
json::Array records;
const json::Value &info = infoMap[symb];
bool inverted = info["inverted"].getBool();
double chng = std::accumulate(trades.begin(), trades.end(), 0.0, [](double x, const IStatSvc::TradeRecord &b){
return x+b.eff_size;
});
double pos = finalPos-chng;
if (!trades.empty()) {
const auto &last = trades[trades.length-1];
std::uint64_t last_time = last.time;
std::uint64_t first = last_time - interval_in_ms;
auto tend = trades.end();
auto iter = trades.begin();
auto &&t = *iter;
double init_price = t.eff_price;
double prev_price = init_price;
double cur_fromPos = 0;
double pnp = 0;
double pap = 0;
ACB acb(init_price, pos);
bool normaccum = false;
std::optional<IStatSvc::TradeRecord> tmpTrade;
const IStatSvc::TradeRecord *prevTrade = nullptr;
int iid = 0;
do {
if (iter == tend || (prevTrade && (std::abs(prevTrade->price - iter->price) > std::abs(iter->price*1e-8)
|| prevTrade->size * iter->size <= 0
|| prevTrade->manual_trade
|| iter->manual_trade)))
{
auto &&t = *prevTrade;
double gain = (t.eff_price - prev_price)*pos ;
prev_price = t.eff_price;
acb = acb(t.eff_price, t.eff_size);
cur_fromPos += gain;
pos += t.eff_size;
double normch = (t.norm_accum - pap) * t.eff_price + (t.norm_profit - pnp);
pap = t.norm_accum;
pnp = t.norm_profit;
normaccum = normaccum || t.norm_accum != 0;
if (t.time >= first) {
records.push_back(Object({
{"id", t.id},
{"time", t.time},
{"achg", (inverted?-1:1)*t.size},
{"gain", gain},
{"norm", t.norm_profit},
{"normch", normch},
{"nacum", normaccum?Value((inverted?-1:1)*t.norm_accum):Value()},
{"pos", (inverted?-1:1)*pos},
{"pl", cur_fromPos},
{"rpl", acb.getRPnL()},
{"open", acb.getOpen()},
{"iid", std::to_string(iid)},
{"price", (inverted?1.0/t.price:t.price)},
{"p0",t.neutral_price?Value(inverted?1.0/t.neutral_price:t.neutral_price):Value()},
{"volume", fabs(t.eff_price*t.eff_size)},
{"man",t.manual_trade},
{"alert", t.size == 0?Value(Object{
{"reason",strAlertReason[static_cast<AlertReason>(t.alertReason)]},
{"side", t.alertSide}
}):json::Value()}
}));
}
prevTrade = nullptr;
if (iter == tend)
break;
}
if (prevTrade == nullptr) {
prevTrade = &(*iter);
} else {
tmpTrade = sumTrades(*prevTrade, *iter);
prevTrade = &(*tmpTrade);
--iid;
}
++iter;
iid++;
} while (true);
}
tradeMap[symb] = records;
sendStreamTrades(*this,symb, records);
}
void Report::exportCharts(json::Object&& out) {
for (auto &&rec: tradeMap) {
out.set(rec.first, rec.second);
}
}
bool Report::OKeyCmp::operator ()(const OKey& a, const OKey& b) const {
int cmp = a.symb.compare(b.symb);
if (cmp == 0) {
return a.dir < b.dir;
} else {
return cmp < 0;
}
}
template<typename ME>
void Report::sendStreamInfo(ME &me, const std::string_view &symb, const json::Value &object) {
me.sendStream(json::Object{
{"type","info"},
{"symbol",symb},
{"data",object}});
}
void Report::setInfo(std::size_t rev, StrViewA symb, const InfoObj &infoObj) {
if (rev != revize) return;
json::Value data = json::Object({
{"title",infoObj.title},
{"currency", infoObj.currencySymb},
{"asset", infoObj.assetSymb},
{"price_symb", infoObj.priceSymb},
{"brokerIcon", json::String({"data:image/png;base64,",infoObj.brokerIcon})},
{"brokerName", infoObj.brokerName},
{"inverted", infoObj.inverted},
{"walletId", infoObj.walletId},
{"emulated",infoObj.emulated},
{"order", infoObj.order}
});
infoMap[symb] = data;
sendStreamInfo(*this,symb, data);
}
template<typename ME>
void Report::sendStreamPrice(ME &me, const std::string_view &symb, double data) {
me.sendStream(json::Object{
{ "type", "price" },
{ "symbol",symb },
{ "data", data } });
}
void Report::setPrice(std::size_t rev, StrViewA symb, double price) {
if (rev != revize) return;
const json::Value &info = infoMap[symb];
bool inverted = info["inverted"].getBool();
double data = inverted?1.0/price:price;
priceMap[symb] = data;
sendStreamPrice(*this,symb, data);
}
void Report::exportOrders(json::Array &&out) {
for (auto &&ord : orderMap) {
if (ord.second.price) {
out.push_back(Object({
{"symb",ord.first.symb},
{"dir",static_cast<int>(ord.first.dir)},
{"size",ord.second.size},
{"price",ord.second.price}
}));
}
}
}
void Report::exportTitles(json::Object&& out) {
for (auto &&rec: infoMap) {
out.set(rec.first, rec.second);
}
}
void Report::exportPrices(json::Object &&out) {
for (auto &&rec: priceMap) {
out.set(rec.first, rec.second);
}
}
template<typename ME>
void Report::sendStreamError(ME &me, const std::string_view &symb, const json::Value &obj) {
me.sendStream(json::Object {
{"type", "error" },
{"symbol",symb},
{ "data", obj } });
}
void Report::setError(std::size_t rev,StrViewA symb, const ErrorObj &errorObj) {
if (rev != revize) return;
const json::Value &info = infoMap[symb];
bool inverted = info["inverted"].getBool();
Object obj;
if (!errorObj.genError.empty()) obj.set("gen", errorObj.genError);
if (!errorObj.buyError.empty()) obj.set(inverted?"sell":"buy", errorObj.buyError);
if (!errorObj.sellError.empty()) obj.set(inverted?"buy":"sell", errorObj.sellError);
errorMap[symb] = obj;
sendStreamError(*this,symb, obj);
}
void Report::exportMisc(json::Object &&out) {
for (auto &&rec: miscMap) {
auto erritr = errorMap.find(rec.first);
Value err = erritr == errorMap.end()?Value():erritr->second;
out.set(rec.first, rec.second.replace("error", err));
}
}
void Report::addLogLine(StrViewA ln) {
logLines.push_back(std::string_view(ln));
sendStream(json::Object({{"type","log"},{"data",std::string_view(ln)}}));
}
using namespace ondra_shared;
class CaptureLog: public ondra_shared::StdLogProviderFactory {
public:
CaptureLog(const ondra_shared::SharedObject<Report> &rpt, ondra_shared::PStdLogProviderFactory target):rpt(rpt),target(target) {}
virtual void writeToLog(const StrViewA &line, const std::time_t &, LogLevel level) override;
virtual bool isLogLevelEnabled(ondra_shared::LogLevel lev) const override;
protected:
SharedObject<Report> rpt;
ondra_shared::PStdLogProviderFactory target;
};
inline void CaptureLog::writeToLog(const StrViewA& line, const std::time_t&tm, LogLevel level) {
if (level >= LogLevel::info) rpt.lock()->addLogLine(line);
target->sendToLog(line, tm, level);
}
inline bool CaptureLog::isLogLevelEnabled(ondra_shared::LogLevel lev) const {
return target->isLogLevelEnabled(lev);
}
ondra_shared::PStdLogProviderFactory Report::captureLog(const ondra_shared::SharedObject<Report> &rpt, ondra_shared::PStdLogProviderFactory target) {
return new CaptureLog(rpt, target);
}
template<typename ME>
void Report::sendStreamMisc(ME &me, const std::string_view &symb, const json::Value &object) {
me.sendStream(json::Object({
{"type","misc"},
{"symbol",std::string_view(symb)},
{"data",object}
}));
}
void Report::setMisc(std::size_t rev, StrViewA symb, const MiscData &miscData, bool initial) {
if (rev != revize) return;
if (initial && miscMap.find(symb) != miscMap.end()) return;
const json::Value &info = infoMap[symb];
bool inverted = info["inverted"].getBool();
double spread;
double lp = miscData.lastTradePrice * std::exp(-miscData.spread);
double hp = miscData.lastTradePrice * std::exp(miscData.spread);
if (inverted) {
lp = 1.0/lp;
hp = 1.0/hp;
}
spread = std::abs(hp-lp);
Object output;
output.setItems({{"ms", spread},
{"mt",miscData.total_trades},
{"tt",miscData.total_time},
{"bt",miscData.budget_total},
{"a",miscData.achieve_mode},
{"accum",miscData.accumulated},
{"ba",miscData.budget_assets},
{"en",miscData.enabled},
{"upnl",miscData.upnl},
{"rpnl",miscData.rpnl},
});
if (miscData.budget_extra.has_value())
output.set("be", *miscData.budget_extra);
if (inverted) {
output.setItems({
{"t",-miscData.trade_dir},
{"pos",-miscData.position},
{"mcp", 1.0/miscData.calc_price},
{"ml",1.0/miscData.highest_price},
{"mh",1.0/miscData.lowest_price},
{"mdmb", miscData.dynmult_sell},
{"mdms", miscData.dynmult_buy},
{"cur_norm_buy",miscData.cur_norm_sell},
{"cur_norm_sell",miscData.cur_norm_buy},
{"op", 1.0/miscData.entry_price},
{"ltp", 1.0/miscData.lastTradePrice}});
} else {
output.setItems({
{"t",miscData.trade_dir},
{"pos",miscData.position},
{"mcp", miscData.calc_price},
{"ml",miscData.lowest_price},
{"mh",miscData.highest_price},
{"mdmb", miscData.dynmult_buy},
{"mdms", miscData.dynmult_sell},
{"cur_norm_buy",miscData.cur_norm_buy},
{"cur_norm_sell",miscData.cur_norm_sell},
{"op", miscData.entry_price},
{"ltp", miscData.lastTradePrice}
});
}
miscMap[symb] = output;
sendStreamMisc(*this,symb, output);
}
void Report::clear() {
revize++;
tradeMap.clear();
infoMap.clear();
priceMap.clear();
miscMap.clear();
errorMap.clear();
orderMap.clear();
logLines.clear();
refresh_after_clear= true;
}
void Report::perfReport(json::Value report) {
perfRep = report;
sendStream(Object{{"type","performance"},{"data", perfRep}});
}
void Report::sendStream(const json::Value &v) {
if (refresh_after_clear) return;
auto iter = std::remove_if(streams.begin(), streams.end(), [&](const auto &s){
return !s(v);
});
streams.erase(iter, streams.end());
}
template<typename ME>
void Report::sendStreamGlobal(ME &me) const {
me.sendStream(Object{
{"type","config"},
{"data",Object{
{"interval", interval_in_ms},
}}
});
me.sendStream(Object{
{"type","performance"},
{"data", perfRep}
});
me.sendStream(Object{
{"type","version"},
{"data", MMBOT_VERSION}
});
}
void Report::pingStreams() {
if (!streams.empty()) {
sendStream("ping");
sendStreamGlobal(*this);
}
}
std::size_t Report::initCounter() {
return time(nullptr);
}
void Report::addStream(Stream &&stream) {
if (refresh_after_clear) {
this->streams.push_back(std::move(stream));
} else if (stream("refresh") && stream_refresh(stream) && stream("end_refresh")) {
this->streams.push_back(std::move(stream));
}
}
json::Value Report::OValue::toJson() const {
return json::Object({
{"price",price},
{"size",size}
});
}
void Report::setNewsMessages(unsigned int count) {
newsMessages = count;
sendNewsMessages(*this);
}
template<typename ME>
void Report::sendNewsMessages(ME &me) const {
me.sendStream(
json::Object{
{"type","news"},
{"data",json::Object{
{"count", newsMessages}
}}
});
}
template<typename ME>
void Report::sendLogMessages(ME &me) const {
for (json::Value ln: logLines) {
me.sendStream(json::Object({{"type","log"},{"data",ln}}));
}
}
bool Report::stream_refresh(Stream &stream) const {
class Helper {
public:
Helper(Stream &stream):stream(stream) {}
void sendStream(const Value &x) {
ok = ok && stream(x);
}
Stream &stream;
bool ok = true;
};
Helper hlp(stream);
sendStreamGlobal(hlp);
for (const auto &item: infoMap) {
sendStreamInfo(hlp,item.first, item.second);
}
for (const auto &item: tradeMap) {
sendStreamTrades(hlp,item.first, item.second);
}
for (const auto &item: miscMap) {
sendStreamMisc(hlp,item.first, item.second);
}
for (const auto &item: errorMap) {
sendStreamError(hlp,item.first, item.second);
}
for (const auto &item: priceMap) {
sendStreamPrice(hlp,item.first, item.second);
}
for (const auto &item: orderMap) {
sendStreamOrder(hlp,item.first, item.second);
}
sendNewsMessages(hlp);
sendLogMessages(hlp);
return hlp.ok;
}
| 24.200608 | 149 | 0.659131 | [
"object"
] |
eb936107f272afb7984b1fb4e2fa03e96a80d80b | 1,936 | cpp | C++ | src/settings.cpp | mugiseyebrows/mugi-ffmpeg | e7c3a5aeab3ee6ba5d3000f912491e42f32facbd | [
"MIT"
] | 3 | 2019-10-08T13:33:48.000Z | 2020-06-14T01:10:04.000Z | src/settings.cpp | mugiseyebrows/mugi-ffmpeg | e7c3a5aeab3ee6ba5d3000f912491e42f32facbd | [
"MIT"
] | null | null | null | src/settings.cpp | mugiseyebrows/mugi-ffmpeg | e7c3a5aeab3ee6ba5d3000f912491e42f32facbd | [
"MIT"
] | 3 | 2020-06-14T01:10:09.000Z | 2021-12-30T01:36:49.000Z | #include "settings.h"
#include <QStandardPaths>
#include <QDir>
#include <QApplication>
#include <QMessageBox>
#include <QDebug>
#include "jsonhelper.h"
Settings* Settings::mInstance = 0;
Settings* Settings::instance() {
if (!mInstance) {
mInstance = new Settings();
}
return mInstance;
}
Settings::Settings() {
QString appData = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
QString name = qApp->applicationName();
QDir d(appData);
if (!d.exists()) {
d.cdUp();
if (!d.mkdir(name)) {
QString error = QString("Can not create directory %1").arg(appData);
QMessageBox::critical(qApp->activeWindow(),"Error",error);
}
d.cd(name);
}
mDir = appData;
QString path = settingsPath();
if (!QFile::exists(path)) {
return;
}
bool ok;
QJsonDocument doc = loadJson(path,&ok);
if (!ok) {
QMessageBox::critical(qApp->activeWindow(),"Error",QString("Failed to load settings %1").arg(path));
return;
}
QJsonObject obj = doc.object();
mSource = obj.value("source").toString();
mOutput = obj.value("output").toString();
mOverwrite = obj.value("overwrite").toBool();
}
QString Settings::source() const {
return mSource;
}
QString Settings::output() const {
return mOutput;
}
bool Settings::overwrite() const {
return mOverwrite;
}
void Settings::setSource(const QString& value) {
mSource = value;
}
void Settings::setOutput(const QString& value) {
mOutput = value;
}
void Settings::setOverwrite(bool value) {
mOverwrite = value;
}
void Settings::save() {
QJsonObject settings;
settings["source"] = mSource;
settings["output"] = mOutput;
settings["overwrite"] = mOverwrite;
saveJson(settingsPath(),settings);
}
QString Settings::settingsPath() const
{
return QDir(mDir).filePath("settings.json");
}
| 20.595745 | 108 | 0.635331 | [
"object"
] |
eb95c22d6963b4bc3b1e835cfffaa26826e1f971 | 7,071 | cpp | C++ | fbpmp/data_processing/sharding/shard_pid.cpp | benliugithub/fbpcs | 7af984264428058645847135026d474d7e28144e | [
"MIT"
] | null | null | null | fbpmp/data_processing/sharding/shard_pid.cpp | benliugithub/fbpcs | 7af984264428058645847135026d474d7e28144e | [
"MIT"
] | null | null | null | fbpmp/data_processing/sharding/shard_pid.cpp | benliugithub/fbpcs | 7af984264428058645847135026d474d7e28144e | [
"MIT"
] | null | null | null | /*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#include <algorithm>
#include <filesystem>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <memory>
#include <sstream>
#include <string>
#include <vector>
#include "../hash_slinging_salter/HashSlingingSalter.hpp"
#include <gflags/gflags.h>
#include "folly/Random.h"
#include "folly/init/Init.h"
#include "folly/logging/xlog.h"
// TODO: Rewrite for open source?
#include "fbpcf/aws/AwsSdk.h"
#include "fbpcf/io/FileManagerUtil.h"
// TODO: Rewrite for open source?
#include "../common/FilepathHelpers.h"
#include "../common/Logging.h"
#include "../common/S3CopyFromLocalUtil.h"
DEFINE_string(input_filename, "", "Name of the input file");
DEFINE_string(
output_filenames,
"",
"Comma-separated list of file paths for output");
DEFINE_string(
output_base_path,
"",
"Local or s3 base path where output files are written to");
DEFINE_int32(
file_start_index,
0,
"First file that will be created from base path");
DEFINE_int32(num_output_files, 0, "Number of files that should be created");
DEFINE_string(
tmp_directory,
"/tmp/",
"Directory where temporary files should be saved before final write");
DEFINE_int32(log_every_n, 1000000, "How frequently to log updates");
DEFINE_int32(hashing_prime, 37, "Prime number to assist in consistent hashing");
DEFINE_string(
hmac_base64_key,
"",
"key to be used in optional hash salting step");
/* Utility to hash a string to an unsigned machine size integer.
* Unsigned is important so overflow is properly defined.
* Adapted from
* https://stackoverflow.com/questions/8567238/hash-function-in-c-for-string-to-int
*/
std::size_t hashString(const std::string& s, uint64_t hashing_prime) {
std::size_t res = 0;
for (auto i = 0; i < s.length(); ++i) {
res = hashing_prime * res + s[i];
}
return res;
}
void stripQuotes(std::string& s) {
s.erase(std::remove(s.begin(), s.end(), '"'), s.end());
}
void shardFile(
const std::string& inputFilename,
const std::filesystem::path& tmpDirectory,
const std::vector<std::string>& outputFilepaths,
int32_t logEveryN,
int32_t hashingPrime,
const std::string& hmacBase64Key) {
auto numShards = outputFilepaths.size();
auto inStreamPtr = fbpcf::io::getInputStream(inputFilename);
auto& inStream = inStreamPtr->get();
std::vector<std::string> tmpFilenames;
std::vector<std::unique_ptr<std::ofstream>> tmpFiles;
auto filename = std::filesystem::path{
private_lift::filepath_helpers::getBaseFilename(inputFilename)};
auto stem = filename.stem().string();
auto extension = filename.extension().string();
// Get a random ID to avoid potential name collisions if multiple
// runs at the same time point to the same input file
auto randomId = std::to_string(folly::Random::secureRand64());
for (auto i = 0; i < numShards; ++i) {
std::stringstream tmpName;
tmpName << randomId << "_" << stem << "_" << i << extension;
auto tmpFilepath = tmpDirectory / tmpName.str();
tmpFilenames.push_back(tmpFilepath.string());
tmpFiles.push_back(std::make_unique<std::ofstream>(tmpFilepath));
}
// First get the header and put it in all the output files
std::string line;
getline(inStream, line);
stripQuotes(line);
for (const auto& tmpFile : tmpFiles) {
*tmpFile << line << "\n";
}
XLOG(INFO) << "Got header line: '" << line;
// Read lines and send to appropriate outFile repeatedly
uint64_t line_idx = 0;
if (hmacBase64Key.empty()) {
while (getline(inStream, line)) {
stripQuotes(line);
auto commaPos = line.find_first_of(",");
auto id = line.substr(0, commaPos);
auto shard = hashString(id, hashingPrime) % numShards;
*tmpFiles.at(shard) << line << "\n";
++line_idx;
if (line_idx % logEveryN == 0) {
XLOG(INFO) << "Processed line "
<< private_lift::logging::formatNumber(line_idx);
}
}
} else {
while (getline(inStream, line)) {
stripQuotes(line);
auto commaPos = line.find_first_of(",");
auto id = line.substr(0, commaPos);
auto base64SaltedId =
private_lift::hash_slinging_salter::base64SaltedHashFromBase64Key(
id, hmacBase64Key);
auto shard = hashString(base64SaltedId, hashingPrime) % numShards;
*tmpFiles.at(shard) << base64SaltedId << line.substr(commaPos) << "\n";
++line_idx;
if (line_idx % logEveryN == 0) {
XLOG(INFO) << "Processed line "
<< private_lift::logging::formatNumber(line_idx);
}
}
}
XLOG(INFO) << "Finished after processing "
<< private_lift::logging::formatNumber(line_idx) << " lines.";
XLOG(INFO) << "Now copying files to final output path...";
for (auto i = 0; i < numShards; ++i) {
auto outputDst = outputFilepaths.at(i);
auto tmpFileSrc = tmpFilenames.at(i);
if (outputDst == tmpFileSrc) {
continue;
}
// Reset underlying unique_ptr to ensure buffer gets flushed
tmpFiles.at(i).reset();
XLOG(INFO) << "Writing " << tmpFileSrc << " -> " << outputDst;
auto outputType = fbpcf::io::getFileType(outputDst);
if (outputType == fbpcf::io::FileType::S3) {
private_lift::s3_utils::uploadToS3(tmpFileSrc, outputDst);
} else if (outputType == fbpcf::io::FileType::Local) {
std::filesystem::copy(
tmpFileSrc,
outputDst,
std::filesystem::copy_options::overwrite_existing);
} else {
throw std::runtime_error{"Unsupported output destination"};
}
// We need to make sure we clean up the tmpfiles now
std::remove(tmpFileSrc.c_str());
}
XLOG(INFO) << "All file writes successful";
}
int main(int argc, char** argv) {
folly::init(&argc, &argv);
gflags::ParseCommandLineFlags(&argc, &argv, true);
fbpcf::AwsSdk::aquire();
std::filesystem::path tmpDirectory{FLAGS_tmp_directory};
std::vector<std::string> outputFilepaths;
if (!FLAGS_output_filenames.empty()) {
std::stringstream ss{FLAGS_output_filenames};
while (ss.good()) {
std::string substr;
getline(ss, substr, ',');
outputFilepaths.push_back(std::move(substr));
}
} else if (!FLAGS_output_base_path.empty() && FLAGS_num_output_files > 0) {
std::string output_base_path = FLAGS_output_base_path + "_";
for (auto i = FLAGS_file_start_index;
i < FLAGS_file_start_index + FLAGS_num_output_files;
++i) {
outputFilepaths.push_back(output_base_path + std::to_string(i));
}
}
if (outputFilepaths.empty()) {
XLOG(ERR)
<< "Error: specify --output_filenames or --output_base_path, --file_start_index, and --num_output_files";
std::exit(1);
}
shardFile(
FLAGS_input_filename,
tmpDirectory,
outputFilepaths,
FLAGS_log_every_n,
FLAGS_hashing_prime,
FLAGS_hmac_base64_key);
return 0;
}
| 31.851351 | 113 | 0.665252 | [
"vector"
] |
eb967fdfedc471b491cdadf27b604cd973f4dd90 | 3,184 | cpp | C++ | AphasiaFrame.cpp | leakingmemory/aphasia-support-app | 40a1bda9629c6406243f7c4044a50c30cf227606 | [
"MIT"
] | null | null | null | AphasiaFrame.cpp | leakingmemory/aphasia-support-app | 40a1bda9629c6406243f7c4044a50c30cf227606 | [
"MIT"
] | null | null | null | AphasiaFrame.cpp | leakingmemory/aphasia-support-app | 40a1bda9629c6406243f7c4044a50c30cf227606 | [
"MIT"
] | null | null | null | //
// Created by jeo on 23.09.2021.
//
#include <memory>
#include "AphasiaFrame.h"
#include "guistring.h"
#include "PhrasesView.h"
#define FILL_SIZE 10000
#define TAB_HEIGHT 30
AphasiaFrame::AphasiaFrame(const wxString &title) : wxFrame(nullptr, wxID_ANY, title, wxDefaultPosition, wxSize(800, 600)), mainCategories() {
mainCategories = std::make_shared<std::vector<CategorySelection<CategorySelection<wxString>>>>();
mainCategories->push_back(CategorySelection<CategorySelection<wxString>>(STR("Handlinger"),
{
CategorySelection<wxString>(
STR("Gå til"),
{
STR("Google Earth"),
STR("kafe"),
STR("skolen"),
STR("byen"),
STR("sykehuset")
}
),
CategorySelection<wxString>(STR("Gå fra")),
CategorySelection<wxString>(STR("Kjøre til")),
CategorySelection<wxString>(STR("Kjøre fra")),
CategorySelection<wxString>(STR("Reise til")),
CategorySelection<wxString>(STR("Reise fra")),
CategorySelection<wxString>(STR("Klippe gress")),
CategorySelection<wxString>(STR("Klippe hår")),
CategorySelection<wxString>(STR("Male")),
CategorySelection<wxString>(STR("Spikre")),
CategorySelection<wxString>(STR("Fiske"))
}));
mainCategories->emplace_back(STR("Familie"));
mainCategories->emplace_back(STR("Kjente"));
mainCategories->emplace_back(STR("Natur"));
mainCategories->emplace_back(STR("Reiser"));
mainCategories->emplace_back(STR("Minner"));
tabControl = new wxNotebook(this, wxID_ANY, wxPoint(0,0), wxSize(FILL_SIZE, FILL_SIZE));
for (auto &mainCat : *mainCategories) {
tabControl->AddPage(new PhrasesView(tabControl, mainCat.Phrases), mainCat.Name, false);
}
struct ContextType {
std::vector<CategorySelection<wxString>> *secondPhrase;
ContextType() {
secondPhrase = nullptr;
}
};
std::shared_ptr<ContextType> Context = std::make_shared<ContextType>();
#ifndef __linux__
tabControl->SetTabSize(wxSize(-1, TAB_HEIGHT));
#endif
this->Bind(wxEVT_SIZE, &AphasiaFrame::OnResize, this);
}
void AphasiaFrame::OnResize(wxSizeEvent &event) {
UpdateSizes(event.GetSize());
}
void AphasiaFrame::UpdateSizes(const wxSize &size) {
tabControl->SetSize(wxSize(size.GetWidth(), size.GetHeight() - TAB_HEIGHT));
}
| 46.823529 | 142 | 0.497802 | [
"vector"
] |
eb978c1d9ba21392c28a5034efad56b611c25212 | 2,556 | cpp | C++ | src/game/world/aspects/actor_controller_aspect.cpp | jdmclark/gorc | a03d6a38ab7684860c418dd3d2e77cbe6a6d9fc8 | [
"Apache-2.0"
] | 97 | 2015-02-24T05:09:24.000Z | 2022-01-23T12:08:22.000Z | src/game/world/aspects/actor_controller_aspect.cpp | annnoo/gorc | 1889b4de6380c30af6c58a8af60ecd9c816db91d | [
"Apache-2.0"
] | 8 | 2015-03-27T23:03:23.000Z | 2020-12-21T02:34:33.000Z | src/game/world/aspects/actor_controller_aspect.cpp | annnoo/gorc | 1889b4de6380c30af6c58a8af60ecd9c816db91d | [
"Apache-2.0"
] | 10 | 2016-03-24T14:32:50.000Z | 2021-11-13T02:38:53.000Z | #include "actor_controller_aspect.hpp"
#include "game/world/level_model.hpp"
#include "game/world/events/thing_created.hpp"
#include "game/world/events/killed.hpp"
gorc::game::world::aspects::actor_controller_aspect::actor_controller_aspect(entity_component_system<thing_id>& cs)
: inner_join_aspect(cs) {
created_delegate =
cs.bus.add_handler<events::thing_created>([&](events::thing_created const &e) {
if(e.tpl.type == flags::thing_type::Actor) {
cs.emplace_component<components::actor>(e.thing);
}
});
killed_delegate =
cs.bus.add_handler<events::killed>([&](events::killed const &e) {
auto rng = cs.find_component<components::actor>(e.thing);
for(auto it = rng.begin(); it != rng.end(); ++it) {
for(auto &thing : cs.find_component<components::thing>(e.thing)) {
thing.second->thrust = make_zero_vector<3, float>();
}
}
ecs.erase_components<components::actor>(e.thing);
});
}
void gorc::game::world::aspects::actor_controller_aspect::update(time_delta t, thing_id, components::actor&, components::thing& thing) {
if(thing.ai_mode_flags & flags::ai_mode_flag::turning_to_face_target) {
// Get plane angle.
auto lv = thing.orient.transform(make_vector(0.0f, 1.0f, 0.0f));
auto plane_look = normalize(make_vector(get<0>(lv), get<1>(lv)));
auto v = thing.ai_look_target;
auto plane_v = normalize(make_vector(get<0>(v), get<1>(v)));
float base_yaw = to_degrees(atan2f(get<1>(plane_look), get<0>(plane_look)));
float target_yaw = to_degrees(atan2f(get<1>(plane_v), get<0>(plane_v)));
if(fabs(base_yaw - target_yaw) <= 0.5) {
thing.ai_mode_flags -= flags::ai_mode_flag::turning_to_face_target;
}
else {
thing.orient = slerp(thing.orient, make_rotation<float>(make_vector(0.0f, 0.0f, 1.0f), target_yaw - 90.0f), thing.ai_move_speed * static_cast<float>(t.count()) * 1.0f);
}
}
if(thing.ai_mode_flags & flags::ai_mode_flag::moving_toward_destination) {
auto v = thing.ai_move_target - thing.position;
get<2>(v) = 0.0f;
float vlen = length(v);
if(vlen > 0.005f) {
thing.thrust = (v / vlen) * thing.ai_move_speed * static_cast<float>(t.count()) * 6.0f;
}
else {
thing.thrust = make_zero_vector<3, float>();
thing.ai_mode_flags -= flags::ai_mode_flag::moving_toward_destination;
}
}
return;
}
| 39.323077 | 180 | 0.628717 | [
"transform"
] |
eba07ef0b9dd2c914ba2f3b466db8ff868bc332c | 3,150 | hh | C++ | client/coding/aont.hh | tinoryj/REED | 821e42a84237bdaef809879c1d9243fc047b736a | [
"MIT"
] | 2 | 2021-06-27T06:13:15.000Z | 2021-12-05T11:32:05.000Z | client/coding/aont.hh | tinoryj/REED | 821e42a84237bdaef809879c1d9243fc047b736a | [
"MIT"
] | null | null | null | client/coding/aont.hh | tinoryj/REED | 821e42a84237bdaef809879c1d9243fc047b736a | [
"MIT"
] | null | null | null | /*
* aont.hh
* crypto object for hashing and AES
*/
#ifndef __AONT_HH__
#define __AONT_HH__
#include <bits/stdc++.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>
#include "conf.hh"
#include "CryptoPrimitive.hh"
// chunk size
#define CHUNK_SIZE (4*1024*1024)
// indicator SIM: baseline, AVD: enhanced.
#define SIM 0
#define AVD 1
#define REED_TYPE 7
using namespace std;
class Aont {
private:
// encryption type indicator
int type_;
// crypto Obj
CryptoPrimitive *cryptoObj_;
// word size
int bytesPerWord_;
// aont key
unsigned char *key_;
// buffer for storing aligned data and its size
int alignedBufferSize_;
unsigned char *alignedBuffer_;
// mask bufer
unsigned char *mask_;
public:
/* constructor
*
* @param cryptoObj - crypto object for hashing and AES
* @param type - encryption type indicator
*
*/
Aont(CryptoPrimitive *cryptoObj, int type);
/*
* destructor
*/
~Aont();
/*
* general encode function
*
* @param buf - input buffer
* @param size - input size
* @param package - output buffer
* @param retSize - output size
* @param key - encryption key
* @param stub - output stub (64byte)
*/
int encode(unsigned char* buf, int size, unsigned char* package, int* retSize, unsigned char* key, unsigned char* stub);
/*
* general decode function
*
* @param package - input buffer
* @param size - input size
* @param buf - output buffer
* @param retSize - output size
*
*/
int decode(unsigned char* package, int size, unsigned char* buf, int* retSize);
/*
* baseline encode function
*
* @param buf - input buffer
* @param size - input size
* @param package - output buffer
* @param retSize - output size
* @param key - encryption key
* @param stub - output stub (64byte)
*/
int simple_encode(unsigned char* buf, int size, unsigned char* package, int* retSize, unsigned char* key, unsigned char* stub);
/*
* baseline decode function
*
* @param package - input buffer
* @param size - input size
* @param buf - output buffer
* @param retSize - output size
*
*/
int simple_decode(unsigned char* package, int size, unsigned char* buf, int* retSize);
/*
* enhanced encode function
*
* @param buf - input buffer
* @param size - input size
* @param package - output buffer
* @param retSize - output size
* @param key - encryption key
* @param stub - output stub (64byte)
*/
int adv_encode(unsigned char* buf, int size, unsigned char* package, int* retSize, unsigned char* key, unsigned char* stub);
/*
* enhanced decode function
*
* @param package - input buffer
* @param size - input size
* @param buf - output buffer
* @param retSize - output size
*
*/
int adv_decode(unsigned char* package, int size, unsigned char* buf, int* retSize);
/*
* hashing function
*
* @param buf - input buffer
* @param size - input size
* @param ret - returned hash value
*/
int getHash(unsigned char* buf, int size, unsigned char* ret);
};
#endif
| 21.724138 | 129 | 0.648571 | [
"object"
] |
eba3e3206ab03c6d808c98aa57dfcdf9f0649c59 | 3,688 | cpp | C++ | thirdparty/geogram/src/lib/geogram/image/image_rasterizer.cpp | AmericaMakes/OASIS-marcwang | 7aa10040251d7a1b807a773a45d123e1a52faac5 | [
"BSD-2-Clause"
] | 1 | 2021-03-07T14:47:09.000Z | 2021-03-07T14:47:09.000Z | thirdparty/geogram/src/lib/geogram/image/image_rasterizer.cpp | AmericaMakes/OASIS-marcwang | 7aa10040251d7a1b807a773a45d123e1a52faac5 | [
"BSD-2-Clause"
] | null | null | null | thirdparty/geogram/src/lib/geogram/image/image_rasterizer.cpp | AmericaMakes/OASIS-marcwang | 7aa10040251d7a1b807a773a45d123e1a52faac5 | [
"BSD-2-Clause"
] | 1 | 2021-03-07T00:24:57.000Z | 2021-03-07T00:24:57.000Z | /*
* OGF/Graphite: Geometry and Graphics Programming Library + Utilities
* Copyright (C) 2000 Bruno Levy
*
* 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., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* If you modify this software, you should include a notice giving the
* name of the person performing the modification, the date of modification,
* and the reason for such modification.
*
* Contact: Bruno Levy
*
* levy@loria.fr
*
* ISA Project
* LORIA, INRIA Lorraine,
* Campus Scientifique, BP 239
* 54506 VANDOEUVRE LES NANCY CEDEX
* FRANCE
*
* Note that the GNU General Public License does not permit incorporating
* the Software into proprietary programs.
*/
#include <geogram/image/image_rasterizer.h>
namespace GEO {
ImageRasterizer::ImageRasterizer(
Image* image, double x1, double y1, double x2, double y2
) : image_(image) {
x1_ = x1;
y1_ = y1;
x2_ = x2;
y2_ = y2;
component_encoding_ = image_->component_encoding();
nb_components_ = index_t(
Image::nb_components(image_->color_encoding())
);
}
void ImageRasterizer::clear() {
Memory::clear(image_->base_mem(), image_->bytes());
}
void ImageRasterizer::triangle(
const vec2& p1, const Color& c1,
const vec2& p2, const Color& c2,
const vec2& p3, const Color& c3
) {
vec2i P1,P2,P3;
transform(p1,P1);
transform(p2,P2);
transform(p3,P3);
// Find triangle's bounding box.
int xmin = std::min(P1.x,std::min(P2.x,P3.x));
int ymin = std::min(P1.y,std::min(P2.y,P3.y));
int xmax = std::max(P1.x,std::max(P2.x,P3.x));
int ymax = std::max(P1.y,std::max(P2.y,P3.y));
geo_clamp(xmin, 0, int(image_->width()-1));
geo_clamp(xmax, 0, int(image_->width()-1));
geo_clamp(ymin, 0, int(image_->height()-1));
geo_clamp(ymax, 0, int(image_->height()-1));
int D = (P2.x - P1.x) * (P3.y - P1.y) - (P2.y - P1.y) * (P3.x - P1.x);
if(D == 0) {
return;
}
// Iterative computation of barycentric coordinates.
int cxl1 = P2.y - P3.y;
int cxl2 = P3.y - P1.y;
int cxl3 = P1.y - P2.y;
int cyl1 = P3.x - P2.x;
int cyl2 = P1.x - P3.x;
int cyl3 = P2.x - P1.x;
int c0l1 = P2.x*P3.y-P3.x*P2.y;
int c0l2 = P3.x*P1.y-P1.x*P3.y;
int c0l3 = P1.x*P2.y-P2.x*P1.y;
int row_l1 = xmin * cxl1 + ymin * cyl1 + c0l1;
int row_l2 = xmin * cxl2 + ymin * cyl2 + c0l2;
int row_l3 = xmin * cxl3 + ymin * cyl3 + c0l3;
for(int y=ymin; y<ymax; ++y) {
int l1 = row_l1;
int l2 = row_l2;
int l3 = row_l3;
for(int x=xmin; x<xmax; ++x) {
if(
(D > 0 && l1 >= 0.0 && l2 >= 0.0 && l3 >= 0.0) ||
(D < 0 && l1 <= 0.0 && l2 <= 0.0 && l3 <= 0.0)
) {
Color c;
interpolate_color(
c1,c2,c3,
double(l1)/double(D),
double(l2)/double(D),
double(l3)/double(D),
c
);
set_pixel(x,y,c);
}
l1 += cxl1;
l2 += cxl2;
l3 += cxl3;
}
row_l1 += cyl1;
row_l2 += cyl2;
row_l3 += cyl3;
}
}
}
| 27.318519 | 78 | 0.598698 | [
"geometry",
"transform"
] |
ebafc485727086f6d53c0ddc635e0b2b80647137 | 6,918 | cpp | C++ | dev/Gems/ScriptCanvas/Code/Editor/Assets/Functions/ScriptCanvasFunctionAssetHandler.cpp | brianherrera/lumberyard | f85344403c1c2e77ec8c75deb2c116e97b713217 | [
"AML"
] | 1,738 | 2017-09-21T10:59:12.000Z | 2022-03-31T21:05:46.000Z | dev/Gems/ScriptCanvas/Code/Editor/Assets/Functions/ScriptCanvasFunctionAssetHandler.cpp | ArchitectureStudios/lumberyard | f85344403c1c2e77ec8c75deb2c116e97b713217 | [
"AML"
] | 427 | 2017-09-29T22:54:36.000Z | 2022-02-15T19:26:50.000Z | dev/Gems/ScriptCanvas/Code/Editor/Assets/Functions/ScriptCanvasFunctionAssetHandler.cpp | ArchitectureStudios/lumberyard | f85344403c1c2e77ec8c75deb2c116e97b713217 | [
"AML"
] | 671 | 2017-09-21T08:04:01.000Z | 2022-03-29T14:30:07.000Z | /*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include "precompiled.h"
#include <ScriptCanvas/Assets/Functions/ScriptCanvasFunctionAssetHandler.h>
#include <ScriptCanvas/Asset/RuntimeAsset.h>
#include <ScriptCanvas/Bus/ScriptCanvasBus.h>
#include <Core/ScriptCanvasBus.h>
#include <ScriptCanvas/Components/EditorGraph.h>
#include <ScriptCanvas/Components/EditorScriptCanvasComponent.h>
#include <ScriptCanvas/Components/EditorGraphVariableManagerComponent.h>
#include <GraphCanvas/GraphCanvasBus.h>
#include <AzCore/IO/GenericStreams.h>
#include <AzCore/IO/FileIO.h>
#include <AzCore/Serialization/Utils.h>
#include <AzCore/Serialization/SerializeContext.h>
#include <AzCore/Component/ComponentApplicationBus.h>
#include <AzCore/Component/Entity.h>
#include <AzCore/std/string/string_view.h>
#include <AzFramework/StringFunc/StringFunc.h>
#include <AzToolsFramework/API/EditorAssetSystemAPI.h>
#include <ScriptCanvas/Asset/Functions/ScriptCanvasFunctionAsset.h>
namespace ScriptCanvasEditor
{
ScriptCanvasFunctionAssetHandler::ScriptCanvasFunctionAssetHandler(AZ::SerializeContext* context)
: ScriptCanvasAssetHandler(context)
{
AZ::AssetTypeInfoBus::MultiHandler::BusConnect(azrtti_typeid<ScriptCanvas::ScriptCanvasFunctionAsset>());
}
ScriptCanvasFunctionAssetHandler::~ScriptCanvasFunctionAssetHandler()
{
AZ::AssetTypeInfoBus::MultiHandler::BusDisconnect();
}
AZ::Data::AssetPtr ScriptCanvasFunctionAssetHandler::CreateAsset(const AZ::Data::AssetId& id, const AZ::Data::AssetType& type)
{
AZ_UNUSED(type);
ScriptCanvas::ScriptCanvasFunctionAsset* assetData = aznew ScriptCanvas::ScriptCanvasFunctionAsset(id);
AZ::Entity* scriptCanvasEntity = aznew AZ::Entity(ScriptCanvas::AssetDescription::GetEntityName<ScriptCanvas::ScriptCanvasFunctionAsset>());
SystemRequestBus::Broadcast(&SystemRequests::CreateEditorComponentsOnEntity, scriptCanvasEntity, azrtti_typeid<ScriptCanvas::RuntimeFunctionAsset>());
assetData->m_cachedComponent = scriptCanvasEntity->CreateComponent<ScriptCanvas::ScriptCanvasFunctionDataComponent>();
assetData->SetScriptCanvasEntity(scriptCanvasEntity);
return assetData;
}
bool ScriptCanvasFunctionAssetHandler::LoadAssetData(const AZ::Data::Asset<AZ::Data::AssetData>& asset, AZ::IO::GenericStream* stream, const AZ::Data::AssetFilterCB& assetLoadFilterCB)
{
ScriptCanvas::ScriptCanvasFunctionAsset* scriptCanvasAsset = asset.GetAs<ScriptCanvas::ScriptCanvasFunctionAsset>();
AZ_Assert(m_serializeContext, "ScriptCanvasFunctionAssetHandler needs to be initialized with a SerializeContext");
if (scriptCanvasAsset)
{
stream->Seek(0U, AZ::IO::GenericStream::ST_SEEK_BEGIN);
bool loadSuccess = AZ::Utils::LoadObjectFromStreamInPlace(*stream, scriptCanvasAsset->GetScriptCanvasData(), m_serializeContext, AZ::ObjectStream::FilterDescriptor(assetLoadFilterCB, AZ::ObjectStream::FILTERFLAG_IGNORE_UNKNOWN_CLASSES));
if (loadSuccess)
{
scriptCanvasAsset->m_cachedComponent = scriptCanvasAsset->GetScriptCanvasData().GetScriptCanvasEntity()->FindComponent<ScriptCanvas::ScriptCanvasFunctionDataComponent>();
}
return loadSuccess;
}
return false;
}
bool ScriptCanvasFunctionAssetHandler::SaveAssetData(const AZ::Data::Asset<AZ::Data::AssetData>& asset, AZ::IO::GenericStream* stream)
{
return SaveAssetData(asset.GetAs<ScriptCanvas::ScriptCanvasFunctionAsset>(), stream);
}
bool ScriptCanvasFunctionAssetHandler::SaveAssetData(const ScriptCanvas::ScriptCanvasFunctionAsset* assetData, AZ::IO::GenericStream* stream)
{
return SaveAssetData(assetData, stream, AZ::DataStream::ST_XML);
}
bool ScriptCanvasFunctionAssetHandler::SaveAssetData(const ScriptCanvas::ScriptCanvasFunctionAsset* assetData, AZ::IO::GenericStream* stream, AZ::DataStream::StreamType streamType)
{
if (assetData && m_serializeContext)
{
AZStd::vector<char> byteBuffer;
AZ::IO::ByteContainerStream<decltype(byteBuffer)> byteStream(&byteBuffer);
AZ::ObjectStream* objStream = AZ::ObjectStream::Create(&byteStream, *m_serializeContext, streamType);
const ScriptCanvas::ScriptCanvasData& functionData = assetData->GetScriptCanvasData();
bool assetSaved = objStream->WriteClass(&functionData);
objStream->Finalize();
assetSaved = stream->Write(byteBuffer.size(), byteBuffer.data()) == byteBuffer.size() && assetSaved;
return assetSaved;
}
return false;
}
AZ::Data::AssetType ScriptCanvasFunctionAssetHandler::GetAssetType() const
{
return ScriptCanvasFunctionAssetHandler::GetAssetTypeStatic();
}
const char* ScriptCanvasFunctionAssetHandler::GetAssetTypeDisplayName() const
{
return ScriptCanvas::AssetDescription::GetAssetTypeDisplayName<ScriptCanvas::ScriptCanvasFunctionAsset>();
}
bool ScriptCanvasFunctionAssetHandler::CanCreateComponent(const AZ::Data::AssetId& assetId) const
{
return false;
}
void ScriptCanvasFunctionAssetHandler::GetAssetTypeExtensions(AZStd::vector<AZStd::string>& extensions)
{
const AZ::Uuid& assetType = *AZ::AssetTypeInfoBus::GetCurrentBusId();
if (assetType == AZ::AzTypeInfo<ScriptCanvas::ScriptCanvasFunctionAsset>::Uuid())
{
extensions.push_back(ScriptCanvas::AssetDescription::GetExtension<ScriptCanvas::ScriptCanvasFunctionAsset>());
}
}
void ScriptCanvasFunctionAssetHandler::GetHandledAssetTypes(AZStd::vector<AZ::Data::AssetType>& assetTypes)
{
assetTypes.push_back(AZ::AzTypeInfo<ScriptCanvas::ScriptCanvasFunctionAsset>::Uuid());
}
AZ::Data::AssetType ScriptCanvasFunctionAssetHandler::GetAssetTypeStatic()
{
return azrtti_typeid<ScriptCanvas::ScriptCanvasFunctionAsset>();
}
const char* ScriptCanvasFunctionAssetHandler::GetGroup() const
{
return ScriptCanvas::AssetDescription::GetGroup<ScriptCanvas::ScriptCanvasFunctionAsset>();
}
const char* ScriptCanvasFunctionAssetHandler::GetBrowserIcon() const
{
return ScriptCanvas::AssetDescription::GetIconPath<ScriptCanvas::ScriptCanvasFunctionAsset>();
}
} // namespace ScriptCanvasEditor
| 43.2375 | 249 | 0.742989 | [
"vector"
] |
ebb4250cb967c672eaa3da7fd590fd5f00992a28 | 2,458 | cpp | C++ | src/entities/carmature.cpp | meoblast001/citrine | 9e97484d33860213555d865ec81b301c59b0657c | [
"MIT"
] | null | null | null | src/entities/carmature.cpp | meoblast001/citrine | 9e97484d33860213555d865ec81b301c59b0657c | [
"MIT"
] | null | null | null | src/entities/carmature.cpp | meoblast001/citrine | 9e97484d33860213555d865ec81b301c59b0657c | [
"MIT"
] | null | null | null | /*
Copyright (C) 2010 Braden Walters
This software may be modified and distributed under the terms of the MIT
license. See the LICENSE file for details.
*/
#include "carmature.h"
#include "../math/cvector.h"
using namespace Citrine;
std::pair<Vertex*, unsigned short> Citrine::ArmatureVertexDeform(std::pair<Vertex*, unsigned short> vertices, std::pair<Armature*, unsigned short> armatures)
{
//Allocate space for new vertices
std::pair<Vertex*, unsigned short> results;
results.first = new Vertex[vertices.second];
results.second = vertices.second;
for (unsigned short i = 0; i < vertices.second; i++)
{
//Construct Vector3 out of current vertex
Vector3 current_vert;
current_vert.x = vertices.first[i].position.x;
current_vert.y = vertices.first[i].position.y;
current_vert.z = vertices.first[i].position.z;
//If weights sum to 0, there is no armature influence
if (vertices.first[i].weights.x + vertices.first[i].weights.y + vertices.first[i].weights.z + vertices.first[i].weights.w == 0.0f)
{
results.first[i].position.x = current_vert.x;
results.first[i].position.y = current_vert.y;
results.first[i].position.z = current_vert.z;
}
else
{
Vector3 result;
result.x = 0.0f;
result.y = 0.0f;
result.z = 0.0f;
//Perform (armature * vertex) * weight for each valid armature
if (vertices.first[i].armatures[0] > 0)
result += (armatures.first[vertices.first[i].armatures[0] - 1].transformation.GetRotationMatrix() * current_vert) * vertices.first[i].weights.x;
if (vertices.first[i].armatures[1] > 0)
result += (armatures.first[vertices.first[i].armatures[1] - 1].transformation.GetRotationMatrix() * current_vert) * vertices.first[i].weights.y;
if (vertices.first[i].armatures[2] > 0)
result += (armatures.first[vertices.first[i].armatures[2] - 1].transformation.GetRotationMatrix() * current_vert) * vertices.first[i].weights.z;
if (vertices.first[i].armatures[3] > 0)
result += (armatures.first[vertices.first[i].armatures[3] - 1].transformation.GetRotationMatrix() * current_vert) * vertices.first[i].weights.w;
//Copy result vector to result vertex
results.first[i].position.x = result.x;
results.first[i].position.y = result.y;
results.first[i].position.z = result.z;
//Copy unchanged vertex values
results.first[i].texcoord.x = vertices.first[i].texcoord.x;
results.first[i].texcoord.y = vertices.first[i].texcoord.y;
}
}
return results;
}
| 39.015873 | 157 | 0.709927 | [
"vector"
] |
ebb703a6fb9e81aef290d3b8fc5113ffd60cf6cf | 1,016 | cpp | C++ | test/main.cpp | alxarsenault/axServer | cb5edf5a3d3010abe182e8c8b61bafbb8f3800f4 | [
"MIT"
] | 1 | 2015-10-18T07:48:20.000Z | 2015-10-18T07:48:20.000Z | test/main.cpp | alxarsenault/axServer | cb5edf5a3d3010abe182e8c8b61bafbb8f3800f4 | [
"MIT"
] | null | null | null | test/main.cpp | alxarsenault/axServer | cb5edf5a3d3010abe182e8c8b61bafbb8f3800f4 | [
"MIT"
] | null | null | null | //
// main.cpp
// ~~~~~~~~
//
// Copyright (c) 2003-2013 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#include <iostream>
#include <string>
// #include <boost/asio.hpp>
#include <boost/filesystem.hpp>
#include <boost/range/iterator_range.hpp>
#include "axPython.h"
int main(int argc, char* argv[])
{
axPython python(argc, argv);
// python.InsertFolder(".");
// python.InsertFolder("/Library/Python/2.7/site-packages/googleapiclient/");
// python.InsertFolder("/Library/Python/2.7/site-packages/oauth2client/");
python.InsertFolder("/Library/Python/2.7/site-packages/");
python.InsertFolder("/Library/Python/2.7/");
python.LoadModule("ttt");
std::vector<std::string> args;
std::string answer = python.CallFunction("StringTest", args);
std::cout << answer << std::endl;
return 0;
}
| 25.4 | 81 | 0.667323 | [
"vector"
] |
ebbf9d1aafc11a6b4775db319fe2457ec0a7dcc2 | 649 | cpp | C++ | cpp-leetcode/leetcode441-arranging-coins_binary_search.cpp | yanglr/LeetCodeOJ | 27dd1e4a2442b707deae7921e0118752248bef5e | [
"MIT"
] | 45 | 2021-07-25T00:45:43.000Z | 2022-03-24T05:10:43.000Z | cpp-leetcode/leetcode441-arranging-coins_binary_search.cpp | yanglr/LeetCodeOJ | 27dd1e4a2442b707deae7921e0118752248bef5e | [
"MIT"
] | null | null | null | cpp-leetcode/leetcode441-arranging-coins_binary_search.cpp | yanglr/LeetCodeOJ | 27dd1e4a2442b707deae7921e0118752248bef5e | [
"MIT"
] | 15 | 2021-07-25T00:40:52.000Z | 2021-12-27T06:25:31.000Z | #include<algorithm>
#include<vector>
#include<cmath>
#include<unordered_set>
#include<iostream>
using namespace std;
using LL = long long;
class Solution {
public:
int arrangeCoins(int n) {
LL left = 0, right = (LL)n + 1;
while (left < right)
{
LL mid = left + (right - left) / 2; // 防止整型溢出
LL target = (mid + 1) * mid / 2;
if (target <= n)
left = mid + 1;
else right = mid;
}
return left - 1;
}
};
// Test
int main()
{
Solution sol;
int num = 10;
auto res = sol.arrangeCoins(num);
cout << res << endl;
return 0;
} | 19.088235 | 57 | 0.508475 | [
"vector"
] |
ebc4d3b83a01f29602f6d7740c868cf64e15f7c7 | 766 | hpp | C++ | src/core/Core/Config/ParameterBuilder.hpp | krieselreihe/litr | ffaa7ecd09bfede01f5eb6edc957562363eadfc2 | [
"MIT"
] | 3 | 2020-11-26T15:46:48.000Z | 2021-08-16T11:12:48.000Z | src/core/Core/Config/ParameterBuilder.hpp | krieselreihe/litr | ffaa7ecd09bfede01f5eb6edc957562363eadfc2 | [
"MIT"
] | 57 | 2020-09-21T08:00:29.000Z | 2022-03-31T18:46:29.000Z | src/core/Core/Config/ParameterBuilder.hpp | krieselreihe/litr | ffaa7ecd09bfede01f5eb6edc957562363eadfc2 | [
"MIT"
] | null | null | null | #pragma once
#include <string>
#include <toml.hpp>
#include "Core/Base.hpp"
#include "Core/Config/Parameter.hpp"
namespace Litr::Config {
class ParameterBuilder {
public:
ParameterBuilder(const toml::table& file, const toml::value& data, const std::string& name);
void AddDescription();
void AddDescription(const std::string& description);
void AddShortcut();
void AddShortcut(const std::vector<Ref<Parameter>>& params);
void AddDefault();
void AddType();
[[nodiscard]] inline Ref<Parameter> GetResult() const { return m_Parameter; }
[[nodiscard]] static bool IsReservedName(const std::string& name);
private:
const toml::table& m_File;
const toml::value& m_Table;
const Ref<Parameter> m_Parameter;
};
} // namespace Litr::Config
| 23.212121 | 94 | 0.720627 | [
"vector"
] |
ebc722e05988f79471fb8bac5aaf5f24038b16a4 | 20,585 | cpp | C++ | layer5/TestPyMOL.cpp | kingdavid72/pymol-OpenSource | 8068af8b53a4ae16657b536e83bfd5310e58a8bd | [
"CNRI-Python"
] | 2 | 2019-05-23T22:17:29.000Z | 2020-07-03T14:36:22.000Z | layer5/TestPyMOL.cpp | telamonian/pymol | 8192e75bf3d4c1072d6bd399b7dacd065bf78a06 | [
"CNRI-Python"
] | null | null | null | layer5/TestPyMOL.cpp | telamonian/pymol | 8192e75bf3d4c1072d6bd399b7dacd065bf78a06 | [
"CNRI-Python"
] | null | null | null |
/*
A* -------------------------------------------------------------------
B* This file contains source code for the PyMOL computer program
C* Copyright (c) Schrodinger, LLC.
D* -------------------------------------------------------------------
E* It is unlawful to modify or remove this copyright notice.
F* -------------------------------------------------------------------
G* Please see the accompanying LICENSE file for further information.
H* -------------------------------------------------------------------
I* Additional authors of this source file include:
-*
-*
-*
Z* -------------------------------------------------------------------
*/
/* Module for internal C-level PyMOL tests...*/
#include"os_python.h"
#include"os_predef.h"
#include"os_std.h"
#include"Base.h"
#include"MemoryDebug.h"
#include"Feedback.h"
#include"TestPyMOL.h"
#include"ObjectCGO.h"
#include"VFont.h"
#include"ObjectGadget.h"
#include"P.h"
#include"ObjectMap.h"
#include"Executive.h"
#include"ButMode.h"
#include"Control.h"
#include"PyMOL.h"
static int TestPyMOL_00_00(PyMOLGlobals * G)
{
ObjectMap *obj;
ObjectMapDesc _md, *md;
ObjectMapState *ms = NULL;
int a;
md = &_md;
md->mode = cObjectMap_OrthoMinMaxGrid;
for(a = 0; a < 3; a++) {
md->Grid[a] = 0.1F;
md->MinCorner[a] = 0.0F;
md->MaxCorner[a] = a + 1.0F;
}
md->init_mode = -2;
obj = ObjectMapNew(G);
if(obj) {
ms = ObjectMapNewStateFromDesc(G, obj, md, 0, true);
ms->Active = true;
}
if(obj) {
ObjectSetName((CObject *) obj, "00_00");
ExecutiveManageObject(G, (CObject *) obj, -1, false);
}
return (obj != NULL);
}
#define STR_MAX 100
static char *get_st(const char array[][STR_MAX])
{
char *result = NULL;
size_t c = 0, l = 0;
while(array[c][0]) {
l += strlen(array[c]);
c++;
}
result = Alloc(char, l + 1);
l = 0;
c = 0;
while(array[c][0]) {
strcpy(result + l, array[c]);
l += strlen(array[c]);
c++;
}
return result;
}
static const char pdb_01_01[][STR_MAX] = {
"ATOM 1 N ASP E 1 4.868 -17.809 25.188 1.00 34.37 E N\n",
"ATOM 2 CA ASP E 1 3.984 -16.723 25.698 1.00 33.85 E C\n",
"ATOM 3 CB ASP E 1 4.633 -16.020 26.888 1.00 35.91 E C\n",
"ATOM 4 CG ASP E 1 6.016 -15.468 26.567 1.00 39.23 E C\n",
"ATOM 5 OD1 ASP E 1 6.340 -14.367 27.058 1.00 42.40 E O\n",
"ATOM 6 OD2 ASP E 1 6.787 -16.131 25.836 1.00 39.28 E O\n",
"ATOM 7 C ASP E 1 3.789 -15.753 24.546 1.00 33.96 E C\n",
"ATOM 8 O ASP E 1 4.456 -15.889 23.517 1.00 35.44 E O\n",
"ATOM 9 N CYS E 2 2.908 -14.771 24.711 1.00 31.94 E N\n",
"ATOM 10 CA CYS E 2 2.638 -13.825 23.633 1.00 29.67 E C\n",
"ATOM 11 CB CYS E 2 1.198 -13.996 23.132 1.00 28.73 E C\n",
"ATOM 12 SG CYS E 2 0.725 -15.681 22.638 1.00 25.85 E S\n",
"ATOM 13 C CYS E 2 2.842 -12.366 24.012 1.00 30.31 E C\n",
"ATOM 14 O CYS E 2 3.025 -12.039 25.188 1.00 30.74 E O\n",
"ATOM 15 N ALA E 3 2.792 -11.504 22.996 1.00 30.15 E N\n",
"ATOM 16 CA ALA E 3 2.923 -10.056 23.151 1.00 30.15 E C\n",
"ATOM 17 CB ALA E 3 4.226 -9.566 22.552 1.00 30.82 E C\n",
"ATOM 18 C ALA E 3 1.736 -9.418 22.436 1.00 29.90 E C\n",
"ATOM 19 O ALA E 3 1.332 -9.867 21.362 1.00 28.16 E O\n",
"ATOM 20 N TRP E 4 1.173 -8.377 23.038 1.00 31.77 E N\n",
"ATOM 21 CA TRP E 4 0.007 -7.715 22.471 1.00 32.08 E C\n",
"ATOM 22 CB TRP E 4 -1.233 -7.992 23.344 1.00 32.83 E C\n",
"ATOM 23 CG TRP E 4 -1.500 -9.458 23.636 1.00 35.04 E C\n",
"ATOM 24 CD1 TRP E 4 -0.831 -10.264 24.528 1.00 35.36 E C\n",
"ATOM 25 CD2 TRP E 4 -2.507 -10.285 23.037 1.00 35.86 E C\n",
"ATOM 26 CE2 TRP E 4 -2.390 -11.576 23.610 1.00 34.80 E C\n",
"ATOM 27 CE3 TRP E 4 -3.500 -10.059 22.069 1.00 36.66 E C\n",
"ATOM 28 NE1 TRP E 4 -1.360 -11.535 24.514 1.00 33.13 E N\n",
"ATOM 29 CZ2 TRP E 4 -3.228 -12.638 23.249 1.00 36.81 E C\n",
"ATOM 30 CZ3 TRP E 4 -4.338 -11.120 21.706 1.00 37.35 E C\n",
"ATOM 31 CH2 TRP E 4 -4.194 -12.390 22.297 1.00 38.27 E C\n",
"ATOM 32 C TRP E 4 0.231 -6.212 22.372 1.00 32.17 E C\n",
"ATOM 33 O TRP E 4 0.752 -5.592 23.297 1.00 33.32 E O\n",
"ATOM 34 N HIS E 5 -0.135 -5.634 21.235 1.00 32.18 E N\n",
"ATOM 35 CA HIS E 5 -0.006 -4.205 21.043 1.00 32.91 E C\n",
"ATOM 36 CB HIS E 5 0.791 -3.871 19.783 1.00 33.02 E C\n",
"ATOM 37 CG HIS E 5 0.939 -2.396 19.549 1.00 32.86 E C\n",
"ATOM 38 CD2 HIS E 5 0.582 -1.619 18.499 1.00 31.48 E C\n",
"ATOM 39 ND1 HIS E 5 1.470 -1.542 20.495 1.00 29.87 E N\n",
"ATOM 40 CE1 HIS E 5 1.431 -0.303 20.038 1.00 29.68 E C\n",
"ATOM 41 NE2 HIS E 5 0.896 -0.322 18.831 1.00 29.87 E N\n",
"ATOM 42 C HIS E 5 -1.408 -3.636 20.918 1.00 34.58 E C\n",
"ATOM 43 O HIS E 5 -2.092 -3.870 19.914 1.00 35.87 E O\n",
"ATOM 44 N LEU E 6 -1.838 -2.904 21.943 1.00 34.54 E N\n",
"ATOM 45 CA LEU E 6 -3.165 -2.295 21.956 1.00 34.66 E C\n",
"ATOM 46 CB LEU E 6 -3.266 -1.199 20.892 1.00 34.44 E C\n",
"ATOM 47 CG LEU E 6 -2.302 -0.023 21.018 1.00 35.32 E C\n",
"ATOM 48 CD1 LEU E 6 -2.422 0.863 19.781 1.00 34.55 E C\n",
"ATOM 49 CD2 LEU E 6 -2.582 0.753 22.302 1.00 33.68 E C\n",
"ATOM 50 C LEU E 6 -4.242 -3.339 21.698 1.00 36.23 E C\n",
"ATOM 51 O LEU E 6 -5.181 -3.100 20.933 1.00 35.26 E O\n",
"ATOM 52 N GLY E 7 -4.087 -4.506 22.315 1.00 37.53 E N\n",
"ATOM 53 CA GLY E 7 -5.063 -5.564 22.138 1.00 38.95 E C\n",
"ATOM 54 C GLY E 7 -4.781 -6.514 20.988 1.00 39.52 E C\n",
"ATOM 55 O GLY E 7 -5.188 -7.669 21.049 1.00 42.08 E O\n",
"ATOM 56 N GLU E 8 -4.092 -6.046 19.948 1.00 39.31 E N\n",
"ATOM 57 CA GLU E 8 -3.771 -6.883 18.787 1.00 38.11 E C\n",
"ATOM 58 CB GLU E 8 -3.361 -6.012 17.607 1.00 40.57 E C\n",
"ATOM 59 CG GLU E 8 -4.472 -5.586 16.679 1.00 43.48 E C\n",
"ATOM 60 CD GLU E 8 -3.920 -4.806 15.506 1.00 47.43 E C\n",
"ATOM 61 OE1 GLU E 8 -3.572 -5.421 14.467 1.00 44.53 E O\n",
"ATOM 62 OE2 GLU E 8 -3.800 -3.572 15.644 1.00 50.21 E O\n",
"ATOM 63 C GLU E 8 -2.646 -7.877 19.066 1.00 35.96 E C\n",
"ATOM 64 O GLU E 8 -1.643 -7.529 19.691 1.00 37.36 E O\n",
"ATOM 65 N LEU E 9 -2.793 -9.104 18.579 1.00 32.21 E N\n",
"ATOM 66 CA LEU E 9 -1.763 -10.108 18.791 1.00 27.94 E C\n",
"ATOM 67 CB LEU E 9 -2.275 -11.515 18.478 1.00 28.00 E C\n",
"ATOM 68 CG LEU E 9 -1.255 -12.643 18.693 1.00 27.79 E C\n",
"ATOM 69 CD1 LEU E 9 -0.819 -12.720 20.160 1.00 24.02 E C\n",
"ATOM 70 CD2 LEU E 9 -1.848 -13.963 18.233 1.00 26.33 E C\n",
"ATOM 71 C LEU E 9 -0.569 -9.800 17.911 1.00 25.48 E C\n",
"ATOM 72 O LEU E 9 -0.699 -9.660 16.692 1.00 25.09 E O\n",
"ATOM 73 N VAL E 10 0.589 -9.697 18.547 1.00 22.25 E N\n",
"ATOM 74 CA VAL E 10 1.835 -9.417 17.858 1.00 18.77 E C\n",
"ATOM 75 CB VAL E 10 2.797 -8.578 18.759 1.00 17.44 E C\n",
"ATOM 76 CG1 VAL E 10 4.131 -8.351 18.068 1.00 17.34 E C\n",
"ATOM 77 CG2 VAL E 10 2.166 -7.248 19.110 1.00 17.12 E C\n",
"ATOM 78 C VAL E 10 2.537 -10.717 17.473 1.00 19.09 E C\n",
"ATOM 79 O VAL E 10 2.708 -11.019 16.296 1.00 18.92 E O\n",
"ATOM 80 N TRP E 11 2.886 -11.525 18.465 1.00 19.41 E N\n",
"ATOM 81 CA TRP E 11 3.622 -12.742 18.191 1.00 18.86 E C\n",
"ATOM 82 CB TRP E 11 5.059 -12.338 17.887 1.00 14.44 E C\n",
"ATOM 83 CG TRP E 11 5.840 -13.342 17.171 1.00 14.67 E C\n",
"ATOM 84 CD1 TRP E 11 6.700 -14.257 17.709 1.00 11.97 E C\n",
"ATOM 85 CD2 TRP E 11 5.886 -13.519 15.756 1.00 16.13 E C\n",
"ATOM 86 CE2 TRP E 11 6.804 -14.562 15.500 1.00 17.59 E C\n",
"ATOM 87 CE3 TRP E 11 5.250 -12.894 14.676 1.00 18.07 E C\n",
"ATOM 88 NE1 TRP E 11 7.284 -14.992 16.711 1.00 13.12 E N\n",
"ATOM 89 CZ2 TRP E 11 7.101 -14.995 14.196 1.00 16.12 E C\n",
"ATOM 90 CZ3 TRP E 11 5.548 -13.321 13.382 1.00 16.68 E C\n",
"ATOM 91 CH2 TRP E 11 6.466 -14.362 13.157 1.00 17.19 E C\n",
"ATOM 92 C TRP E 11 3.637 -13.609 19.431 1.00 21.88 E C\n",
"ATOM 93 O TRP E 11 3.449 -13.097 20.534 1.00 24.04 E O\n",
"ATOM 94 N CYS E 12 3.878 -14.908 19.252 1.00 24.56 E N\n",
"ATOM 95 CA CYS E 12 3.978 -15.845 20.367 1.00 27.16 E C\n",
"ATOM 96 CB CYS E 12 2.709 -16.674 20.541 1.00 25.57 E C\n",
"ATOM 97 SG CYS E 12 1.146 -15.762 20.653 1.00 29.62 E S\n",
"ATOM 98 C CYS E 12 5.126 -16.810 20.107 1.00 30.17 E C\n",
"ATOM 99 O CYS E 12 5.278 -17.322 18.998 1.00 29.17 E O\n",
"ATOM 100 N THR E 13 5.959 -17.026 21.117 1.00 35.02 E N\n",
"ATOM 101 CA THR E 13 7.053 -17.973 20.984 1.00 39.40 E C\n",
"ATOM 102 CB THR E 13 8.289 -17.578 21.828 1.00 38.42 E C\n",
"ATOM 103 CG2 THR E 13 8.919 -16.310 21.286 1.00 37.78 E C\n",
"ATOM 104 OG1 THR E 13 7.908 -17.397 23.194 1.00 38.69 E O\n",
"ATOM 105 C THR E 13 6.513 -19.322 21.459 1.00 42.05 E C\n",
"ATOM 106 O THR E 13 5.962 -19.432 22.570 1.00 41.54 E O\n",
"ATOM 107 OXT THR E 13 6.606 -20.331 20.602 1.00 43.02 E O\n",
"END\n",
""
};
static const char mol_01_02[][STR_MAX] = {
"MFCD02681585\n",
" ChemPy 3D 0\n",
"\n",
" 36 39 0 0 1 0 0 0 0 0999 V2000\n",
" 52.5122 32.1815 21.0164 O 0 0 0 0 0 0 0 0 0 0 0 0\n",
" 53.1716 32.3766 20.0197 C 0 0 0 0 0 0 0 0 0 0 0 0\n",
" 54.4517 31.7147 19.8169 C 0 0 0 0 0 0 0 0 0 0 0 0\n",
" 54.7302 30.3758 20.0244 N 0 0 0 0 0 0 0 0 0 0 0 0\n",
" 56.0228 30.0429 19.7805 N 0 0 0 0 0 0 0 0 0 0 0 0\n",
" 56.5952 31.1894 19.3737 C 0 0 0 0 0 0 0 0 0 0 0 0\n",
" 55.6544 32.2488 19.3610 C 0 0 0 0 0 0 0 0 0 0 0 0\n",
" 58.0576 31.2220 18.9914 C 0 0 0 0 0 0 0 0 0 0 0 0\n",
" 58.8985 30.2129 19.7561 C 0 0 0 0 0 0 0 0 0 0 0 0\n",
" 58.1952 30.8995 17.4763 C 0 0 0 0 0 0 0 0 0 0 0 0\n",
" 58.6099 32.6423 19.2418 C 0 0 0 0 0 0 0 0 0 0 0 0\n",
" 53.8260 29.3227 20.4323 C 0 0 0 0 0 0 0 0 0 0 0 0\n",
" 54.0916 28.8513 21.8755 C 0 0 0 0 0 0 0 0 0 0 0 0\n",
" 53.2812 29.2854 22.9295 C 0 0 0 0 0 0 0 0 0 0 0 0\n",
" 53.4667 28.8569 24.2265 C 0 0 0 0 0 0 0 0 0 0 0 0\n",
" 52.5554 29.3273 25.3339 C 0 0 0 0 0 0 0 0 0 0 0 0\n",
" 54.5278 27.9533 24.4780 C 0 0 0 0 0 0 0 0 0 0 0 0\n",
" 55.3346 27.5330 23.4437 C 0 0 0 0 0 0 0 0 0 0 0 0\n",
" 55.1252 27.9853 22.1551 C 0 0 0 0 0 0 0 0 0 0 0 0\n",
" 52.8162 33.2369 18.9768 N 0 0 0 0 0 0 0 0 0 0 0 0\n",
" 51.5459 33.8650 18.8063 C 0 0 0 0 0 0 0 0 0 0 0 0\n",
" 50.7291 34.3547 19.8196 C 0 0 0 0 0 0 0 0 0 0 0 0\n",
" 49.4781 34.9470 19.5308 C 0 0 0 0 0 0 0 0 0 0 0 0\n",
" 48.6170 35.3669 20.6527 C 0 0 0 0 0 0 0 0 0 0 0 0\n",
" 49.0272 35.8529 21.7164 O 0 0 0 0 0 0 0 0 0 0 0 0\n",
" 47.3132 35.1061 20.3115 O 0 0 0 0 0 0 0 0 0 0 0 0\n",
" 46.3612 35.5386 21.2706 C 0 0 0 0 0 0 0 0 0 0 0 0\n",
" 49.0388 35.0753 18.1950 C 0 0 0 0 0 0 0 0 0 0 0 0\n",
" 49.8568 34.5421 17.1857 C 0 0 0 0 0 0 0 0 0 0 0 0\n",
" 51.0846 33.9564 17.4684 C 0 0 0 0 0 0 0 0 0 0 0 0\n",
" 47.7773 35.7058 17.8640 N 0 0 0 0 0 0 0 0 0 0 0 0\n",
" 46.9256 35.1276 16.8017 C 0 0 0 0 0 0 0 0 0 0 0 0\n",
" 45.5301 35.6792 16.9429 C 0 0 0 0 0 0 0 0 0 0 0 0\n",
" 45.5107 37.1034 16.9789 O 0 0 0 0 0 0 0 0 0 0 0 0\n",
" 46.2587 37.5980 18.0839 C 0 0 0 0 0 0 0 0 0 0 0 0\n",
" 47.7345 37.1658 17.9831 C 0 0 0 0 0 0 0 0 0 0 0 0\n",
" 1 2 2 0 0 0 0\n",
" 2 3 1 0 0 0 0\n",
" 2 20 1 0 0 0 0\n",
" 3 4 4 0 0 0 0\n",
" 3 7 4 0 0 0 0\n",
" 4 5 4 0 0 0 0\n",
" 4 12 1 0 0 0 0\n",
" 5 6 4 0 0 0 0\n",
" 6 7 4 0 0 0 0\n",
" 6 8 1 0 0 0 0\n",
" 8 9 1 0 0 0 0\n",
" 8 10 1 0 0 0 0\n",
" 8 11 1 0 0 0 0\n",
" 12 13 1 0 0 0 0\n",
" 13 14 4 0 0 0 0\n",
" 13 19 4 0 0 0 0\n",
" 14 15 4 0 0 0 0\n",
" 15 16 1 0 0 0 0\n",
" 15 17 4 0 0 0 0\n",
" 17 18 4 0 0 0 0\n",
" 18 19 4 0 0 0 0\n",
" 20 21 1 0 0 0 0\n",
" 21 22 4 0 0 0 0\n",
" 21 30 4 0 0 0 0\n",
" 22 23 4 0 0 0 0\n",
" 23 24 1 0 0 0 0\n",
" 23 28 4 0 0 0 0\n",
" 24 25 2 0 0 0 0\n",
" 24 26 1 0 0 0 0\n",
" 26 27 1 0 0 0 0\n",
" 28 29 4 0 0 0 0\n",
" 28 31 1 0 0 0 0\n",
" 29 30 4 0 0 0 0\n",
" 31 32 1 0 0 0 0\n",
" 31 36 1 0 0 0 0\n",
" 32 33 1 0 0 0 0\n",
" 33 34 1 0 0 0 0\n",
" 34 35 1 0 0 0 0\n",
" 35 36 1 0 0 0 0\n",
"M END\n"
};
int TestPyMOLRun(PyMOLGlobals * G, int group, int test)
{
switch (group) {
case 0: /* development tests */
switch (test) {
case 0:
TestPyMOL_00_00(G);
break;
case 1:
PBlock(G);
VFontLoad(G, 1, 0, 0, true);
PUnblock(G);
break;
case 2:
{
CObject *obj = NULL;
float pos[3] = { 0.0, 0.0, 0.0 };
PBlock(G);
obj = (CObject *) ObjectCGONewVFontTest(G, "hello", pos);
PUnblock(G);
if(obj) {
ObjectSetName(obj, "hello");
ExecutiveManageObject(G, obj, -1, false);
}
}
break;
case 3:
{
CObject *obj = NULL;
obj = (CObject *) ObjectGadgetTest(G);
if(obj) {
ObjectSetName(obj, "gadget");
ExecutiveManageObject(G, obj, -1, false);
}
}
break;
case 4:
{
/* try to match G3D */
SettingSetGlobal_b(G, cSetting_ortho, 1);
const float light[3] = { 1.0F, -1.0F, -2.5F };
SettingSet_3fv(G->Setting, cSetting_light, light);
}
break;
}
break;
case 1:
/* set up for test usage as a simple viewer */
PyMOL_SetDefaultMouse(G->PyMOL);
switch (test) {
case 1:
{
char *st = get_st(pdb_01_01);
PyMOL_CmdLoad(G->PyMOL, st, "string", "pdb", "test_01_01", 0, false, true, true,
false, PYMOL_DEFAULT);
ExecutiveSetRepVisib(G, "test_01_01", cRepCyl, 1);
ExecutiveSetRepVisib(G, "test_01_01", cRepLine, 0);
SettingSetGlobal_f(G, cSetting_sweep_speed, 3.0F);
ControlRock(G, 1);
FreeP(st);
break;
}
break;
case 2:
{
char *st = get_st(pdb_01_01);
PyMOL_CmdLoad(G->PyMOL, st, "string", "pdb", "test_01_02", 0, false, true, true,
false, PYMOL_DEFAULT);
ExecutiveSetRepVisib(G, "test_01_02", cRepLine, 0);
ExecutiveSetRepVisib(G, "test_01_02", cRepSurface, 1);
ControlRock(G, 1);
FreeP(st);
break;
}
break;
case 3:
{
char *st = get_st(pdb_01_01);
PyMOL_CmdLoad(G->PyMOL, st, "string", "pdb", "test_01_03", 0, false, true, true,
false, PYMOL_DEFAULT);
ExecutiveSetRepVisib(G, "test_01_03", cRepLine, 0);
ExecutiveSetRepVisib(G, "test_01_03", cRepCartoon, 1);
SettingSetGlobal_f(G, cSetting_sweep_speed, 1.50F);
ControlRock(G, 1);
FreeP(st);
break;
}
break;
case 4:
{
char *st = get_st(pdb_01_01);
PyMOL_CmdLoad(G->PyMOL, st, "string", "pdb", "test_01_04", 0, false, true, true,
false, PYMOL_DEFAULT);
ExecutiveSetRepVisib(G, "test_01_04", cRepLine, 0);
ExecutiveSetRepVisib(G, "test_01_04", cRepDot, 1);
SettingSetGlobal_f(G, cSetting_sweep_speed, 1.50F);
ControlRock(G, 1);
FreeP(st);
break;
}
break;
case 5:
{
char *st = get_st(pdb_01_01);
PyMOL_CmdLoad(G->PyMOL, st, "string", "pdb", "test_01_05", 0, false, true, true,
false, PYMOL_DEFAULT);
ExecutiveSetRepVisib(G, "test_01_05", cRepLine, 0);
ExecutiveSetRepVisib(G, "test_01_05", cRepSphere, 1);
SettingSetGlobal_f(G, cSetting_sweep_speed, 4.50F);
ControlRock(G, 1);
FreeP(st);
break;
}
break;
case 6:
{
char *st = get_st(pdb_01_01);
PyMOL_CmdLoad(G->PyMOL, st, "string", "pdb", "test_01_06", 0, false, true, true,
false, PYMOL_DEFAULT);
SettingSetGlobal_f(G, cSetting_sweep_speed, 4.50F);
ControlRock(G, 1);
FreeP(st);
break;
}
break;
case 7:
{
char *st = get_st(mol_01_02);
ExecutiveLoad(G, st, -1, cLoadTypeMOLStr, "test_01_07", 0, -1, 0, 1, 0, 1,
NULL, 0, NULL);
ExecutiveSetRepVisib(G, "test_01_07", cRepCyl, 1);
ExecutiveSetRepVisib(G, "test_01_07", cRepLine, 0);
SettingSetGlobal_b(G, cSetting_valence, 1);
SettingSetGlobal_f(G, cSetting_sweep_speed, 0.25F);
SettingSetGlobal_f(G, cSetting_sweep_angle, 180.0F);
ControlRock(G, 1);
FreeP(st);
break;
}
break;
case 8:
{
char *st = get_st(mol_01_02);
ExecutiveLoad(G, st, -1, cLoadTypeMOLStr, "test_01_08", 0, -1, 0, 1, 0, 1,
NULL, 0, NULL);
SettingSetGlobal_b(G, cSetting_valence, 1);
ControlRock(G, 1);
FreeP(st);
break;
}
break;
case 9:
{
char *st = get_st(mol_01_02);
ExecutiveLoad(G, st, -1, cLoadTypeMOLStr, "test_01_09", 0, -1, 0, 1, 0, 1,
NULL, 0, NULL);
ExecutiveSetRepVisib(G, "test_01_09", cRepMesh, 1);
ExecutiveSetRepVisib(G, "test_01_09", cRepLine, 0);
SettingSetGlobal_b(G, cSetting_valence, 1);
SettingSetGlobal_f(G, cSetting_sweep_speed, 0.50F);
SettingSetGlobal_f(G, cSetting_sweep_angle, 90.0F);
ControlRock(G, 1);
FreeP(st);
break;
}
break;
}
}
return 1;
}
| 44.460043 | 88 | 0.456692 | [
"3d"
] |
1b0e8c0ff5443ab47e8ac26497c95b3cb6226272 | 11,099 | hpp | C++ | lockfree/Messenger.hpp | unevens/lockfree-async | 57009fc5270d3b42b8ff8c57c6c2961cdcf299b1 | [
"MIT"
] | 2 | 2020-04-06T01:50:26.000Z | 2021-03-18T17:19:36.000Z | lockfree/Messenger.hpp | unevens/lockfree-async | 57009fc5270d3b42b8ff8c57c6c2961cdcf299b1 | [
"MIT"
] | null | null | null | lockfree/Messenger.hpp | unevens/lockfree-async | 57009fc5270d3b42b8ff8c57c6c2961cdcf299b1 | [
"MIT"
] | null | null | null | /*
Copyright 2019-2021 Dario Mambro
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.
*/
#pragma once
#include "QueueWorld/QwMpmcPopAllLifoStack.h"
#include <algorithm>
#include <atomic>
#include <cassert>
#include <functional>
#include <memory>
#include <optional>
namespace lockfree {
/*
The LifoMessanger class uses QwMpmcPopAllLifoStack from
https://github.com/RossBencina/QueueWorld by Ross Bencina.
QwMpmcPopAllLifoStack is a multiple-producer
multiple-consumer LIFO stack that supports push() and pop_all() operations,
but not pop().
See QwMpmcPopAllLifoStack.h
*/
/**
* Template class for the nodes of lock-free multiple-producer multiple-consumer
* LIFO stack.
* @tparam T data type held by the node.
* @see QwLinkTraits.h
*/
template<typename T>
class MessageNode final
{
T message;
public:
// QwLinkTraits interface begin
enum
{
LINK_INDEX_1 = 0,
PREV_LINK,
LINK_COUNT
};
MessageNode* links_[2];
/**
* Constructor.
* @param message the message to store in the MessageNode
*/
explicit MessageNode(T message)
: message{ std::move(message) }
, links_{ nullptr, nullptr }
{}
/**
* @return a reference to the message stored in the MessageNode.
*/
T& get()
{
return message;
}
/**
* Sets the message.
* @param message_ the message to store in the MessageNode object.
*/
void set(T message_)
{
message = std::move(message_);
}
/**
* @return a reference to the next MessageNode in the stack.
*/
MessageNode*& next()
{
return links_[0];
}
/**
* @return a reference to the previous MessageNode in the stack. This is only
* used by handleMessageStack, and its result is not valid anywhere else.
*/
MessageNode*& prev()
{
return links_[1];
}
/**
* @return a reference to the last MessageNode in the stack.
*/
MessageNode* last()
{
auto it = this;
while (it->next()) {
it = it->next();
}
return it;
}
/**
* @return the number of MessageNodes in the stack, starting from this one.
*/
int count()
{
int num = 0;
auto it = this;
while (it) {
++num;
it = it->next();
}
return num;
}
};
/**
* Handles a stack of received message nodes using a functor. The messages will
* be handled in the order they were sent.
* @tparam T data type held by the node.
* @tparam Action the type of the functor to call on the message nodes, e.g.
* std::function<void(MessageNode<T>)>
* @param head the head node of the stack
* @param action the functor to use
* @see QwLinkTraits.h
*/
template<typename T, class Action>
inline void handleMessageStack(MessageNode<T>* head, Action action)
{
if (!head) {
return;
}
// gotta handle the message in FIFO order, so we cache that order using the
// MessageNode<T>::prev() link poiner
head->prev() = nullptr;
while (head->next()) {
head->next()->prev() = head;
head = head->next();
}
// and we loop from the new head (which is the last node of the lifo stack)
// using the prev pointer
while (head) {
action(head->get());
head = head->prev();
}
}
/**
* Frees a stack of message nodes.
* @tparam T data type held by the node.
* @see QwLinkTraits.h
*/
template<typename T>
inline void freeMessageStack(MessageNode<T>* head)
{
while (head) {
auto next = head->next();
delete head;
head = next;
}
}
/**
* An alias for QueueWorld's QwMpmcPopAllLifoStack.
* @tparam T the type of the data held by the nodes
*/
template<typename T>
using LifoStack = QwMpmcPopAllLifoStack<MessageNode<T>*, MessageNode<T>::LINK_INDEX_1>;
/**
* Wrapper around QueueWorld's QwMpmcPopAllLifoStack with functionality to
* allocate and recycle nodes.
* @tparam T the type of the data held by the nodes, char is used as default for
* Messages that are just notification and do not need to have data.
*/
template<typename T>
class Messenger final
{
LifoStack<T> lifo;
LifoStack<T> storage;
public:
/**
* Sends a message already wrapped in a MessageNode. Non-blocking.
* @param node the massage node to send.
*/
void send(MessageNode<T>* node)
{
lifo.push(node);
}
/**
* Sends a stack of message nodes. Non-blocking.
* @param head the head node of the stack.
*/
void sendMultiple(MessageNode<T>* head)
{
lifo.push_multiple(head, head->last());
}
/**
* Sends a Message, wrapping in a MessageNode from the storage if there is
* one available, otherwise it allocates a new one.
* @param message the massage to send.
*/
bool send(T&& message)
{
auto node = storage.pop_all();
bool fromStorage = true;
if (!node) {
node = new MessageNode<T>(std::move(message));
fromStorage = false;
}
if (fromStorage) {
node->set(std::move(message));
auto next = node->next();
node->next() = nullptr;
if (next) {
storage.push_multiple(next, next->last());
}
}
lifo.push(node);
return fromStorage;
}
/**
* Sends a Message, wrapping it in a MessageNode from the storage if there is
* one available, otherwise it does not send the message and returns false.
* @param message the massage to send.
* @return true if the message was sent, false if it was not sent
*/
bool sendIfNodeAvailable(T&& message)
{
auto node = storage.pop_all();
if (!node) {
return false;
}
else {
node->set(std::move(message));
auto next = node->next();
node->next() = nullptr;
if (next) {
storage.push_multiple(next, next->last());
}
}
lifo.push(node);
return true;
}
/**
* Receives the message that was sent for last. Non blocking. If there is any
* message not yet received, "ReceiveLast" will move the one that was sent for
* last to its argument, and return true; otherwise it will return false.
* REMARK: When "receiveLastMessage" is called, ONLY the message sent for last
* is received, all the others are discarded.
* @return a std::optional holding the maybe received message
*/
std::optional<T> receiveLastMessage()
{
MessageNode<T>* head = lifo.pop_all();
if (!head) {
return std::nullopt;
}
auto message = std::optional<T>(std::move(head->get()));
storage.push_multiple(head, head->last());
return message;
}
/**
* Receives the message that was sent for last, wrapped in the MessageNode it
* was sent in. Non blocking. Returns nullptr if there are no messages to be
* received.
* REMARK: When "receiveLastNode" is called, ONLY the message sent
* for last is received, all the others are discarded.
* @return the received message node.
*/
MessageNode<T>* receiveLastNode()
{
MessageNode<T>* head = lifo.pop_all();
if (!head) {
return nullptr;
}
if (head->next()) {
storage.push_multiple(head->next(), head->last());
head->next() = nullptr;
}
return head;
}
/**
* Receives all the messages and returned the stack of nodes that hold them.
* @return the head node of the stack of message nodes.
*/
MessageNode<T>* receiveAllNodes()
{
return lifo.pop_all();
}
/**
* @return all the preallocated message nodes that are kept in storage.
*/
MessageNode<T>* popStorage()
{
return storage.pop_all();
}
/**
* Recycles a stack of message nodes.
* @param stack the stack of nodes to recycle.
*/
void recycle(MessageNode<T>* stack)
{
if (stack) {
storage.push_multiple(stack, stack->last());
}
}
/**
* Allocates message nodes using the default constructor of T and puts them into the storage, ready to be used for
* sending messages.
* @param numNodesToAllocate the number of nodes to allocate.
*/
void allocateNodes(int numNodesToAllocate)
{
MessageNode<T>* head = nullptr;
MessageNode<T>* it = nullptr;
for (int i = 0; i < numNodesToAllocate; ++i) {
auto node = new MessageNode<T>(T{});
if (it) {
it->next() = node;
it = node;
}
else if (!head) {
head = it = node;
}
}
recycle(head);
}
/**
* Allocates message nodes using initializer functor and puts them into the storage, ready to be used for
* sending messages.
* @param numNodesToAllocate the number of nodes to allocate.
* @param initializer functor to initialize the nodes.
*/
void allocateNodes(int numNodesToAllocate, typename std::function<T()> initializer)
{
MessageNode<T>* head = nullptr;
MessageNode<T>* it = nullptr;
for (int i = 0; i < numNodesToAllocate; ++i) {
auto node = new MessageNode<T>(initializer());
if (it) {
it->next() = node;
it = node;
}
else if (!head) {
head = it = node;
}
}
recycle(head);
}
/**
* Discards all messages, recycling their nodes.
*/
void discardAllMessages()
{
recycle(lifo.pop_all());
}
/**
* Frees any nodes currently in the storage.
*/
void freeStorage()
{
freeMessageStack(storage.pop_all());
}
/**
* Discards all messages and frees the nodes that were holding them.
*/
void discardAndFreeAllMessages()
{
freeMessageStack(lifo.pop_all());
}
/**
* Destructor.
*/
~Messenger()
{
discardAndFreeAllMessages();
freeStorage();
}
};
/**
* Receive messages using a Messenger and handles the with a functor.
* @tparam T the type of the data held by the nodes
* @tparam Action the type of the functor to call on the message nodes, e.g.
* std::function<void(MessageNode<T>)>
* @param messenger the messenger to receive the messages from
* @param action the functor to call on the received nodes
* @return the number of handled messages
*/
template<typename T, class Action>
inline int receiveAndHandleMessageStack(Messenger<T>& messenger, Action action)
{
auto messages = messenger.receiveAllNodes();
auto numMessages = messages->count();
handleMessageStack(messages, action);
messenger.recycle(messages);
return numMessages;
}
} // namespace lockfree
| 25.340183 | 116 | 0.659158 | [
"object"
] |
1b14ce4a6e9780e667b171283e13bad9cb4d631d | 2,636 | hpp | C++ | include/eve/module/special/regular/lbeta.hpp | clayne/eve | dc268b5db474376e1c53f5a474f5bb42b7c4cb59 | [
"MIT"
] | null | null | null | include/eve/module/special/regular/lbeta.hpp | clayne/eve | dc268b5db474376e1c53f5a474f5bb42b7c4cb59 | [
"MIT"
] | null | null | null | include/eve/module/special/regular/lbeta.hpp | clayne/eve | dc268b5db474376e1c53f5a474f5bb42b7c4cb59 | [
"MIT"
] | null | null | null | /*
EVE - Expressive Vector Engine
Copyright : EVE Contributors & Maintainers
SPDX-License-Identifier: MIT
*/
//==================================================================================================
#pragma once
#include <eve/detail/overload.hpp>
namespace eve
{
//================================================================================================
//! @addtogroup special
//! @{
//! @var lbeta
//!
//! @brief Callable object computing the logarithm of the beta function.
//!
//!
//! #### Members Functions
//!
//! | Member | Effect |
//! |:-------------|:-----------------------------------------------------------|
//! | `operator()` | the lbeta operation |
//! | `operator[]` | Construct a conditional version of current function object |
//!
//! ---
//!
//! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
//! template< floating_value T, floating_value U > auto operator()( T x, U y ) const noexcept requires compatible< T, U >;
//! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//!
//! **Parameters**
//!
//!`x`, `y`: [values](@ref eve::value).
//!
//! **Return value**
//!
//!Returns [elementwise](@ref glossary_elementwise) \f$\displaystyle \log\left(\frac{\Gamma(x)\Gamma(y)}{\Gamma(x+y)}\right)\f$.
//!
//! The result type is the [common compatible type](@ref common_compatible) of the two parameters.
//!
//! ---
//!
//! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
//! auto operator[]( conditional_expression auto cond ) const noexcept;
//! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//!
//! Higher-order function generating a masked version of eve::lbeta
//!
//! **Parameters**
//!
//! `cond` : conditional expression
//!
//! **Return value**
//!
//! A Callable object so that the expression `lbeta[cond](x, ...)` is equivalent to `if_else(cond,lbeta(x, ...),x)`
//!
//! ---
//!
//! #### Supported decorators
//!
//!
//! * eve::diff, eve::diff_1st, eve::diff_2nd, eve::diff_nth
//!
//!
//! The expression `derivative_1st(lbeta)(x,y)` and `derivative_2nd(lbeta)(x,y)` computes the partial
//! derivatives of \f$f\f$, where \f$f\f$ is the function \f$(x,y) \rightarrow \ \log(\mbox{B}(x,y))\f$.
//!
//! #### Example
//!
//! @godbolt{doc/special/lbeta.cpp}
//!
//! @}
//================================================================================================
EVE_MAKE_CALLABLE(lbeta_, lbeta);
}
#include <eve/module/special/regular/impl/lbeta.hpp>
| 32.54321 | 130 | 0.437785 | [
"object",
"vector"
] |
1b214ca0a4081523b82d97eede380b631e5cfa46 | 3,311 | cpp | C++ | novatel_gps_driver/src/parsers/gpgsa.cpp | Robotics-Mechatronics-Group/novatel_gps_driver_modified | f57138506245cdcad8862d00df6fc62fdf2f90a0 | [
"BSD-3-Clause"
] | 2 | 2018-06-05T14:28:15.000Z | 2019-07-05T02:26:16.000Z | novatel_gps_driver/src/parsers/gpgsa.cpp | Robotics-Mechatronics-Group/novatel_gps_driver_modified | f57138506245cdcad8862d00df6fc62fdf2f90a0 | [
"BSD-3-Clause"
] | null | null | null | novatel_gps_driver/src/parsers/gpgsa.cpp | Robotics-Mechatronics-Group/novatel_gps_driver_modified | f57138506245cdcad8862d00df6fc62fdf2f90a0 | [
"BSD-3-Clause"
] | 2 | 2018-07-06T09:30:26.000Z | 2018-10-09T05:53:51.000Z | // *****************************************************************************
//
// Copyright (c) 2017, Southwest Research Institute® (SwRI®)
// 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 Southwest Research Institute® (SwRI®) 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 SOUTHWEST RESEARCH INSTITUTE 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 <novatel_gps_driver/parsers/gpgsa.h>
#include <boost/make_shared.hpp>
const std::string novatel_gps_driver::GpgsaParser::MESSAGE_NAME = "GPGSA";
uint32_t novatel_gps_driver::GpgsaParser::GetMessageId() const
{
return 0;
}
const std::string novatel_gps_driver::GpgsaParser::GetMessageName() const
{
return MESSAGE_NAME;
}
novatel_gps_msgs::GpgsaPtr novatel_gps_driver::GpgsaParser::ParseAscii(const novatel_gps_driver::NmeaSentence& sentence) throw(ParseException)
{
// Check the length first -- should be 18 elements long
const size_t LENGTH = 18;
if (sentence.body.size() != LENGTH)
{
std::stringstream error;
error << "Expected GPGSA length " << LENGTH
<< ", actual length " << sentence.body.size();
throw ParseException(error.str());
}
novatel_gps_msgs::GpgsaPtr msg = boost::make_shared<novatel_gps_msgs::Gpgsa>();
msg->message_id = sentence.body[0];
msg->auto_manual_mode = sentence.body[1];
ParseUInt8(sentence.body[2], msg->fix_mode);
// Words 3-14 of the sentence are SV IDs. Copy only the non-null strings.
msg->sv_ids.resize(12, 0);
size_t n_svs = 0;
for (std::vector<std::string>::const_iterator id = sentence.body.begin()+3; id < sentence.body.begin()+15; ++id)
{
if (! id->empty())
{
ParseUInt8(*id, msg->sv_ids[n_svs]);
++n_svs;
}
}
msg->sv_ids.resize(n_svs);
ParseFloat(sentence.body[15], msg->pdop);
ParseFloat(sentence.body[16], msg->hdop);
ParseFloat(sentence.body[17], msg->vdop);
return msg;
}
| 41.911392 | 142 | 0.69254 | [
"vector"
] |
1b22767940595894fb4e8e9ceb1ecbaffd612e28 | 2,211 | hpp | C++ | src/plugins/intel_gpu/include/intel_gpu/primitives/gather_nd.hpp | ryanloney/openvino-1 | 4e0a740eb3ee31062ba0df88fcf438564f67edb7 | [
"Apache-2.0"
] | 1,127 | 2018-10-15T14:36:58.000Z | 2020-04-20T09:29:44.000Z | src/plugins/intel_gpu/include/intel_gpu/primitives/gather_nd.hpp | ryanloney/openvino-1 | 4e0a740eb3ee31062ba0df88fcf438564f67edb7 | [
"Apache-2.0"
] | 439 | 2018-10-20T04:40:35.000Z | 2020-04-19T05:56:25.000Z | src/plugins/intel_gpu/include/intel_gpu/primitives/gather_nd.hpp | ryanloney/openvino-1 | 4e0a740eb3ee31062ba0df88fcf438564f67edb7 | [
"Apache-2.0"
] | 414 | 2018-10-17T05:53:46.000Z | 2020-04-16T17:29:53.000Z | // Copyright (C) 2018-2022 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#pragma once
#include "primitive.hpp"
namespace cldnn {
/// @addtogroup cpp_api C++ API
/// @{
/// @addtogroup cpp_topology Network Topology
/// @{
/// @addtogroup cpp_primitives Primitives
/// @{
/// @brief
/// @details
struct gather_nd : public primitive_base<gather_nd> {
CLDNN_DECLARE_PRIMITIVE(gather_nd)
/// @brief Constructs gather_nd primitive.
///
/// @param id This primitive id.
/// @param data Input data primitive id.
/// @param indices Input indexes primitive id.
/// @param input_rank Rank of input data.
/// @param indices_rank Rank of indices.
/// @param batch_dims batch_dims as an attribute of GatherND. Optional.
/// @param batch_merged_output batched output shape is merged as a dimention for v5.
/// In case of output{3, 2, 4, 5} at batch_dims = 2, real output shape should be {6, 4, 5}.
/// This should be false for v8.
/// For batch_dims < 2, This doesn't have any meaning.
gather_nd(const primitive_id& id,
const primitive_id& data,
const primitive_id& indices,
const uint8_t input_rank,
const uint8_t indices_rank,
const uint8_t batch_dims = 0,
const bool batch_merged_output = true,
const primitive_id& ext_prim_id = "",
const padding& output_padding = padding())
: primitive_base(id, {data, indices}, ext_prim_id, output_padding),
input_rank(input_rank),
indices_rank(indices_rank),
batch_dims(batch_dims),
batch_merged_output(batch_merged_output) {}
/// @brief GatherND input_rank
uint8_t input_rank;
/// @brief GatherND indices_rank
uint8_t indices_rank;
/// @brief GatherND batch_dims
uint8_t batch_dims;
/// @brief GatherND batch_merged_output
bool batch_merged_output;
};
/// @}
/// @}
/// @}
} // namespace cldnn
| 34.546875 | 123 | 0.58209 | [
"shape"
] |
1b2313e812e6de98d1b8bbfcf7efd9c2b8d211f0 | 421 | hpp | C++ | Part F Finite Difference Methods/Exercise F Finite Difference Methods/Level9/Level9Code/Level9Code/UtilitiesDJD/VectorsAndMatrices/ArrayMechanisms.hpp | bondxue/Option-Pricing-Model | 5f22df0ff31e90fd536eb216c5af19c697fb87b2 | [
"MIT"
] | null | null | null | Part F Finite Difference Methods/Exercise F Finite Difference Methods/Level9/Level9Code/Level9Code/UtilitiesDJD/VectorsAndMatrices/ArrayMechanisms.hpp | bondxue/Option-Pricing-Model | 5f22df0ff31e90fd536eb216c5af19c697fb87b2 | [
"MIT"
] | null | null | null | Part F Finite Difference Methods/Exercise F Finite Difference Methods/Level9/Level9Code/Level9Code/UtilitiesDJD/VectorsAndMatrices/ArrayMechanisms.hpp | bondxue/Option-Pricing-Model | 5f22df0ff31e90fd536eb216c5af19c697fb87b2 | [
"MIT"
] | null | null | null | // ArrayMechanisms.hpp
//
// (C) Datasim Education BV 2003-2012
#ifndef ArrayMechanisms_hpp
#define ArrayMechanisms_hpp
#include "UtilitiesDJD/VectorsAndMatrices/Vector.cpp"
////////////// Useful and Basic Print Functions ////////////////////////////////////////////////////
template <typename V, typename I> void print(const Array<V,I>& v);
template <typename V, typename I> void print(const Vector<V,I>& v);
#endif | 28.066667 | 100 | 0.643705 | [
"vector"
] |
1b262aabe06b36955fa1442203c208b645cb6ae9 | 1,300 | cpp | C++ | csapex_scan_2d/src/split_labeled_scan.cpp | AdrianZw/csapex_core_plugins | 1b23c90af7e552c3fc37c7dda589d751d2aae97f | [
"BSD-3-Clause"
] | 2 | 2016-09-02T15:33:22.000Z | 2019-05-06T22:09:33.000Z | csapex_scan_2d/src/split_labeled_scan.cpp | AdrianZw/csapex_core_plugins | 1b23c90af7e552c3fc37c7dda589d751d2aae97f | [
"BSD-3-Clause"
] | 1 | 2021-02-11T09:14:31.000Z | 2021-02-27T09:30:14.000Z | csapex_scan_2d/src/split_labeled_scan.cpp | AdrianZw/csapex_core_plugins | 1b23c90af7e552c3fc37c7dda589d751d2aae97f | [
"BSD-3-Clause"
] | 6 | 2016-10-12T00:55:23.000Z | 2021-02-10T17:49:25.000Z | /// HEADER
#include "split_labeled_scan.h"
/// PROJECT
#include <csapex/model/node_modifier.h>
#include <csapex/msg/generic_vector_message.hpp>
#include <csapex/msg/io.h>
#include <csapex/param/parameter_factory.h>
#include <csapex/utility/register_apex_plugin.h>
#include <csapex_scan_2d/labeled_scan_message.h>
#include <csapex_scan_2d/scan_message.h>
CSAPEX_REGISTER_CLASS(csapex::SplitLabeledScan, csapex::Node)
using namespace csapex;
using namespace csapex::connection_types;
SplitLabeledScan::SplitLabeledScan()
{
}
void SplitLabeledScan::setupParameters(Parameterizable& parameters)
{
}
void SplitLabeledScan::setup(NodeModifier& node_modifier)
{
in_ = node_modifier.addInput<LabeledScanMessage>("Labeled Scan");
out_scan_ = node_modifier.addOutput<ScanMessage>("Scan");
out_labels_ = node_modifier.addOutput<GenericVectorMessage, int>("Labels");
}
void SplitLabeledScan::process()
{
LabeledScanMessage::ConstPtr input = msg::getMessage<LabeledScanMessage>(in_);
ScanMessage::Ptr output_scan(new ScanMessage);
output_scan->value = input->value;
msg::publish(out_scan_, output_scan);
std::shared_ptr<std::vector<int>> labels(new std::vector<int>);
*labels = input->value.labels;
msg::publish<GenericVectorMessage, int>(out_labels_, labels);
}
| 28.26087 | 82 | 0.77 | [
"vector",
"model"
] |
1b2bf836b758b5253448d245eadda7e95961e463 | 20,441 | cpp | C++ | executor/lib/graph_task.cpp | wangshankun/Tengine | 65c8e2e60e2df88afb65ea4ae466c11d10529ce8 | [
"Apache-2.0"
] | 3 | 2019-12-27T02:31:59.000Z | 2021-08-04T05:59:03.000Z | executor/lib/graph_task.cpp | houzh/Tengine | 423aaaf7e9008679f64a78ee93c8ebf7dbd58dc9 | [
"Apache-2.0"
] | null | null | null | executor/lib/graph_task.cpp | houzh/Tengine | 423aaaf7e9008679f64a78ee93c8ebf7dbd58dc9 | [
"Apache-2.0"
] | null | null | null | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
/*
* Copyright (c) 2018, Open AI Lab
* Author: haitao@openailab.com
*/
#include <string.h>
#include <atomic>
#include <set>
#include "tengine_errno.hpp"
#include "generic_engine.hpp"
#include "logger.hpp"
#include "graph_task.hpp"
#include "graph_executor.hpp"
#include "dev_scheduler.hpp"
#include "graph_perf.hpp"
namespace TEngine {
GraphTask::GraphTask(GraphExecutor* graph_executor)
{
graph_executor_ = graph_executor;
graph_ = graph_executor->GetGraph();
p_exec_attr_ = graph_executor->GetExecAttr();
dev_engine_ = nullptr;
optimized_graph_ = nullptr;
status_ = EXEC_STATUS_CREATED;
}
void GraphTask::AddSubgraphTask(SubgraphTask* sub_task)
{
sub_task_list_.push_back(sub_task);
}
void GraphTask::RemoveSubgraphTask(SubgraphTask* sub_task)
{
auto ir = sub_task_list_.begin();
auto end = sub_task_list_.end();
while(ir != end)
{
if(*ir == sub_task)
sub_task_list_.erase(ir);
}
}
bool GraphTask::SyncRunSubgraphTask(SubgraphTask* sub_task)
{
DevScheduler* scheduler = dev_engine_->GetScheduler();
active_sub_task_count_++;
bool ret = scheduler->SyncRunTask(dev_engine_, sub_task->dev_executor, sub_task);
if(!ret)
return false;
sub_task->OnSyncTaskDone();
return true;
}
bool GraphTask::RunSubgraphTask(SubgraphTask* sub_task)
{
if(status_ != EXEC_STATUS_READY && status_ != EXEC_STATUS_RUN)
return false;
DevScheduler* scheduler = dev_engine_->GetScheduler();
std::string msg;
msg = msg + "graph " + sub_task->sub_graph->GetName() +
" launched. active:" + std::to_string(( int )active_sub_task_count_) + "\n";
active_sub_task_count_++;
return scheduler->SchedTask(dev_engine_, sub_task->dev_executor, sub_task);
}
bool GraphTask::OptimizeGraph(void)
{
bool ret = false;
for(auto e : sub_task_list_)
{
DevExecutor* dev_executor = e->dev_executor;
ret = dev_executor->OptimizeGraph(e);
if(!ret)
break;
}
return ret;
}
Graph* GraphTask::MergeSubgraph(Graph* origin_graph, const std::vector<Subgraph*>& sub_list)
{
std::string graph_name = origin_graph->GetName() + ".optimized";
Graph* graph = new Graph(graph_name);
int subgraph_number = sub_list.size();
/* first: search the graph input nodes and graph output nodes
and collect all nodes and tensors */
graph->input_nodes = origin_graph->input_nodes;
for(int i = 0; i < subgraph_number; i++)
{
Subgraph* sub = sub_list[i];
graph->seq_nodes.insert(graph->seq_nodes.end(), sub->seq_nodes.begin(), sub->seq_nodes.end());
for(unsigned int k = 0; k < sub->output_nodes.size(); k++)
{
Node* node = sub->output_nodes[k];
unsigned int l;
for(l = 0; l < node->GetOutputNum(); l++)
{
Tensor* tensor = node->GetOutputTensor(l);
if(tensor->consumer.size() == 0)
break;
}
if(l < node->GetOutputNum())
graph->output_nodes.push_back(node);
}
}
/*second: setup the tensor map */
for(unsigned int i = 0; i < graph->seq_nodes.size(); i++)
{
Node* node = graph->seq_nodes[i];
node->SetNodeIndex(i);
for(unsigned int l = 0; l < node->GetOutputNum(); l++)
{
Tensor* tensor = node->GetOutputTensor(l);
graph->AddTensorMap(tensor->GetName(), tensor);
}
}
/*third: get the output nodes order*/
if(graph->output_nodes.size() > 1)
{
graph->output_nodes = origin_graph->output_nodes;
}
/* last reorder the nodes */
graph->SanitizeGraph();
return graph;
}
Graph* GraphTask::GetOptimizedGraph(void)
{
std::vector<Subgraph*> sub_list;
for(auto e : sub_task_list_)
{
if(!e->graph_optimized)
{
sub_list.push_back(e->sub_graph);
continue;
}
DevExecutor* dev_executor = e->dev_executor;
Subgraph* sub_graph = dev_executor->GetOptimizedGraph(e);
sub_list.push_back(sub_graph);
}
if(sub_list.empty())
{
return nullptr;
}
if(optimized_graph_)
delete optimized_graph_;
optimized_graph_ = MergeSubgraph(graph_, sub_list);
return optimized_graph_;
}
bool GraphTask::SetEventHook(int event, event_handler_t cb_func, void* cb_arg)
{
set_tengine_errno(ENOTSUP);
return false;
}
bool GraphTask::Prerun(void)
{
output_task_number_ = 0;
DevScheduler* scheduler = dev_engine_->GetScheduler();
for(auto e : sub_task_list_)
{
if(!scheduler->PrerunTask(dev_engine_, e->dev_executor, e))
{
XLOG_ERROR() << "failed to Prerun task on dev executor: " << e->dev_executor->GetName() << "\n";
return false;
}
e->attached = true;
if(e->is_output_task)
output_task_number_++;
}
status_ = EXEC_STATUS_INITED;
return true;
}
bool GraphTask::SyncRun(void)
{
if(status_ != EXEC_STATUS_INITED && status_ != EXEC_STATUS_READY)
{
XLOG_ERROR() << "bad status: " << dev_engine_->GetStatusStr(status_) << "\n";
return false;
}
status_ = EXEC_STATUS_RUN;
output_wait_count_ = output_task_number_ * 2; // never signal graph task done
active_sub_task_count_ = 0;
std::set<SubgraphTask*> working_set;
for(unsigned int i = 0; i < sub_task_list_.size(); i++)
working_set.insert(sub_task_list_[i]);
// first try: sequentially execution
for(unsigned int j = 0; j < sub_task_list_.size(); j++)
{
SubgraphTask* sub_task = sub_task_list_[j];
if(!sub_task->input_wait_count_)
{
bool ret = SyncRunSubgraphTask(sub_task);
if(ret)
working_set.erase(sub_task);
else
{
status_ = EXEC_STATUS_BAD;
return false;
}
}
}
// second round: repeatly try the tasks in working_set
while(!working_set.empty())
{
for(auto ir = working_set.begin(); ir != working_set.end();)
{
SubgraphTask* sub_task = *ir;
if(sub_task->input_wait_count_)
ir++;
else
{
if(SyncRunSubgraphTask(sub_task))
{
ir = working_set.erase(ir);
}
else
{
status_ = EXEC_STATUS_BAD;
return false;
}
}
}
}
status_ = EXEC_STATUS_READY;
return true;
}
bool GraphTask::Run(exec_event_t& event)
{
wait_event_.mutex.lock();
if(status_ != EXEC_STATUS_INITED && status_ != EXEC_STATUS_READY)
{
XLOG_ERROR() << "bad status: " << dev_engine_->GetStatusStr(status_) << "\n";
wait_event_.mutex.unlock();
return false;
}
/* inital status */
status_ = EXEC_STATUS_RUN;
wait_event_.mutex.unlock();
output_wait_count_ = output_task_number_;
active_sub_task_count_ = 0;
task_done_ = false;
wait_event_.wait_count = 0;
int task_launched = 0;
// let all input tasks run
for(auto e : sub_task_list_)
{
if(!e->saved_input_wait_count_)
{
if(RunSubgraphTask(e))
task_launched++;
else
{
XLOG_ERROR() << "failed to run task on dev executor: " << e->dev_executor->GetName() << "\n";
status_ = EXEC_STATUS_BAD;
break;
}
}
}
if(!task_launched)
{
XLOG_ERROR() << "No sub task launched!!\n";
status_ = EXEC_STATUS_BAD;
}
if(status_ == EXEC_STATUS_BAD)
return false;
event = &wait_event_;
return true;
}
bool GraphTask::SetCallback(exec_event_t& e, int event, exec_cb_t cb)
{
return false;
}
int GraphTask::Wait(exec_event_t& event, int try_wait)
{
WaitEvent* p_event = any_cast<WaitEvent*>(event);
if(p_event != &wait_event_)
{
XLOG_ERROR() << "bad event pointer passed\n";
return 0;
}
std::unique_lock<std::mutex> lock(p_event->mutex);
if(try_wait && !task_done_)
{
lock.unlock();
return 0;
}
p_event->wait_count++;
if(!task_done_)
p_event->cond.wait(lock, [this] { return task_done_; });
lock.unlock();
p_event->wait_count.fetch_sub(1);
return 1;
}
void GraphTask::SignalGraphTaskDone(void)
{
std::unique_lock<std::mutex> lock(wait_event_.mutex, std::defer_lock);
lock.lock();
task_done_ = true;
wait_event_.cond.notify_all();
lock.unlock();
}
void GraphTask::Postrun(void)
{
if(status_ == EXEC_STATUS_RUN)
return;
DevScheduler* scheduler = dev_engine_->GetScheduler();
for(auto e : sub_task_list_)
{
scheduler->PostrunTask(dev_engine_, e->dev_executor, e);
e->attached = false;
}
status_ = EXEC_STATUS_INVALID;
}
void GraphTask::OnOutputSubgraphTaskDone(SubgraphTask* sub_task)
{
int active_task = active_sub_task_count_.fetch_sub(1);
if(active_task == 1 && status_ == EXEC_STATUS_BAD)
{
SignalGraphTaskDone();
return;
}
if(output_wait_count_.fetch_sub(1) == 1)
{
status_ = EXEC_STATUS_READY;
SignalGraphTaskDone();
}
}
void GraphTask::OnSubgraphTaskError(SubgraphTask* sub_task)
{
status_ = EXEC_STATUS_BAD; // this will stop to generate new tasks
OnOutputSubgraphTaskDone(sub_task);
}
void GraphTask::ReclaimSubgraphTask(void)
{
DevScheduler* scheduler = dev_engine_->GetScheduler();
for(SubgraphTask* sub : sub_task_list_)
{
if(sub->GetStatus() == EXEC_STATUS_RUN)
{
XLOG_ERROR() << "cannot reclaim subgraph while it is running\n";
return;
}
if(sub->attached)
{
scheduler->PostrunTask(dev_engine_, sub->dev_executor, sub);
}
sub->Release();
delete sub;
}
sub_task_list_.clear();
}
GraphTask::~GraphTask(void)
{
if(optimized_graph_)
delete optimized_graph_;
}
bool GraphTask::SetGraphPerfAttr(const char* name, const void* val, int size)
{
for(unsigned int i = 0; i < sub_task_list_.size(); i++)
{
auto sub_task = sub_task_list_[i];
if(!sub_task->SetAttr(name, val, size))
return false;
}
return true;
}
bool GraphTask::GetGraphPerfAttr(const char* name, void* val, int size)
{
GraphPerfMsg* perf_msg = ( GraphPerfMsg* )val;
struct perf_info** info = perf_msg->buf;
int info_idx = 0;
bool loop_done = false;
bool fetch_error = false;
int entry_number = perf_msg->buf_size;
for(unsigned int i = 0; i < sub_task_list_.size(); i++)
{
auto sub_task = sub_task_list_[i];
int buf_num = 100;
GraphPerfMsg tmp_msg;
tmp_msg.action = perf_msg->action;
tmp_msg.buf = nullptr;
do
{
if(tmp_msg.buf)
{
free(tmp_msg.buf);
buf_num += 100;
}
tmp_msg.buf = ( struct perf_info** )malloc(buf_num * sizeof(void*));
tmp_msg.buf_size = buf_num;
tmp_msg.ret_number = -1;
if(!sub_task->GetAttr(name, &tmp_msg, sizeof(tmp_msg)))
{
tmp_msg.ret_number = -1;
fetch_error = true;
loop_done = true;
break;
}
} while(tmp_msg.ret_number == buf_num);
for(int i = 0; i < tmp_msg.ret_number; i++)
{
info[info_idx++] = tmp_msg.buf[i];
if(info_idx == entry_number)
{
loop_done = true;
break;
}
}
free(tmp_msg.buf);
if(loop_done)
break;
}
if(fetch_error)
return false;
else
{
perf_msg->ret_number = info_idx;
return true;
}
}
bool GraphTask::SetAttr(const char* name, const void* val, int size)
{
if(!strncmp(name, ATTR_GRAPH_PERF_STAT, strlen(ATTR_GRAPH_PERF_STAT)))
{
return SetGraphPerfAttr(name, val, size);
}
// loop all subtask
for(unsigned int i = 0; i < sub_task_list_.size(); i++)
{
auto sub_task = sub_task_list_[i];
if(sub_task->SetAttr(name, val, size))
return true;
}
return false;
}
bool GraphTask::GetAttr(const char* name, void* val, int size)
{
if(!strncmp(name, ATTR_GRAPH_PERF_STAT, strlen(ATTR_GRAPH_PERF_STAT)))
{
return GetGraphPerfAttr(name, val, size);
}
// loop all subtask
for(unsigned int i = 0; i < sub_task_list_.size(); i++)
{
auto sub_task = sub_task_list_[i];
if(sub_task->GetAttr(name, val, size))
return true;
}
return false;
}
/**************Subgraph Task ***************/
void SubgraphTask::SetSubgraphTask(Subgraph* sub_graph, SubgraphTask* task)
{
sub_graph->SetAttr("sub_task", task);
}
SubgraphTask* SubgraphTask::GetSubgraphTask(Subgraph* sub_graph)
{
if(!sub_graph->ExistAttr("sub_task"))
return nullptr;
SubgraphTask* sub_task = any_cast<SubgraphTask*>(sub_graph->GetAttr("sub_task"));
return sub_task;
}
SubgraphTask::SubgraphTask(Subgraph* sub)
{
sub_graph = sub;
graph_optimized = false;
graph_handle = nullptr;
is_output_task = false;
SetSubgraphTask(sub, this);
}
void SubgraphTask::Init(GraphTask* graph_tsk)
{
graph_task = graph_tsk;
Graph* graph = graph_task->GetGraph();
const ExecAttr* p_exec_attr = graph_task->GetExecAttr();
exec_priority = p_exec_attr->priority;
// check if it is a global output task
for(auto e : sub_graph->output_nodes)
{
for(auto m : graph->output_nodes)
{
if(e == m)
{
is_output_task = true;
break;
}
}
}
saved_input_wait_count_ = 0;
// for input nodes, calculate the input_wait_mask
for(Node* node : sub_graph->input_nodes)
{
std::uint64_t mask = 0;
for(unsigned int i = 0; i < node->GetInputNum(); i++)
{
NodePort* port = node->GetInputPort(i);
Tensor* tensor = port->tensor;
if(tensor->GetType() == kVarTensor)
{
/* check if parent is in the same graph or not */
Node* parent = tensor->producer->owner;
bool parent_in_graph = false;
for(unsigned int i = 0; i < sub_graph->seq_nodes.size(); i++)
{
if(parent == sub_graph->seq_nodes[i])
{
parent_in_graph = true;
break;
}
}
if(!parent_in_graph)
mask |= 1 << port->port_index;
}
}
if(mask)
{
SetNodeInputWaitMask(node, mask);
CreateNodeInputWaitCounter(node);
auto p_counter = GetNodeInputWaitCounter(node);
*p_counter = mask;
node->SetAttr("consumer_task", this);
saved_input_wait_count_++;
}
}
input_wait_count_ = saved_input_wait_count_;
SetStatus(EXEC_STATUS_INITED);
dev_executor = any_cast<DevExecutor*>(sub_graph->GetAttr("dev_executor"));
// pass down the exec attributes
sub_graph->SetAttr("exec_attr", p_exec_attr);
}
void SubgraphTask::OnSyncTaskDone(void)
{
input_wait_count_ = saved_input_wait_count_;
for(unsigned int i = 0; i < sub_graph->output_nodes.size(); i++)
{
Node* node = sub_graph->output_nodes[i];
OnOutputNodeDone(node, true);
}
}
#include <unistd.h>
void SubgraphTask::OnTaskDone(bool exec_success)
{
input_wait_count_ = saved_input_wait_count_;
if(!exec_success)
{
graph_task->OnSubgraphTaskError(this);
return;
}
// for all output nodes,
for(unsigned int i = 0; i < sub_graph->output_nodes.size(); i++)
{
Node* node = sub_graph->output_nodes[i];
OnOutputNodeDone(node, false);
}
if(is_output_task)
graph_task->OnOutputSubgraphTaskDone(this);
}
void SubgraphTask::OnOutputNodeDone(Node* node, bool sync_mode)
{
int out_tensor_num = node->GetOutputNum();
for(int i = 0; i < out_tensor_num; i++)
{
Tensor* out_tensor = node->GetOutputTensor(i);
for(unsigned int j = 0; j < out_tensor->consumer.size(); j++)
{
NodePort* port = out_tensor->consumer[j];
Node* consumer = port->owner;
if(!consumer->ExistAttr("consumer_task"))
{
/*
LOG_DEBUG()<<"consumer: "<<consumer->GetName()
<<" has no task attached. from node: "
<<node->GetName()<<"\n";
*/
continue;
}
SubgraphTask* consumer_task = any_cast<SubgraphTask*>(consumer->GetAttr("consumer_task"));
consumer_task->OnNodeInputTensorReady(consumer, port->port_index, sync_mode);
}
}
}
void SubgraphTask::OnNodeInputTensorReady(Node* node, int input_idx, bool sync_mode)
{
std::atomic<std::uint64_t>* p_counter;
std::uint64_t mask = 1 << input_idx;
p_counter = GetNodeInputWaitCounter(node);
std::uint64_t prev_val = p_counter->fetch_sub(mask);
// if it is the last waited tensor?
if((prev_val - mask) == 0)
{
OnInputNodeReady(node, sync_mode);
// prepare for next run
(*p_counter) = GetNodeInputWaitMask(node);
}
}
void SubgraphTask::OnInputNodeReady(Node* node, bool sync_mode)
{
if(input_wait_count_.fetch_sub(1) == 1 && !sync_mode)
{
// all input nodes are ready
graph_task->RunSubgraphTask(this);
}
}
void SubgraphTask::SetNodeInputWaitMask(Node* node, std::uint64_t wait_mask)
{
node->SetAttr("input_wait", wait_mask);
}
std::uint64_t SubgraphTask::GetNodeInputWaitMask(Node* node)
{
if(!node->ExistAttr("input_wait"))
return 0;
return any_cast<std::uint64_t>(node->GetAttr("input_wait"));
}
std::atomic<std::uint64_t>* SubgraphTask::GetNodeInputWaitCounter(Node* node)
{
return any_cast<std::atomic<std::uint64_t>*>(node->GetAttr("input_wait_counter"));
}
void SubgraphTask::CreateNodeInputWaitCounter(Node* node)
{
std::atomic<std::uint64_t>* p_counter = new std::atomic<std::uint64_t>();
node->SetAttr("input_wait_counter", p_counter);
}
void SubgraphTask::ReleaseNodeInputWaitCounter(Node* node)
{
if(!node->ExistAttr("input_wait_counter"))
return;
std::atomic<std::uint64_t>* p_counter = any_cast<std::atomic<std::uint64_t>*>(node->GetAttr("input_wait_counter"));
delete p_counter;
}
void SubgraphTask::Release(void)
{
for(unsigned int i = 0; i < sub_graph->input_nodes.size(); i++)
{
Node* node = sub_graph->input_nodes[i];
ReleaseNodeInputWaitCounter(node);
}
}
bool SubgraphTask::SetAttr(const char* name, const void* val, int size)
{
if(graph_handle == nullptr)
return false;
return dev_executor->SetGraphAttr(this, name, val, size);
}
bool SubgraphTask::GetAttr(const char* name, void* val, int size)
{
if(graph_handle == nullptr)
return false;
return dev_executor->GetGraphAttr(this, name, val, size);
}
} // namespace TEngine
| 24.048235 | 119 | 0.597133 | [
"vector"
] |
1b31eb7f8b9b08a83ae4f45aeb6992eca7b5603b | 4,507 | cpp | C++ | model_zoo/jag_utils/check_images.cpp | jychoi-hpc/lbann | 4232883aee90448e8beb89967ce30fee9c4a68bf | [
"Apache-2.0"
] | null | null | null | model_zoo/jag_utils/check_images.cpp | jychoi-hpc/lbann | 4232883aee90448e8beb89967ce30fee9c4a68bf | [
"Apache-2.0"
] | 66 | 2018-04-04T22:24:42.000Z | 2020-10-23T01:50:34.000Z | model_zoo/jag_utils/check_images.cpp | jychoi-hpc/lbann | 4232883aee90448e8beb89967ce30fee9c4a68bf | [
"Apache-2.0"
] | null | null | null | ////////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2014-2019, Lawrence Livermore National Security, LLC.
// Produced at the Lawrence Livermore National Laboratory.
// Written by the LBANN Research Team (B. Van Essen, et al.) listed in
// the CONTRIBUTORS file. <lbann-dev@llnl.gov>
//
// LLNL-CODE-697807.
// All rights reserved.
//
// This file is part of LBANN: Livermore Big Artificial Neural Network
// Toolkit. For details, see http://software.llnl.gov/LBANN or
// https://github.com/LLNL/LBANN.
//
// Licensed under the Apache License, Version 2.0 (the "Licensee"); 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 "lbann_config.hpp"
#include "conduit/conduit.hpp"
#include "conduit/conduit_relay.hpp"
#include "conduit/conduit_relay_io_hdf5.hpp"
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <sstream>
#include "lbann/lbann.hpp"
#include <time.h>
using namespace lbann;
#define NUM_OUTPUT_DIRS 100
#define NUM_SAMPLES_PER_FILE 1000
//==========================================================================
int main(int argc, char *argv[]) {
int random_seed = lbann_default_random_seed;
world_comm_ptr comm = initialize(argc, argv, random_seed);
bool master = comm->am_world_master();
const int rank = comm->get_rank_in_world();
const int np = comm->get_procs_in_world();
try {
options *opts = options::get();
opts->init(argc, argv);
if (!opts->has_string("filelist")) {
if (master) {
throw lbann_exception(std::string{} + __FILE__ + " " + std::to_string(__LINE__) + " :: usage: " + argv[0] + " --filelist");
}
}
std::vector<std::string> files;
std::ifstream in(opts->get_string("filelist").c_str());
if (!in) {
throw lbann_exception(std::string{} + __FILE__ + " " + std::to_string(__LINE__) + " :: failed to open " + opts->get_string("filelist") + " for reading");
}
std::string line;
while (getline(in, line)) {
if (line.size()) {
files.push_back(line);
}
}
in.close();
hid_t hdf5_file_hnd;
std::string key;
conduit::Node n_ok;
size_t h = 0;
for (size_t j=rank; j<files.size(); j+= np) {
h += 1;
if (h % 10 == 0) std::cout << rank << " :: processed " << h << " files\n";
try {
hdf5_file_hnd = conduit::relay::io::hdf5_open_file_for_read( files[j] );
} catch (...) {
std::cerr << rank << " :: exception hdf5_open_file_for_read: " << files[j] << "\n";
continue;
}
std::vector<std::string> cnames;
try {
conduit::relay::io::hdf5_group_list_child_names(hdf5_file_hnd, "/", cnames);
} catch (const std::exception&) {
std::cerr << rank << " :: exception hdf5_group_list_child_names: " << files[j] << "\n";
continue;
}
for (size_t i=0; i<cnames.size(); i++) {
// is the next sample valid?
key = "/" + cnames[i] + "/performance/success";
try {
conduit::relay::io::hdf5_read(hdf5_file_hnd, key, n_ok);
} catch (const exception& e) {
throw lbann_exception(std::string{} + __FILE__ + " " + std::to_string(__LINE__) + " :: caught exception reading success flag for child " + std::to_string(i) + " of " + std::to_string(cnames.size()) + "; " + e.what());
}
int success = n_ok.to_int64();
if (success == 1) {
key = "/" + cnames[i] + "/outputs/images";
std::vector<std::string> image_names;
try {
conduit::relay::io::hdf5_group_list_child_names(hdf5_file_hnd, key, image_names);
} catch (const std::exception&) {
std::cerr << rank << " :: exception :hdf5_group_list_child_names for images: " << files[j] << "\n";
continue;
}
}
}
}
} catch (const std::exception& e) {
El::ReportException(e);
return EXIT_FAILURE;
}
// Clean up
return EXIT_SUCCESS;
}
| 34.40458 | 227 | 0.587309 | [
"vector"
] |
1b332a6a068fffda5ad19b8cdd08499b0619d3e7 | 108,870 | cc | C++ | tce/src/applibs/Scheduler/ProgramRepresentations/DDG/DataDependenceGraphBuilder.cc | kanishkan/tce | 430e764b4d43f46bd1dc754aeb1d5632fc742110 | [
"MIT"
] | null | null | null | tce/src/applibs/Scheduler/ProgramRepresentations/DDG/DataDependenceGraphBuilder.cc | kanishkan/tce | 430e764b4d43f46bd1dc754aeb1d5632fc742110 | [
"MIT"
] | null | null | null | tce/src/applibs/Scheduler/ProgramRepresentations/DDG/DataDependenceGraphBuilder.cc | kanishkan/tce | 430e764b4d43f46bd1dc754aeb1d5632fc742110 | [
"MIT"
] | null | null | null | /*
Copyright (c) 2002-2021 Tampere University.
This file is part of TTA-Based Codesign Environment (TCE).
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.
*/
/**
* @file DataDependenceGraphBuilder.cc
*
* Implementation of data dependence graph builder.
*
* DDG's can be built only from unscheduled code. Registers can
* however have been allocated.
*
* @author Heikki Kultala 2006-2009 (heikki.kultala-no.spam-tut.fi)
* @author Pekka Jääskeläinen 2021 (pekka.jaaskelainen tuni fi)
* @note rating: red
*/
#include "CompilerWarnings.hh"
IGNORE_COMPILER_WARNING("-Wunused-parameter")
#include <llvm/CodeGen/MachineInstr.h>
#include <llvm/CodeGen/MachineMemOperand.h>
#include "AssocTools.hh"
#include "ContainerTools.hh"
#include "TCEString.hh"
#include "SequenceTools.hh"
#include "Program.hh"
#include "Procedure.hh"
#include "Instruction.hh"
#include "Operation.hh"
#include "SpecialRegisterPort.hh"
#include "Move.hh"
#include "ProgramOperation.hh"
#include "RegisterFile.hh"
#include "Machine.hh"
#include "UniversalMachine.hh"
#include "Exception.hh"
#include "UnboundedRegisterFile.hh"
#include "MoveGuard.hh"
#include "Guard.hh"
#include "MoveNodeSet.hh"
#include "Operand.hh"
#include "POMDisassembler.hh"
#include "DisassemblyRegister.hh"
#include "Move.hh"
#include "ControlFlowGraph.hh"
#include "ControlFlowEdge.hh"
#include "BasicBlockNode.hh"
#include "BasicBlock.hh"
#include "DataDependenceGraphBuilder.hh"
#include "DataDependenceEdge.hh"
#include "MemoryAliasAnalyzer.hh"
#include "PRegionAliasAnalyzer.hh"
#include "TerminalRegister.hh"
#include "TerminalFUPort.hh"
#include "ConstantAliasAnalyzer.hh"
#include "FalseAliasAnalyzer.hh"
#include "StackAliasAnalyzer.hh"
#include "OffsetAliasAnalyzer.hh"
#include "GlobalVsStackAA.hh"
#include "LLVMAliasAnalyzer.hh"
#include "LLVMTCECmdLineOptions.hh"
#include "InterPassData.hh"
#include "InterPassDatum.hh"
#include "SchedulerCmdLineOptions.hh"
#include "MachineInfo.hh"
using namespace TTAProgram;
using namespace TTAMachine;
using std::list;
static const int REG_RV_HIGH = -1;
static const int REG_SP = 1;
static const int REG_RV = 0;
static const int REG_IPARAM = 2;
static const int REG_VRV = -3;
static const int REG_FP = -2;
POP_COMPILER_DIAGS
//#define USE_FALSE_AA
/**
* Constructor of Data Dependence graph builder.
*
* This constructor does not take special registers from
* interpass data, so it must analyze them from the
* code annotations. Used with old frontend.
*/
DataDependenceGraphBuilder::DataDependenceGraphBuilder() :
interPassData_(NULL), cfg_(NULL), rvIsParamReg_(false) {
/// constant alias AA check aa between global variables.
addAliasAnalyzer(new ConstantAliasAnalyzer);
#ifdef USE_FALSE_AA
/// defining USE_FALSE_AA results in faster but
/// broken code. just for testing theoretical benefits.
addAliasAnalyzer(new FalseAliasAnalyzer);
#endif
addAliasAnalyzer(new PRegionAliasAnalyzer);
LLVMTCECmdLineOptions* llvmOptions =
dynamic_cast<LLVMTCECmdLineOptions*>(
Application::cmdLineOptions());
if (llvmOptions != NULL && llvmOptions->disableLLVMAA() == false) {
addAliasAnalyzer(new LLVMAliasAnalyzer);
}
}
/**
* Constructor of Data Dependence graph builder.
*
* This constructor takes special registers from
* interpass data.
*/
DataDependenceGraphBuilder::DataDependenceGraphBuilder(InterPassData& ipd) :
// TODO: when param reg thing works, rvIsParamReg becomes true here
interPassData_(&ipd), cfg_(NULL), rvIsParamReg_(true) {
// Need to store data about special registers which have semantics
// between function calls and exits. These are stack pointer,
// return value register and the secondary "hi bits"
// return value register.
static const TCEString SP_DATUM = "STACK_POINTER";
static const TCEString FP_DATUM = "FRAME_POINTER";
static const TCEString RV_DATUM = "RV_REGISTER";
// high part of 64-bit return values.
static const TCEString RV_HIGH_DATUM = "RV_HIGH_REGISTER";
static const TCEString IPARAM_DATUM_PREFIX = "IPARAM";
static const TCEString VECTOR_RV_PREFIX="VRV_REGISTER";
SchedulerCmdLineOptions* options =
dynamic_cast<SchedulerCmdLineOptions*>(
Application::cmdLineOptions());
if (ipd.hasDatum(SP_DATUM)) {
RegDatum& sp = dynamic_cast<RegDatum&>(ipd.datum(SP_DATUM));
TCEString spName = sp.first + '.' + Conversion::toString(sp.second);
specialRegisters_[REG_SP] = spName;
// create stack alias analyzer if enabled.
if ((options != NULL && options->enableStackAA())) {
addAliasAnalyzer(new StackAliasAnalyzer(spName));
}
if (options != NULL && options->enableOffsetAA()) {
addAliasAnalyzer(new OffsetAliasAnalyzer(spName));
}
addAliasAnalyzer(new GlobalVsStackAA(spName));
} else {
if (Application::verboseLevel() >
Application::VERBOSE_LEVEL_DEFAULT) {
Application::logStream()
<< "Warning: Stack pointer datum not found "
<< "in interpassdata given to ddg builder. "
<< "May generate invalid code if stack used."
<< std::endl;
}
}
if (ipd.hasDatum(RV_DATUM)) {
RegDatum& rv = dynamic_cast<RegDatum&>(ipd.datum(RV_DATUM));
TCEString reg = rv.first + '.' + Conversion::toString(rv.second);
specialRegisters_[REG_RV] = reg;
if (rvIsParamReg_) {
allParamRegs_.insert(reg);
}
} else {
if (Application::verboseLevel() >
Application::VERBOSE_LEVEL_DEFAULT) {
Application::logStream()
<< "Warning: Return value register datum not found "
<< "in interpassdata given to ddg builder. "
<< "May generate invalid code if return values used."
<< std::endl;
}
}
for(int i = 2;;i++) {
TCEString datum = IPARAM_DATUM_PREFIX; datum << i;
if (ipd.hasDatum(datum)) {
RegDatum& p = dynamic_cast<RegDatum&>(ipd.datum(datum));
TCEString reg = p.first + '.' + Conversion::toString(p.second);
specialRegisters_[REG_IPARAM+i-1] = reg;
} else {
break;
}
}
for (int i = 0;;i++) {
TCEString datum = VECTOR_RV_PREFIX; datum << i;
if (ipd.hasDatum(datum)) {
RegDatum& p = dynamic_cast<RegDatum&>(ipd.datum(datum));
TCEString reg = p.first + '.' + Conversion::toString(p.second);
specialRegisters_[REG_VRV-i] = reg;
} else {
break;
}
}
if (ipd.hasDatum(FP_DATUM)) {
RegDatum& fp = dynamic_cast<RegDatum&>(ipd.datum(FP_DATUM));
TCEString reg = fp.first + '.' + Conversion::toString(fp.second);
specialRegisters_[REG_FP] = reg;
} else {
if (Application::verboseLevel() >
Application::VERBOSE_LEVEL_DEFAULT) {
Application::logStream()
<< "Warning: Frame Pointer Register datum not found "
<< "in interpassdata given to ddg builder. "
<< "May generate invalid code."
<< std::endl;
}
}
if (ipd.hasDatum(RV_HIGH_DATUM)) {
RegDatum& rvh = dynamic_cast<RegDatum&>(ipd.datum(RV_HIGH_DATUM));
specialRegisters_[REG_RV_HIGH] =
rvh.first + '.' + Conversion::toString(rvh.second);
}
// constant alias AA check aa between global variables.
addAliasAnalyzer(new ConstantAliasAnalyzer);
LLVMTCECmdLineOptions* llvmOptions =
dynamic_cast<LLVMTCECmdLineOptions*>(
Application::cmdLineOptions());
if (llvmOptions != NULL && llvmOptions->disableLLVMAA() == false) {
addAliasAnalyzer(new LLVMAliasAnalyzer);
}
addAliasAnalyzer(new PRegionAliasAnalyzer);
#ifdef USE_FALSE_AA
/// defining USE_FALSE_AA results in faster but
/// broken code. just for testing theoretical benefits.
addAliasAnalyzer(new FalseAliasAnalyzer);
#else
if ((options != NULL && options->noaliasFunctions() &&
!options->noaliasFunctions()->empty())) {
addAliasAnalyzer(new FalseAliasAnalyzer(options->noaliasFunctions()));
}
#endif
}
/**
* Destructor of DataDependenceGraphBuilder
*/
DataDependenceGraphBuilder::~DataDependenceGraphBuilder() {
SequenceTools::deleteAllItems(aliasAnalyzers_);
}
/**
* Adds a memory alias analyzer to the DDG builder.
*
* @param analyzer object which will analyze memory accesses.
*/
void
DataDependenceGraphBuilder::addAliasAnalyzer(MemoryAliasAnalyzer* analyzer) {
aliasAnalyzers_.push_back(analyzer);
}
/**
* Tries to find annotations which tell the static registers
* from a program.
*
* Used only with the old gcc frontend.
*
* @param cs codesnippet where to search the annotations.
*/
void
DataDependenceGraphBuilder::findStaticRegisters(
TTAProgram::CodeSnippet& cs,
std::map<int,TCEString>& registers) {
for (int i = 0; i < cs.instructionCount(); i++) {
Instruction& ins = cs.instructionAtIndex(i);
findStaticRegisters(ins, registers);
}
}
/**
* Tries to find annotations which tell the static registers
* from a program.
*
* Used only with the old gcc frontend.
*
* @param cfg cfg where to search the annotations.
*/
void
DataDependenceGraphBuilder::findStaticRegisters(
ControlFlowGraph& cfg,
std::map<int,TCEString>& registers) {
for (int i = 0; i < cfg.nodeCount(); i++) {
BasicBlockNode& bbn = cfg.node(i);
if (bbn.isNormalBB()) {
findStaticRegisters(bbn.basicBlock(), registers);
}
}
}
/**
* Tries to find annotations which tell the static registers
* from a program.
*
* Used only with the old gcc frontend.
*
* @param ins instruction where to search the annotations.
*/
void
DataDependenceGraphBuilder::findStaticRegisters(
TTAProgram::Instruction& ins,
std::map<int,TCEString>& registers) {
try {
for (int i = 0; i < ins.moveCount(); i++) {
Move& move = ins.move(i);
for (int j = 0; j < move.annotationCount(); j++) {
ProgramAnnotation anno = move.annotation(j);
switch (anno.id()) {
case ProgramAnnotation::ANN_REGISTER_RV_READ: {
registers[REG_RV] = DisassemblyRegister::registerName(
move.source());
break;
}
case ProgramAnnotation::ANN_REGISTER_RV_SAVE: {
registers[REG_RV] = DisassemblyRegister::registerName(
move.destination());
break;
}
case ProgramAnnotation::ANN_REGISTER_SP_READ: {
registers[REG_SP] = DisassemblyRegister::registerName(
move.source());
break;
}
case ProgramAnnotation::ANN_REGISTER_SP_SAVE: {
registers[REG_SP] = DisassemblyRegister::registerName(
move.destination());
break;
}
case ProgramAnnotation::ANN_REGISTER_IPARAM_READ: {
/* this fixes one unit test silent breakage but another will then happen - unit test
tpef's seem to contain a bit broken code
Terminal& src = move.source();
if (!src.isGPR()) {
break;
}
*/
TCEString reg =
DisassemblyRegister::registerName(move.source());
registers[
REG_IPARAM+Conversion::toInt(anno.stringValue())] =
reg;
allParamRegs_.insert(reg);
break;
}
case ProgramAnnotation::ANN_REGISTER_IPARAM_SAVE: {
TCEString reg =
DisassemblyRegister::registerName(move.destination());
registers[
REG_IPARAM+Conversion::toInt(anno.stringValue())] =
reg;
allParamRegs_.insert(reg);
break;
}
default:
//TODO: frame pointer, not yet implemented
break;
}
}
}
} catch (std::bad_cast& e) {
throw IllegalProgram(__FILE__,__LINE__, __func__, "Illegal annotation");
}
}
/**
* Initializes the static register table from register from
* UniversalMachine.
*
* Needed for analysis of data dependencies of parameter registers,
* SP, RV etc.
*
* @param um UniversalMachine
* @param registers map where to store those registers.
*/
void
DataDependenceGraphBuilder::findStaticRegisters(
const UniversalMachine& um, std::map<int,TCEString>& registers) {
RegisterFile& rf = um.integerRegisterFile();
for (int i = 0; i < 6; i++) {
TerminalRegister tr(*rf.port(0), i);
TCEString reg = DisassemblyRegister::registerName(tr);
registers[i] = reg;
if (i > REG_SP) {
allParamRegs_.insert(reg);
}
}
}
///////////////////////////////////////////////////////////////////////////////
// End of initializations
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Single-BB DDG construction
///////////////////////////////////////////////////////////////////////////////
/**
* Creates new Data Dependence Graph for the given basic block.
*
* Client has to delete the graph when it is not anymore used.
*
* @param bb BasicBlockNode whose data dependence graph to build.
* @param registerAntidependenceLevel which reg antidependencies to create
* @param createMemAndFUDeps whether to create also memory and
* fu state(side effect) dependencies or only register deps.
* @return new DataDependence Graph.
*
*/
DataDependenceGraph*
DataDependenceGraphBuilder::build(
BasicBlock& bb,
DataDependenceGraph::AntidependenceLevel registerAntidependenceLevel,
const TTAMachine::Machine& mach,
const TCEString& ddgName,
const UniversalMachine* um,
bool createMemAndFUDeps,
llvm::AliasAnalysis* AA) {
mach_ = &mach;
if (AA) {
for (unsigned int i = 0; i < aliasAnalyzers_.size(); i++) {
LLVMAliasAnalyzer* llvmaa =
dynamic_cast<LLVMAliasAnalyzer*>(aliasAnalyzers_[i]);
if (llvmaa != NULL) {
llvmaa->setLLVMAA(AA);
}
}
}
if (bb.liveRangeData_ == NULL) {
bb.liveRangeData_ = new LiveRangeData;
}
currentBB_ = new BasicBlockNode(bb);
currentDDG_ = new DataDependenceGraph(
allParamRegs_, ddgName, registerAntidependenceLevel, currentBB_,
false,true);
// GRR, start and end addresses are lost..
currentData_ = new BBData(*currentBB_);
if (um != NULL) {
findStaticRegisters(*um, specialRegisters_);
} else {
findStaticRegisters(bb,specialRegisters_);
}
try {
// first phase. registers , ops and PO's.
constructIndividualBB(
REGISTERS_AND_PROGRAM_OPERATIONS);
if (createMemAndFUDeps) {
//second phase. mem and fu state deps
constructIndividualBB(
MEMORY_AND_SIDE_EFFECTS);
}
} catch (Exception&) {
delete currentDDG_; currentDDG_ = NULL;
delete currentData_; currentData_ = NULL;
delete currentBB_; currentBB_ = NULL;
throw;
}
clearUnneededBookkeeping(bb, false);
delete currentData_;
currentData_ = NULL;
currentDDG_->setMachine(mach);
return currentDDG_;
}
/**
* Constructs a Data Dependence Graph for a single basic block.
*
* Goes thru all moves in the basic block and analyzes their dependencies,
* creates their ProgramOperations, MoveNodes and Edges,
* and adds the nodes and edges to the graph.
* Also used inside implementation of multi-BB-DDG-code.
* BB being analyzed has to be already set in member variable currentBB_,
* and the graph created and set into member variable currentBB_.
*
* @param bbd basic block to constructs.
* @param phase whether to handle register& operation deps or
* memory and side-effect dependencies.
*/
void
DataDependenceGraphBuilder::constructIndividualBB(
BBData& bbd, ConstructionPhase phase) {
currentData_ = &bbd;
currentBB_ = bbd.bblock_;
// Parallel inline asm block are already marked as scheduled
// TODO: should BBN have isInlineAsm() method?
if (currentBB_->isScheduled()) {
constructIndividualFromInlineAsmBB(phase);
} else {
constructIndividualBB(phase);
}
}
/**
* Constructs a Data Dependence Graph for a single basic block.
*
* Goes thru all moves in the basic block and analyzes their dependencies,
* creates their ProgramOperations, MoveNodes and Edges,
* and adds the nodes and edges to the graph.
* Also used inside implementation of multi-BB-DDG-code.
* BB being analyzed has to be already set in member variable currentBB_,
* and the graph created and set into member variable currentBB_.
*
* @param phase whether to handle register& operation deps or
* memory and side-effect dependencies.
*/
void
DataDependenceGraphBuilder::constructIndividualBB(
ConstructionPhase phase) {
for (int ia = 0; ia < currentBB_->basicBlock().instructionCount(); ia++) {
Instruction& ins = currentBB_->basicBlock().instructionAtIndex(ia);
for (int i = 0; i < ins.moveCount(); i++) {
auto movePtr = ins.movePtr(i);
Move& move = *movePtr;
MoveNode* moveNode = NULL;
// if phase is 0, create the movenode, and handle guard.
if (phase == REGISTERS_AND_PROGRAM_OPERATIONS) {
/* In case using the LLVMTCEIRBuilder, the POs have been built already
and set to corresponding TerminalFUPorts. Use those MoveNodes and
ProgramOperations instead of creating new ones here. NOTE: the
ownership of the MoveNodes is transferred to the DDG.
*/
if (move.destination().isFUPort() &&
dynamic_cast<TerminalFUPort&>(move.destination()).
hasProgramOperation()) {
ProgramOperationPtr po =
dynamic_cast<TerminalFUPort&>(move.destination()).
programOperation();
if (po->hasMoveNodeForMove(move)) {
moveNode = &po->moveNode(move);
} else {
// the po might be corrupted and point to an old POM's Moves
moveNode = new MoveNode(movePtr);
}
} else if (move.source().isFUPort() &&
dynamic_cast<TerminalFUPort&>(move.source()).
hasProgramOperation()) {
ProgramOperationPtr po =
dynamic_cast<TerminalFUPort&>(move.source()).
programOperation();
if (po->hasMoveNodeForMove(move)) {
moveNode = &po->moveNode(move);
} else {
// the po might be corrupted and point to an old POM's Moves
moveNode = new MoveNode(movePtr);
}
} else {
moveNode = new MoveNode(movePtr);
}
currentDDG_->addNode(*moveNode, *currentBB_);
if (!move.isUnconditional()) {
processGuard(*moveNode);
}
processSource(*moveNode);
} else {
// on phase 2, just find the already created movenode.
moveNode = ¤tDDG_->nodeOfMove(move);
}
// destinaition need to be processed in both phases 0 and 1.
processDestination(*moveNode, phase);
}
}
// these are needed no more.
currentBB_->basicBlock().liveRangeData_->potentialRegKills_.clear();
// Checks if we have some unready program operations at the end
// of a basic block.
if (currentData_->destPending_ != NULL ||
currentData_->readPending_ != NULL) {
TCEString msg = TCEString("Basic block ")
+ Conversion::toString(currentBB_->originalStartAddress())
+ TCEString(" - ")
+ Conversion::toString(currentBB_->originalEndAddress())
+ TCEString(", size : ")
+ Conversion::toString(
currentBB_->basicBlock().instructionCount())
+ TCEString(" handled but we have unready PO at: ")
+ currentDDG_->name()
+ TCEString(", probably an operation without result move?");
if (currentData_->readPending_ != NULL) {
msg += "\n\tmissing read: " +
TCEString(currentData_->readPending_->operation().name());
}
if (currentData_->destPending_ != NULL) {
msg += "\n\tmissing dest: " +
TCEString(currentData_->destPending_->operation().name());
}
if (cfg_ != NULL) {
cfg_->writeToDotFile("constructBBbroken_cfg.dot");
}
throw IllegalProgram(__FILE__,__LINE__,__func__, msg);
}
}
/**
* Same as constructIndividualBB() but for already fully scheduled and inline
* asm BB.
*
* @Note: currently, this does not really construct DDG - just creates
* dummy MoveNodes.
*/
void
DataDependenceGraphBuilder::constructIndividualFromInlineAsmBB(
ConstructionPhase phase) {
if (phase != REGISTERS_AND_PROGRAM_OPERATIONS) {
return;
}
auto& bb = currentBB_->basicBlock();
assert(currentBB_->isScheduled());
for (int ia = 0; ia < bb.instructionCount(); ia++) {
Instruction& ins = bb.instructionAtIndex(ia);
for (int i = 0; i < ins.moveCount(); i++) {
MoveNode* moveNode = new MoveNode(ins.movePtr(i));
currentDDG_->addNode(*moveNode, *currentBB_);
}
}
// Process live range with dummy move nodes.
assert(bb.liveRangeData_);
LiveRangeData& liveRangeData = *bb.liveRangeData_;
std::set<TCEString> actualRegUses;
std::set<TCEString> actualRegDefs;
for (int i = 0; i < bb.instructionCount(); i++) {
auto& ins = bb.instructionAtIndex(i);
for (int m = 0; m < ins.moveCount(); m++) {
auto& move = ins.move(m);
auto rdReg = move.source().isGPR() ? move.source().toString()
: TCEString("");
if (!rdReg.empty()) actualRegUses.insert(rdReg);
if (move.isConditional()) {
const Guard& grd = move.guard().guard();
const RegisterGuard* grdReg =
dynamic_cast<const RegisterGuard*>(&grd);
if (grdReg) {
TCEString regName = grdReg->registerFile()->name() + '.' +
Conversion::toString(grdReg->registerIndex());
actualRegUses.insert(regName);
}
}
auto wrReg = move.destination().isGPR()
? move.destination().toString()
: TCEString("");
if (!wrReg.empty()) actualRegDefs.insert(wrReg);
}
}
auto& iaRegUses = liveRangeData.inlineAsmRegUses_;
auto effectiveRegUses = SetTools::intersection(iaRegUses, actualRegUses);
for (auto reg : effectiveRegUses) {
MoveNode* moveNode = new MoveNode();
currentDDG_->addNode(*moveNode, *currentBB_);
liveRangeData.regFirstUses_[reg].insert(*moveNode);
currentDDG_->updateRegUse(*moveNode, reg, bb);
}
auto& iaRegDefs = liveRangeData.inlineAsmRegDefs_;
auto effectiveRegDefs = SetTools::intersection(iaRegDefs, actualRegDefs);
for (auto reg : effectiveRegDefs) {
MoveNode* moveNode = new MoveNode();
currentDDG_->addNode(*moveNode, *currentBB_);
liveRangeData.regDefines_[reg].insert(*moveNode);
MoveNodeUse mnd(*moveNode);
liveRangeData.regKills_[reg] = std::make_pair(mnd, mnd);
}
for (auto& reg : liveRangeData.inlineAsmClobbers_) {
MoveNode* moveNode = new MoveNode();
currentDDG_->addNode(*moveNode, *currentBB_);
liveRangeData.regDefines_[reg].insert(*moveNode);
MoveNodeUse mnd(*moveNode);
liveRangeData.regKills_[reg] = std::make_pair(mnd, mnd);
}
// Not needed anymore.
liveRangeData.inlineAsmRegUses_.clear();
liveRangeData.inlineAsmRegDefs_.clear();
liveRangeData.inlineAsmClobbers_.clear();
}
/**
* Analyzes dependencies related to guard usage.
*
* Finds the guard register used for the guard and the move
* Which writes the guard register, and creates a guard egde
* between them.
*
* @param moveNode MNData of move containing guarded move.
*/
void
DataDependenceGraphBuilder::processGuard(MoveNode& moveNode) {
// new code
const Guard& g = moveNode.move().guard().guard();
const RegisterGuard* rg = dynamic_cast<const RegisterGuard*>(&g);
if (rg != NULL) {
TCEString regName = rg->registerFile()->name() + '.' +
Conversion::toString(rg->registerIndex());
processRegUse(MoveNodeUse(moveNode, true),regName);
} else {
throw IllegalProgram(
__FILE__,__LINE__,__func__,
"Analysis for port guards not supported! used in: "
+ moveNode.toString());
}
}
/**
* Analysis a source of a move and processes it's dependencies,
* and if it's a result read then also participates in ProgramOperation
* creation.
*
* @param moveNode Movenode being analyzed.
*/
void
DataDependenceGraphBuilder::processSource(MoveNode& moveNode) {
Terminal& source = moveNode.move().source();
// is this result move of an operation?
if (source.isFUPort()) {
if (!(dynamic_cast<const SpecialRegisterPort*>(&source.port()))) {
processResultRead(moveNode);
} else {
// handle read from RA.
processRegUse(MoveNodeUse(moveNode, false, true), RA_NAME);
if (moveNode.move().isReturn()) {
processReturn(moveNode);
}
}
} else {
if (source.isGPR()) {
TerminalRegister& tr = dynamic_cast<TerminalRegister&>(source);
TCEString regName = DisassemblyRegister::registerName(tr);
processRegUse(MoveNodeUse(moveNode), regName);
}
}
}
bool DataDependenceGraphBuilder::isTriggering(const MoveNode& mn) {
int destIndex = mn.move().destination().operationIndex();
const Operation& op = mn.destinationOperation().operation();
int triggerIndex = MachineInfo::triggerIndex(*mach_, op);
switch (triggerIndex) {
case -1: {
TCEString msg = "Trigger index ambiguous for operation: ";
msg << op.name() << " in the machine.";
throw IllegalMachine(__FILE__,__LINE__,__func__, msg);
break;
}
case 0: {
TCEString msg = "Operation: ";
msg << op.name() << " Not found from the machine";
throw CompileError(__FILE__,__LINE__,__func__, msg);
break;
}
default:
return triggerIndex == destIndex;
}
}
/**
* Analyzes destination of a move.
* Updates bookkeeping and handles WaW and WaR dependencies of the move.
*
* Checks whether destination is operation or register and calls other
* functions to do the actual dependence checks etc.
*
* @param moveNode MoveNode whose destination is being processed.
* @param phase whether to handle register& operation deps or
* memory and side-effect dependencies.
*/
void
DataDependenceGraphBuilder::processDestination(
MoveNode& moveNode, ConstructionPhase phase) {
Terminal& dest = moveNode.move().destination();
// is this a operand to an operation?
if (dest.isFUPort()) {
if (!(dynamic_cast<const SpecialRegisterPort*>(&dest.port()))) {
TerminalFUPort& tfpd = dynamic_cast<TerminalFUPort&>(dest);
Operation &dop = tfpd.hintOperation();
if (phase == REGISTERS_AND_PROGRAM_OPERATIONS) {
if (tfpd.isOpcodeSetting()) {
processTriggerRegistersAndOperations(
moveNode, dop);
} else {
processOperand(moveNode, dop);
}
} else { // memory and fu state deps
if (dop.usesMemory() || dop.hasSideEffects() ||
dop.affectsCount() || dop.affectedByCount() ||
moveNode.move().isControlFlowMove()) {
if (isTriggering(moveNode)) {
processTriggerMemoryAndFUStates(moveNode, dop);
}
}
}
} else { // RA write
if (phase == REGISTERS_AND_PROGRAM_OPERATIONS) {
processRegWrite(MoveNodeUse(moveNode,false,true), RA_NAME);
}
}
} else {
if (dest.isGPR()) {
// we do not care about register reads in second phase
if (phase == REGISTERS_AND_PROGRAM_OPERATIONS) {
TerminalRegister& tr = dynamic_cast<TerminalRegister&>(dest);
TCEString regName = DisassemblyRegister::registerName(tr);
processRegWrite(MoveNodeUse(moveNode), regName);
}
} else { // something else
throw IllegalProgram(__FILE__,__LINE__,__func__,
"Move has illegal destination" +
moveNode.toString());
}
}
}
/**
* Clears bookkeeping which is only needed during ddg construction.
*
* @param BB containing basic blocks which contain the bookkeeping.
* @param interBBInformation needed whether information about inter-bb-
* dependencies need to be left intact.
*/
void
DataDependenceGraphBuilder::clearUnneededBookkeeping(
BasicBlock& bb, bool interBBInformationNeeded) {
if (!interBBInformationNeeded) {
//used by regcopyadder.
bb.liveRangeData_->regFirstDefines_.clear();
bb.liveRangeData_->regLastUses_.clear();
// used by both
bb.liveRangeData_->regDefines_.clear();
// these are neede for live range things
bb.liveRangeData_->regDefReaches_.clear();
bb.liveRangeData_->registersUsedAfter_.clear();
bb.liveRangeData_->regFirstUses_.clear();
}
bb.liveRangeData_->regUseReaches_.clear();
bb.liveRangeData_->regLastKills_.clear();
bb.liveRangeData_->regDefAfter_.clear();
bb.liveRangeData_->regUseAfter_.clear();
bb.liveRangeData_->memDefines_.clear();
bb.liveRangeData_->memLastUses_.clear();
bb.liveRangeData_->memFirstUses_.clear();
bb.liveRangeData_->memFirstDefines_.clear();
bb.liveRangeData_->memDefReaches_.clear();
bb.liveRangeData_->memUseReaches_.clear();
bb.liveRangeData_->fuDepReaches_.clear();
bb.liveRangeData_->fuDeps_.clear();
bb.liveRangeData_->fuDepAfter_.clear();
bb.liveRangeData_->registersUsedInOrAfter_.clear();
}
///////////////////////////////////////////////////////////////////////////////
// ProgramOperation and Operation edges.
///////////////////////////////////////////////////////////////////////////////
/**
* Handles ProgramOperation creation for a triggering move.
*
* @param moveNode triggering movenode.
* @param dop operation which is being triggered by the movenode.
*/
void
DataDependenceGraphBuilder::processTriggerPO(
MoveNode& moveNode, Operation& dop) {
if (currentData_->destPending_ != NULL) {
ProgramOperationPtr po = currentData_->destPending_;
if (&dop != &po->operation()) {
std::cerr << "pending po: " << po->toString() << std::endl;
std::cerr << "current dop: " << dop.name() << std::endl;
currentDDG_->writeToDotFile("build_fail_po.dot");
}
assert(&dop == &po->operation());
if (!po->isComplete()) {
po->addInputNode(moveNode);
moveNode.addDestinationOperationPtr(po);
}
if (po->isReady()) {
currentData_->destPending_ = ProgramOperationPtr();
if (dop.numberOfOutputs() > 0) {
assert(currentData_->readPending_ == NULL);
currentData_->readPending_ = po;
currentData_->poReadsHandled_ = 0;
} else {
currentDDG_->addProgramOperation(po);
}
} else {
throw IllegalProgram(
__FILE__, __LINE__, __func__,
"Trigger before all operands.");
}
return;
}
// only one triggering input?
if (dop.numberOfInputs() == 1) {
TerminalFUPort& tfpd =
dynamic_cast<TerminalFUPort&>(moveNode.move().destination());
ProgramOperationPtr po;
if (tfpd.hasProgramOperation()) {
po = tfpd.programOperation();
} else {
po = ProgramOperationPtr(new ProgramOperation(dop));
moveNode.addDestinationOperationPtr(po);
po->addInputNode(moveNode);
}
if (dop.numberOfOutputs()) {
assert(currentData_->readPending_ == NULL);
currentData_->readPending_ = po;
} else {
currentDDG_->addProgramOperation(po);
}
} else { // trigger came too early
const TCEString moveDisasm =
POMDisassembler::disassemble(moveNode.move());
throw IllegalProgram(
__FILE__,__LINE__, __func__,
TCEString("Trigger without operand in ") + moveDisasm);
}
}
/**
* Analyze write to a trigger of an operation.
*
* Participates in ProgramOperation building. Calls
* createTriggerDependencies(moveNode, dop) to create the register and
* operation dependence egdes of the operation. Checks if operation is
* call and if it is, processes the call-related register dependencies.
*
* @param moveNode mnData related to a move which triggers an operation
* @param dop Operation being triggered
*/
void
DataDependenceGraphBuilder::processTriggerRegistersAndOperations(
MoveNode& moveNode, Operation& dop) {
processTriggerPO(moveNode, dop);
if (moveNode.move().isFunctionCall()) {
processCall(moveNode);
}
}
/**
* Analyze write to a trigger of an operation.
*
* Participates in ProgramOperation building. Calls
* createTriggerDependencies(moveNode, dop) to create the memory and
* fu state dependence egdes of the operation. Checks if operation is
* call and if it is, processes the call-related memory dependencies.
*
* @param moveNode mnData related to a move which triggers an operation
* @param dop Operation being triggered
*/
void
DataDependenceGraphBuilder::processTriggerMemoryAndFUStates(
MoveNode& moveNode, Operation &dop) {
createTriggerDependencies(moveNode, dop);
// handle call mem deps
if (moveNode.move().isFunctionCall()) {
// no guard, is not ra, is pseudo.
MoveNodeUse mnd2(moveNode, false, false, true);
processMemWrite(mnd2);
}
}
/**
* Analyzes operand writes.
*
* Part of ProgramOperation creation.
*
* @param moveNode mnData related to a move which writes a parameter.
* @param dop Operation whose parameter is being written.
*/
void
DataDependenceGraphBuilder::processOperand(
MoveNode& moveNode, Operation &dop) {
// first operands already analyzed for PO?
// then update existing.
if (currentData_->destPending_ != NULL) {
ProgramOperationPtr po = currentData_->destPending_;
assert(&dop == &po->operation());
if (!po->isComplete()) {
po->addInputNode(moveNode);
moveNode.addDestinationOperationPtr(po);
} else {
// The MoveNode and the PO has been created before entering DDG
// building (in LLVMTCEBuilder.cc).
}
return;
}
// create a new ProgramOperation
TerminalFUPort& tfpd =
dynamic_cast<TerminalFUPort&>(moveNode.move().destination());
ProgramOperationPtr po;
if (tfpd.hasProgramOperation()) {
po = tfpd.programOperation();
} else {
po = ProgramOperationPtr(new ProgramOperation(dop));
moveNode.addDestinationOperationPtr(po);
po->addInputNode(moveNode);
}
currentData_->destPending_ = po;
}
/**
* Analyzes a source of a result read.
*
* Handles program operation creation and operation dependence creation.
*
* @param moveNode MoveNode of the move being analyzed.
*/
void
DataDependenceGraphBuilder::processResultRead(MoveNode& moveNode) {
// Goes thru all programoperations lacking result read.
// There should be only one if well-behaving
// universalmachine code.
if (currentData_->readPending_ != NULL) {
ProgramOperationPtr po = currentData_->readPending_;
currentData_->poReadsHandled_++;
if (!po->isComplete()) {
po->addOutputNode(moveNode);
moveNode.setSourceOperationPtr(po);
}
// if this PO is ready, remove from list of incomplete ones
if (currentData_->poReadsHandled_ >=
po->operation().numberOfOutputs()) {
createOperationEdges(po);
currentData_->readPending_ = ProgramOperationPtr();
currentDDG_->addProgramOperation(po);
currentData_->poReadsHandled_ = 0;
}
return;
}
throw IllegalProgram(
__FILE__, __LINE__, __func__,
(boost::format("Result move '%s' without operands") %
moveNode.move().toString()).str());
}
/**
* Creates operand edges between input and output moves of a
* programoperation.
*
* @param po ProgramOperation whose egdes we are creating.
*/
void
DataDependenceGraphBuilder::createOperationEdges(
ProgramOperationPtr po) {
const Operation& op = po->operation();
// loop over all input nodes
for (int i = 0; i < po->inputMoveCount(); i++) {
MoveNode& inputNode = po->inputMove(i);
// loop over all output nodes.
for (int j = 0; j < po->outputMoveCount(); j++) {
MoveNode& outputNode = po->outputMove(j);
// and create operation edges
// from all input nodes to all
// output nodes.
DataDependenceEdge* dde =
new DataDependenceEdge(
DataDependenceEdge::EDGE_OPERATION,
DataDependenceEdge::DEP_UNKNOWN,
op.name());
currentDDG_->connectOrDeleteEdge(
inputNode, outputNode, dde);
}
}
}
///////////////////////////////////////////////////////////////////////////////
// Register edge creation.
///////////////////////////////////////////////////////////////////////////////
/**
* Checks whether there is a previous alive write with same guard than
* given node.
*
* The origin of the guard value is tracked from DDG, not only plain guard
* is done.
*
* @param mnd MoveNode containing the guard.
* @param defines set of earlier writes which to check.
*/
bool
DataDependenceGraphBuilder::hasEarlierWriteWithSameGuard(
MoveNodeUse& mnd, std::set<MoveNodeUse>& defines) {
// first just check if there is earlier write to this reg with same guard..
for (std::set<MoveNodeUse>::iterator i = defines.begin();
i != defines.end(); i++) {
// if earlier write to this reg with same guard..
if (!mnd.guard() &&
!i->mn()->move().isUnconditional() &&
currentDDG_->sameGuards(*(i->mn()), *(mnd.mn()))) {
return true;
}
}
return false;
}
std::set<MoveNodeUse>
DataDependenceGraphBuilder::earlierWritesWithSameGuard(
MoveNodeUse& mnd, std::set<MoveNodeUse>& defines) {
std::set<MoveNodeUse> results;
// first just check if there is earlier write to this reg with same guard..
for (std::set<MoveNodeUse>::iterator i = defines.begin();
i != defines.end(); i++) {
// if earlier write to this reg with same guard..
if (!mnd.guard() &&
!i->mn()->move().isUnconditional() &&
currentDDG_->sameGuards(*(i->mn()), *(mnd.mn()))) {
results.insert(*i);
}
}
return results;
}
/**
* Handles a usage of a register value.
*
* The usage can be either register read or guard usage.
* Creates the incoming edges and handles bookkeping related to the
* register read.
*
* @param mnd Data about the register use
* @param reg Register containing the value being used.
*/
void
DataDependenceGraphBuilder::processRegUse(
MoveNodeUse mnd, const TCEString& reg) {
// We may have multiple definitions to a register alive
// (statically) at same time if some of the writes were guarded,
// so we don't know which of them were actually executed,
// so we have a set instead of single value.
std::set<MoveNodeUse>& defines =
currentBB_->basicBlock().liveRangeData_->regDefines_[reg];
std::set<MoveNodeUse> sameGuardDefines = earlierWritesWithSameGuard(mnd, defines);
// find if we have a earlier write with same guard. In this case
// no need to draw dependencies over it.
bool guardedKillFound = !sameGuardDefines.empty();
// then create the edges. if no guarded kill found,
// all non-exclusive. if guarded kill found, not to uncond move.
for (std::set<MoveNodeUse>::iterator i = defines.begin();
i != defines.end(); i++) {
// If we do not have a guarded kill, draw edges from all defines.
// If we have a guarded kill, only draw edges from
// unconditional moves, as the guarded kill overshadows the
// inconditional writes.
if (!guardedKillFound || (!i->mn()->move().isUnconditional() &&
!currentDDG_->hasRegWaw(*i, sameGuardDefines))) {
if (!currentDDG_->exclusingGuards(*(i->mn()), *(mnd.mn()))) {
DataDependenceEdge* dde =
new DataDependenceEdge(
mnd.ra() ? DataDependenceEdge::EDGE_RA :
DataDependenceEdge::EDGE_REGISTER,
DataDependenceEdge::DEP_RAW, reg, mnd.guard(), false,
i->pseudo(), mnd.pseudo(), i->loop());
currentDDG_->connectOrDeleteEdge(*i->mn(), *mnd.mn(), dde);
}
}
}
// writes in previous BB's killed or not?
// if not(this bb has a kill), has to check deps from incoming BB's.
if (currentBB_->basicBlock().liveRangeData_->regKills_.find(reg) ==
currentBB_->basicBlock().liveRangeData_->regKills_.end()) {
if (!guardedKillFound) {
// process dependencies from previous BB's
currentBB_->basicBlock().liveRangeData_->regFirstUses_[reg].
insert(mnd);
currentDDG_->updateRegUse(mnd, reg, currentBB_->basicBlock());
}
}
currentBB_->basicBlock().liveRangeData_->regLastUses_[reg].insert(mnd);
// Two writes to opposite guard may create a combined kill-pair.
// But if this is a read between them, it has to be marked in order
// to save bookkeeping about this move when the another write occurs.
// So mark here that we have a read if we have one guarded write
// in our bookkeeping as potential half of a kill pair.
std::map<TCEString, std::pair<MoveNodeUse, bool> >::iterator iter =
currentBB_->basicBlock().liveRangeData_->potentialRegKills_.find(reg);
if (iter != currentBB_->basicBlock().liveRangeData_->potentialRegKills_.end()) {
iter->second.second = true;
}
}
/**
* Creates register antidependencies from set of movenodeuses to one movenode.
*
* @param mnd Movenode which to creat those dependencies
* @param predecessorNodes Nodes where to create dependencies from
* @param depType whether to create WAR or WAW antidependencies
* @param guardedKillFound if there is a write with same guard to the reg.
*/
void
DataDependenceGraphBuilder::createRegisterAntideps(
const TCEString& reg, MoveNodeUse& mnd,
MoveNodeUseSet& predecessorNodes,
DataDependenceEdge::DependenceType depType,
bool guardedKillFound) {
// create dep to another in own bb
for (std::set<MoveNodeUse>::iterator i = predecessorNodes.begin();
i != predecessorNodes.end();) {
if (depType == DataDependenceEdge::DEP_WAW) {
// If we do not have a guarded kill, draw edges from all defines.
// If we have a guarded kill, only draw edges from
// unconditional moves, as the guarded kill overshadows the
// inconditional writes.
if (guardedKillFound && i->mn()->move().isUnconditional()) {
i++;
continue;
}
} else {
assert(depType == DataDependenceEdge::DEP_WAR);
// skip if war to itself, ie move foo.1 -> foo.1
if (i->mn() == mnd.mn()) {
i++;
continue;
}
}
// Do not create antideps if have excluding guards
// But always create antidep if this writes to a reg which is
// used as guard for the previous move.
if (!currentDDG_->exclusingGuards(*(i->mn()), *(mnd.mn())) ||
i->guard()) {
// create dependency edge
DataDependenceEdge* dde =
new DataDependenceEdge(
mnd.ra() ? DataDependenceEdge::EDGE_RA :
DataDependenceEdge::EDGE_REGISTER,
depType, reg, i->guard(), false,
i->pseudo(), mnd.pseudo(), i->loop());
// and connect
currentDDG_->connectOrDeleteEdge(*i->mn(), *mnd.mn(), dde);
// if have same guards, remove the old from bookkeeping
// this completely overshadows it
if (currentDDG_->sameGuards(*(i->mn()), *(mnd.mn()))) {
predecessorNodes.erase(i++);
continue;
}
}
i++;
}
}
/**
* Analyzes a write to a register.
*
* Creates dependence edges and updates bookkeeping.
*
* @param mnd MoveNodeUse containing MoveNode that writes a register
* @param reg register being written by the given movenode.
*/
void
DataDependenceGraphBuilder::processRegWrite(
MoveNodeUse mnd, const TCEString& reg) {
// We may have multiple definitions to a register alive
// (statically) at same time if some of the writes were guarded,
// so we don't know which of them were actually executed,
// so we have a set instead of single value.
std::set<MoveNodeUse>& defines =
currentBB_->basicBlock().liveRangeData_->regDefines_[reg];
// Set of register reads which after last kill.
std::set<MoveNodeUse>& lastUses =
currentBB_->basicBlock().liveRangeData_->regLastUses_[reg];
// find if we have a earlier write with same guard. In this case
// no need to draw dependencies over it.
bool guardedKillFound = hasEarlierWriteWithSameGuard(mnd, defines);
// if no kills to this reg in this BB, this one kills it.
if (currentBB_->basicBlock().liveRangeData_->regKills_.find(reg) ==
currentBB_->basicBlock().liveRangeData_->regKills_.end()) {
// is this alone a kill?
if (mnd.mn()->move().isUnconditional()) {
currentBB_->basicBlock().liveRangeData_->regKills_[reg].first = mnd;
currentBB_->basicBlock().liveRangeData_->regKills_[reg].second = MoveNodeUse();
} else {
// two guarded moves with opposite guards together may be a kill.
// Check if we have such previous guarded write with opposite
// guard.
std::map<TCEString, std::pair<MoveNodeUse, bool> >::iterator
iter =
currentBB_->basicBlock().liveRangeData_->potentialRegKills_.find(reg);
if (iter != currentBB_->basicBlock().liveRangeData_->potentialRegKills_.end() &&
currentDDG_->exclusingGuards(
*(iter->second.first.mn()), *(mnd.mn()))) {
currentBB_->basicBlock().liveRangeData_->regKills_[reg].first =
iter->second.first;
currentBB_->basicBlock().liveRangeData_->regKills_[reg].second = mnd;
}
}
if (!guardedKillFound) {
// may have incoming WaW's / WaRs to this
// insert to bookkeeping for further analysis.
currentBB_->basicBlock().liveRangeData_->regFirstDefines_[reg].insert(mnd);
// do we need to create some inter-bb-antideps?
if (currentDDG_->hasSingleBBLoopRegisterAntidependencies()) {
// deps from other BB.LIVERANGEDATA_->
currentDDG_->updateRegWrite(
mnd, reg, currentBB_->basicBlock());
}
}
}
// Create antideps to defines and uses in this same BB.LIVERANGEDATA_->
if (currentDDG_->hasIntraBBRegisterAntidependencies()) {
createRegisterAntideps(
reg, mnd, defines, DataDependenceEdge::DEP_WAW, guardedKillFound);
createRegisterAntideps(
reg, mnd, lastUses, DataDependenceEdge::DEP_WAR,
guardedKillFound);
}
// if unconditional, this kills previous deps.
if (mnd.mn()->move().isUnconditional()) {
defines.clear();
currentBB_->basicBlock().liveRangeData_->regLastKills_[reg].first = mnd;
currentBB_->basicBlock().liveRangeData_->regLastKills_[reg].second = MoveNodeUse();
// clear reads to given reg.
lastUses.clear();
currentBB_->basicBlock().liveRangeData_->potentialRegKills_.erase(reg);
} else {
// two guarded moves with opposite guards together may be a kill.
// Check if we have such previous guarded write with opposite
// guard.
std::map<TCEString, std::pair<MoveNodeUse, bool> >::iterator iter =
currentBB_->basicBlock().liveRangeData_->potentialRegKills_.find(reg);
if (iter != currentBB_->basicBlock().liveRangeData_->potentialRegKills_.end() &&
currentDDG_->exclusingGuards(
*(iter->second.first.mn()), *(mnd.mn()))) {
// found earlier write which is exclusive with this one.
// mark that these two together are a kill.
currentBB_->basicBlock().liveRangeData_->regLastKills_[reg].first =
iter->second.first;
currentBB_->basicBlock().liveRangeData_->regLastKills_[reg].second = mnd;
// If we have no usage of the register between these two
// writes forming the kill pair, we can clear our bookkeeping.
// only leave the other part of the kill to defines.
defines.clear();
defines.insert(iter->second.first);
if (!iter->second.second) {
// clear reads to given reg.
lastUses.clear();
}
}
currentBB_->basicBlock().liveRangeData_->potentialRegKills_[reg] =
std::pair<MoveNodeUse, bool>(mnd, false);
}
defines.insert(mnd);
}
/**
* Processes a return from a function.
*
* Creates pseudo-read-deps to SP and RV registers.
*
* @param moveNode moveNode containg the return move.
*/
void
DataDependenceGraphBuilder::processReturn(MoveNode& moveNode) {
TCEString sp = specialRegisters_[REG_SP];
// return is considered as read of sp;
// sp must be correct at the end of the procedure.
if (sp != "") {
processRegUse(MoveNodeUse(moveNode,false,false,true),sp);
}
// return is considered as read of RV.
TCEString rv = specialRegisters_[REG_RV];
if (rv != "") {
processRegUse(MoveNodeUse(moveNode,false,false,true),rv);
}
// process all vector rv values
for (int i = REG_VRV;;i--) {
auto vrvIt = specialRegisters_.find(i);
if (vrvIt != specialRegisters_.end()) {
processRegUse(
MoveNodeUse(moveNode,false,false,true),vrvIt->second);
} else {
break;
}
}
// return is also considered as read of RV high(for 64-bit RV's)
TCEString rvh = specialRegisters_[REG_RV_HIGH];
if (rvh != "") {
processRegUse(MoveNodeUse(moveNode,false,false,true),rvh);
}
TCEString fp = specialRegisters_[REG_FP];
if (fp != "") {
processRegUse(MoveNodeUse(moveNode,false,false,true),fp);
}
}
/**
* Processes a call of a function.
*
* Pseudo-reads from parameter registers and SP, writes to RV and RA.
*
* @param mn MoveNode containg the function call move.
*/
void
DataDependenceGraphBuilder::processCall(MoveNode& mn) {
// calls mess up RA. But immediately, not after delay slots?
processRegWrite(
MoveNodeUse(mn, false, true, false), RA_NAME);
// MoveNodeUse for sp and rv(not guard, not ra, is pseudo)
MoveNodeUse mnd2(mn, false,false, true);
// call is considered read of sp
TCEString sp = specialRegisters_[REG_SP];
if (sp != "") {
processRegUse(mnd2,sp);
}
// call is considered as write of RV
TCEString rv = specialRegisters_[REG_RV];
if (rv != "") {
if (rvIsParamReg_) {
processRegUse(mnd2,rv);
}
processRegWrite(mnd2,rv);
}
// process all vector rv values
for (int i = REG_VRV;;i--) {
auto vrvIt = specialRegisters_.find(i);
if (vrvIt != specialRegisters_.end()) {
processRegWrite(mnd2, vrvIt->second);
} else {
break;
}
}
// call is considered as write of RV high (64-bit return values)
TCEString rvh = specialRegisters_[REG_RV_HIGH];
if (rvh != "") {
processRegWrite(mnd2, rvh);
}
// params
for (int i = 0; i < 4;i++) {
TCEString paramReg = specialRegisters_[REG_IPARAM+i];
if (paramReg != "") {
processRegUse(mnd2, paramReg);
}
}
}
///////////////////////////////////////////////////////////////////////////////
// Side-Effects of triggers.
///////////////////////////////////////////////////////////////////////////////
/**
* Analyzes operation of a trigger write.
*
* If memory read, calls processMemRead to manage memory read dependencies.
* Manages FU State dependencies between operations.
*
* @param moveNode mnData related to a move which triggers an operation
* @param dop Operation being triggered
*
*/
void
DataDependenceGraphBuilder::createTriggerDependencies(
MoveNode& moveNode, Operation& dop) {
if (dop.readsMemory()) {
processMemUse(MoveNodeUse(moveNode));
} //TODO: avoid drawing antidep to itself
if (dop.writesMemory()) {
processMemWrite(MoveNodeUse(moveNode));
}
createSideEffectEdges(currentBB_->basicBlock().liveRangeData_->fuDeps_, moveNode, dop);
createSideEffectEdges(
currentBB_->basicBlock().liveRangeData_->fuDepReaches_, moveNode, dop);
OperationPool pool;
if (dop.hasSideEffects() || pool.sharesState(dop)) {
// remove old same op from bookkeeping.
// this should prevent exponential explosion of edge count.
if (dop.hasSideEffects() && moveNode.move().isUnconditional()) {
for (MoveNodeUseSet::iterator iter =
currentBB_->basicBlock().liveRangeData_->fuDeps_.begin();
iter != currentBB_->basicBlock().liveRangeData_->fuDeps_.end(); iter++) {
const Operation& o =
iter->mn()->destinationOperation().operation();
if (&o == &dop) {
currentBB_->basicBlock().liveRangeData_->fuDeps_.erase(iter);
break;
}
}
}
// add the new one to bookkeeping
currentBB_->basicBlock().liveRangeData_->fuDeps_.insert(MoveNodeUse(moveNode));
}
}
/*
* Creates operation side effect.
*
* Checks the given MoveNode against list of possible side effect
* dependence sources, and creates side effect edges if there is
* a side effect/fu state dependence.
*
* @param prevMoves moves to check side effects against.
* @param mn moveNode that is the destination of the dependencies.
* @param dop Operation that mn triggers.
*/
void
DataDependenceGraphBuilder::createSideEffectEdges(
MoveNodeUseSet& prevMoves, const MoveNode& mn, Operation& dop) {
OperationPool pool;
if (pool.sharesState(dop) || dop.hasSideEffects()) {
for (MoveNodeUseSet::iterator i = prevMoves.begin();
i != prevMoves.end(); i++) {
const Operation& o = i->mn()->destinationOperation().operation();
// mem writes are handled by memory deps so exclude here
if ((&dop == &o && o.hasSideEffects()) ||
dop.dependsOn(o) || o.dependsOn(dop)) {
// if operations are always assigned to differnt FU,
// skip creating dependency edge
if (isAlwaysDifferentFU(&mn, i->mn())) continue;
if (!currentDDG_->exclusingGuards(*(i->mn()), mn)) {
DataDependenceEdge* dde =
new DataDependenceEdge(
DataDependenceEdge::EDGE_FUSTATE,
DataDependenceEdge::DEP_UNKNOWN, false,false,false,
false, static_cast<int>(i->loop()));
currentDDG_->connectOrDeleteEdge(
*(i->mn()), mn, dde);
}
}
}
}
}
///////////////////////////////////////////////////////////////////////////////
// Memory edge creation.
///////////////////////////////////////////////////////////////////////////////
/**
* Checks if there is an earlier write to same address or with same guard.
*
* @param mnd the current node dictating guard and mem address to check.
* @param defines set of earlier writes to check for the write.
*/
bool
DataDependenceGraphBuilder::hasEarlierMemWriteToSameAddressWithSameGuard(
MoveNodeUse& mnd, std::set<MoveNodeUse>& defines) {
// first just check if there is earlier write to this mem address
// with same guard.
for (std::set<MoveNodeUse>::iterator i = defines.begin();
i != defines.end(); i++) {
// if earlier write to this reg with same guard..
if (currentDDG_->sameGuards(*(i->mn()), *(mnd.mn()))) {
ProgramOperation& curPop = mnd.mn()->destinationOperation();
ProgramOperation& prevPop = (i->mn())->destinationOperation();
// MoveNode* currentAddress = addressMove(*mnd.mn());
// MoveNode* prevAddress = addressMove(*(i->mn()));
if (!isAddressTraceable(prevPop) ||
analyzeMemoryAlias(prevPop, curPop, i->bbRelation()) ==
MemoryAliasAnalyzer::ALIAS_TRUE) {
return true;
}
}
}
return false;
}
/**
* Creates memory dependencies from set of nodes to given nodes.
*
* Does not create if gaurds of aliasing dictate edge not needed.
* If both guard and aliasing indicate fully transitive case for some
* prev nodes, then remove these previous nodes from the bookkeeping.
*/
void
DataDependenceGraphBuilder::checkAndCreateMemAntideps(
MoveNodeUse& mnd, std::set<MoveNodeUse>& prevNodes,
DataDependenceEdge::DependenceType depType,
bool traceable) {
// create WaW to another in own bb
for (MoveNodeUseSet::iterator iter =
prevNodes.begin(); iter != prevNodes.end();) {
if ((checkAndCreateMemDep(*iter, mnd, depType) || !traceable) &&
(mnd.mn()->move().isUnconditional() ||
currentDDG_->sameGuards(*(iter->mn()), *(mnd.mn())))) {
// remove current element and update iterator to next.
prevNodes.erase(iter++);
} else { // just take next from the set
iter++;
}
}
}
/**
* Updates memory operation bookkeeping and creates WaR and WaW
* memory dependencies.
*
* @param moveNode MoveNodeUse related to Move whose memory write to are
* processing.
*/
void
DataDependenceGraphBuilder::processMemWrite(MoveNodeUse mnd) {
TCEString category = memoryCategory(mnd);
std::set<MoveNodeUse>& defines =
currentBB_->basicBlock().liveRangeData_->memDefines_[category];
std::set<MoveNodeUse>& lastUses =
currentBB_->basicBlock().liveRangeData_->memLastUses_[category];
// check if no earlier barriers/kills to this one in this bb?
if (currentBB_->basicBlock().liveRangeData_->memKills_[category].mn() == NULL) {
// is this a kill?
if (mnd.mn()->move().isUnconditional() &&
!isAddressTraceable(mnd.mn()->destinationOperation())) {
currentBB_->basicBlock().liveRangeData_->memKills_[category] = mnd;
}
// check if there is "guarded kill" to this mem address
bool guardedKillFound =
hasEarlierMemWriteToSameAddressWithSameGuard(mnd, defines);
if (!guardedKillFound) {
// may have incoming WaW's / WaRs to this
currentBB_->basicBlock().liveRangeData_->memFirstDefines_[category].insert(mnd);
updateMemWrite(mnd, category);
}
}
bool traceable = isAddressTraceable(mnd.mn()->destinationOperation());
checkAndCreateMemAntideps(
mnd, defines, DataDependenceEdge::DEP_WAW, traceable);
checkAndCreateMemAntideps(
mnd, lastUses, DataDependenceEdge::DEP_WAR, traceable);
// does this kill previous deps?
if (mnd.mn()->move().isUnconditional() && !traceable) {
currentBB_->basicBlock().liveRangeData_->memLastKill_[category] = mnd;
defines.clear();
lastUses.clear();
}
defines.insert(mnd);
}
/**
* Processes a memory read.
*
* Creates dependence edges and updates bookkeeping.
*
* @param mnd MoveNodeUse of MoveNode being processed.
*/
void
DataDependenceGraphBuilder::processMemUse(MoveNodeUse mnd) {
TCEString category = memoryCategory(mnd);
// can be multiple if some write predicated
std::set<MoveNodeUse>& defines =
currentBB_->basicBlock().liveRangeData_->memDefines_[category];
// no kills/barriers to this one in this basic block.
if (currentBB_->basicBlock().liveRangeData_->memKills_[category].mn() == NULL) {
// check if there is "guarded kill" to this mem address
bool guardedKillFound =
hasEarlierMemWriteToSameAddressWithSameGuard(mnd, defines);
if (!guardedKillFound) {
currentBB_->basicBlock().liveRangeData_->memFirstUses_[category].insert(mnd);
// so create deps from previous BB's
updateMemUse(mnd, category);
}
}
// create deps from writes in this BB.LIVERANGEDATA_->
for (MoveNodeUseSet::iterator iter =
defines.begin(); iter != defines.end(); iter++) {
checkAndCreateMemDep(*iter, mnd, DataDependenceEdge::DEP_RAW);
}
// update bookkeeping.
currentBB_->basicBlock().liveRangeData_->memLastUses_[category].insert(mnd);
}
/**
* Compares a memory op against one previous memory ops and
* creates dependence if may alias.
*
* @param prev Previous Memory write movenode
* @param mn Current memory write movenode
* @param depType dependence type which to create.
* @return true if true alias.
*/
bool
DataDependenceGraphBuilder::checkAndCreateMemDep(
MoveNodeUse prev, MoveNodeUse mnd,
DataDependenceEdge::DependenceType depType) {
// cannot be dep if opposite guards.
if (currentDDG_->exclusingGuards(*(prev.mn()), *(mnd.mn()))) {
return false;
}
MemoryAliasAnalyzer::AliasingResult aliasResult =
MemoryAliasAnalyzer::ALIAS_UNKNOWN;
// only for true stores and loads; we cannot analyze aliasing
// of pseudo dependencies caused by call/return.
if (!prev.pseudo() && !mnd.pseudo()) {
ProgramOperation& currPop = mnd.mn()->destinationOperation();
ProgramOperation& prevPop = prev.mn()->destinationOperation();
const llvm::MachineInstr* instr1 = currPop.machineInstr();
const llvm::MachineInstr* instr2 = prevPop.machineInstr();
// The LLVM MachineInstructions are not connected to
// all memory operands, at least not to those in inline
// assembly blocks (from custom operation calls).
if (instr1 != NULL && instr2 != NULL) {
llvm::MachineInstr::mmo_iterator begin1 =
instr1->memoperands_begin();
// Machine instruction could in theory have several memory operands.
// In practice it is usually just one.
while (begin1 != instr1->memoperands_end()) {
llvm::MachineInstr::mmo_iterator begin2 =
instr2->memoperands_begin();
while (begin2 != instr2->memoperands_end()) {
// Force program ordering between volatile mem accesses.
if ((*begin1)->isVolatile() && (*begin2)->isVolatile()) {
#if 0
Application::logStream() << "MemDep >> volatile \n";
PRINT_VAR(currPop.toString());
PRINT_VAR(prevPop.toString());
(*begin1)->getValue()->dump();
(*begin2)->getValue()->dump();
#endif
aliasResult = MemoryAliasAnalyzer::ALIAS_PARTIAL;
}
begin2++;
}
begin1++;
}
}
if (aliasResult == MemoryAliasAnalyzer::ALIAS_UNKNOWN)
aliasResult = analyzeMemoryAlias(prevPop, currPop, prev.bbRelation());
}
if (aliasResult != MemoryAliasAnalyzer::ALIAS_FALSE) {
// if not alias false , have to create mem edge.
bool trueAlias = (aliasResult == MemoryAliasAnalyzer::ALIAS_TRUE);
ProgramOperation& prevPo = prev.mn()->destinationOperation();
for (int i = 0; i < prevPo.inputMoveCount(); i++) {
if (prev.loop() || &prevPo.inputMove(i) != mnd.mn()) {
// if operations are always assigned to differnt FU,
// then skip creating memroy dependency edge
if (isAlwaysDifferentFU(prev.mn(), mnd.mn())) {
continue;
}
DataDependenceEdge* dde2 =
new DataDependenceEdge(
DataDependenceEdge::EDGE_MEMORY, depType, false,
trueAlias, prev.pseudo(), mnd.pseudo(),
static_cast<int>(prev.loop()));
currentDDG_->connectOrDeleteEdge(
prevPo.inputMove(i), *mnd.mn(), dde2);
}
}
return trueAlias;
}
return false;
}
///////////////////////////////////////////////////////////////////////////////
// Alias analysis - related things.
///////////////////////////////////////////////////////////////////////////////
/**
* Gets the address-writing move of a move which is a trigger or operand
* to a memory operation.
*
* If none found, return null
*
* @param mn moveNode whose address write move is being searched.
* @return MoveNode which writes address to a mem operation or NULL.
MoveNode*
DataDependenceGraphBuilder::addressMove(const MoveNode& mn) {
if (mn.isDestinationOperation()) {
return addressOperandMove(mn.destinationOperation());
}
return NULL;
}
*/
/**
* Delegates the call to all registered memory address alias analyzers.
*
* Returns the first non-unknown result.
* If no alias analyzer can analyze these, returns ALIAS_UNKNOWN
*
* @return Whether the memory accesses in the given moves alias.
*/
MemoryAliasAnalyzer::AliasingResult
DataDependenceGraphBuilder::analyzeMemoryAlias(
const ProgramOperation& pop1, const ProgramOperation& pop2,
MoveNodeUse::BBRelation bbInfo) {
for (unsigned int i = 0; i < aliasAnalyzers_.size(); i++) {
MemoryAliasAnalyzer* analyzer = aliasAnalyzers_[i];
MemoryAliasAnalyzer::AliasingResult res =
analyzer->analyze(*currentDDG_, pop1, pop2, bbInfo);
if (res != MemoryAliasAnalyzer::ALIAS_UNKNOWN) {
return res;
}
}
return MemoryAliasAnalyzer::ALIAS_UNKNOWN;
}
/**
* Can some analyzer say something about this address?
*
* @param mn Movenode containing memory address write.
* @return true if some alias analyzer knows something about the address,
* ie can return something else than ALIAS_UNKNOWN.
*/
bool
DataDependenceGraphBuilder::isAddressTraceable(const ProgramOperation& pop) {
for (unsigned int i = 0; i < aliasAnalyzers_.size(); i++) {
if (aliasAnalyzers_.at(i)->isAddressTraceable(*currentDDG_, pop)) {
return true;
}
}
return false;
}
/**
* Checks into which category this memory address belongs.
*
* Memory accesses in different categories cannot alias, and there is
* separate bookkeeping for every category. Current implementation separates
* spills, different alias spaces, restrict keywords and opencl work items.
*
* @param mnd MoveNodeUse which transfers the address of the memory operation.
* @return string which is then used as key for map.
* unique for different categories, empty for the default category.
*
* @TODO: create some memorycategorizer interface for this analysis?
*/
TCEString
DataDependenceGraphBuilder::memoryCategory(const MoveNodeUse& mnd) {
TCEString category;
// MoveNode* addressNode = addressMove(*mnd.mn());
// if (addressNode != NULL && addressNode->isMove()) {
const TTAProgram::Move& move = mnd.mn()->move();//addressNode->move();
// spill annotations are in all operands.
for (int j = 0; j < move.annotationCount(); j++) {
TTAProgram::ProgramAnnotation anno = move.annotation(j);
if (anno.id() ==
TTAProgram::ProgramAnnotation::ANN_STACKUSE_SPILL) {
return "_SPILL";
}
if (anno.id() ==
TTAProgram::ProgramAnnotation::ANN_STACKUSE_RA_SAVE) {
return "_RA";
}
if (anno.id() ==
TTAProgram::ProgramAnnotation::ANN_STACKUSE_FP_SAVE) {
return "_FP";
}
if (anno.id() ==
TTAProgram::ProgramAnnotation::ANN_CONSTANT_MEM) {
return "_CONSTANT";
}
}
if (!mnd.mn()->isDestinationOperation()) {
PRINT_VAR(mnd.mn()->toString());
abortWithError("Not destination operation!");
}
ProgramOperation& po = mnd.mn()->destinationOperation();
LLVMTCECmdLineOptions* llvmOptions =
dynamic_cast<LLVMTCECmdLineOptions*>(
Application::cmdLineOptions());
if (llvmOptions == NULL || !llvmOptions->disableAddressSpaceAA()) {
// address space
for (int i = 0; i < po.inputMoveCount(); i++) {
MoveNode& mn = po.inputMove(i);
Move& m = mn.move();
if (m.hasAnnotations(
ProgramAnnotation::ANN_POINTER_ADDR_SPACE)) {
if (m.annotation(
0, ProgramAnnotation::ANN_POINTER_ADDR_SPACE).stringValue()
!= "0") {
category +=
"_AS:" +
m.annotation(
0, ProgramAnnotation::ANN_POINTER_ADDR_SPACE)
.stringValue();
break;
}
}
}
}
for (int i = 0; i < po.inputMoveCount(); i++) {
MoveNode& mn = po.inputMove(i);
Move& m = mn.move();
TCEString pointerName = "";
// restrict keyword.
if (m.hasAnnotations(
ProgramAnnotation::ANN_POINTER_NAME) &&
m.hasAnnotations(
ProgramAnnotation::ANN_POINTER_NOALIAS)) {
pointerName =
m.annotation(
0, ProgramAnnotation::ANN_POINTER_NAME).stringValue();
category += "_RESTRICT:" + pointerName;
break;
}
}
/* OpenCL work item variable access.
OpenCL kernels enforce memory consistency for local and global
memory only at explicit barrier() calls within a work group.
Thus, all memory accesses between work items can be considered
independent in alias analysis in the regions between barrier
calls.
*/
for (int i = 0; i < po.inputMoveCount(); i++) {
MoveNode& mn = po.inputMove(i);
Move& m = mn.move();
if (m.hasAnnotations(ProgramAnnotation::ANN_OPENCL_WORK_ITEM_ID)) {
category +=
"_OPENCL_WI:" +
Conversion::toHexString(
m.annotation(
0, ProgramAnnotation::ANN_OPENCL_WORK_ITEM_ID).
intValue(), 8);
break;
}
}
return category;
}
///////////////////////////////////////////////////////////////////////////////
// Multi-BB DDG construction
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// High-level Multi-BB DDG construction
///////////////////////////////////////////////////////////////////////////////
/**
* Builds a DDG from a CFG.
*
* @param cfg Control flow graph where the ddg is built from.
* @param antidependenceLevel level of register antidependencies to create.
* @param um universalmachine used for the code if registers unallocated.
* if null, assumed that registers allready allocated.
* @param createMemAndFUDeps whether to create also memory and
* fu state(side effect) dependencies or only register deps.
* @param createDeathInformation whether to search the last usage
* of all liveranges. This is needed for things like register renamer
* and threading.
* @return pointer to the ddg which is created.
*/
DataDependenceGraph*
DataDependenceGraphBuilder::build(
ControlFlowGraph& cfg,
DataDependenceGraph::AntidependenceLevel antidependenceLevel,
const TTAMachine::Machine& mach,
const UniversalMachine* um,
bool createMemAndFUDeps, bool createDeathInformation,
llvm::AliasAnalysis* AA) {
mach_ = &mach;
if (AA) {
for (unsigned int i = 0; i < aliasAnalyzers_.size(); i++) {
LLVMAliasAnalyzer* llvmaa =
dynamic_cast<LLVMAliasAnalyzer*>(aliasAnalyzers_[i]);
if (llvmaa != NULL) {
llvmaa->setLLVMAA(AA);
}
}
}
cfg_ = &cfg;
// @TODO: when CFG subgraphs are in use, 2nd param not always true
DataDependenceGraph* ddg = new DataDependenceGraph(
allParamRegs_, cfg.name(), antidependenceLevel, NULL, true,
false);
try {
// this is just for old frontend code.
if (um != NULL) {
findStaticRegisters(*um, specialRegisters_);
} else {
findStaticRegisters(cfg, specialRegisters_);
}
currentDDG_ = ddg;
// do the first phase (register dependencies and operation edges)
createRegisterDeps();
// then do the second phase - mem and fu deps.
if (createMemAndFUDeps) {
createMemAndFUstateDeps();
}
// search when registers are used for last time.
// this live range information is used by register renamer and
// threading.
if (createDeathInformation) {
searchRegisterDeaths();
}
// clear bookkeeping which is not needed anymore.
clearUnneededBookkeeping();
} catch (const Exception& e) {
Application::logStream()
<< e.fileName() << ": " << e.lineNum() << ": " << e.errorMessageStack()
<< std::endl;
delete ddg;
throw;
} catch (...) {
delete ddg;
throw;
}
ddg->setMachine(mach);
return ddg;
}
/**
* Initializes states of all BB's to unreached
*
*/
void
DataDependenceGraphBuilder::initializeBBStates() {
// initialize state lists
for (int bbi = 0; bbi < cfg_->nodeCount(); bbi++) {
BasicBlockNode& bbn = cfg_->node(bbi);
BasicBlock& bb = bbn.basicBlock();
if (bb.liveRangeData_ == NULL) {
bb.liveRangeData_ = new LiveRangeData;
}
BBData* bbd = new BBData(bbn);
bbData_[&bbn] = bbd;
// in the beginning all are unreached
if (bbn.isNormalBB()) {
blocksByState_[BB_UNREACHED].push_back(bbd);
}
}
}
/**
* Changes state of a basic block in processing.
* Move BBData into a diffefent list and changes the state data in BBData.
*
* @param bbd BBData of basic block whose state is being changed
* @param newState the new state of the basic block.
*/
void
DataDependenceGraphBuilder::changeState(
BBData& bbd, BBState newState, bool priorize) {
BBState oldState = bbd.state_;
if (newState != oldState) {
ContainerTools::removeValueIfExists(blocksByState_[oldState], &bbd);
bbd.state_ = newState;
if (priorize) {
blocksByState_[newState].push_front(&bbd);
} else {
blocksByState_[newState].push_back(&bbd);
}
}
}
/**
* Queues first basic block to be processed.
*
* @return the first basic block node
*/
BasicBlockNode*
DataDependenceGraphBuilder::queueFirstBB() {
// get first BB where to start
BasicBlockNodeSet firstBBs = cfg_->successors(cfg_->entryNode());
assert(firstBBs.size() == 1);
BasicBlockNode* firstBB = *firstBBs.begin();
changeState(*(bbData_[firstBB]), BB_QUEUED);
return firstBB;
}
/**
* Clears bookkeeping which is only needed during ddg construction.
*/
void
DataDependenceGraphBuilder::clearUnneededBookkeeping() {
for (int i = 0; i < cfg_->nodeCount();i++) {
BasicBlockNode& bbn = cfg_->node(i);
if (bbn.isNormalBB()) {
BasicBlock& bb = bbn.basicBlock();
clearUnneededBookkeeping(bb, true);
}
}
}
/**
* Does the first phase of ddg construction. handles register deps.
*
* @param cfg control flow graph containing the code.
*/
void
DataDependenceGraphBuilder::createRegisterDeps() {
// initializes states of all BB's to unreached.
initializeBBStates();
// queues first bb for processing
BasicBlockNode* firstBB = queueFirstBB();
// currentBB need to be set for entry node processing
currentBB_ = firstBB;
// set entry deps. ( procedure parameter edges )
MoveNode* entryNode = new MoveNode();
currentDDG_->addNode(*entryNode, cfg_->entryNode());
processEntryNode(*entryNode);
// iterate over BB's. Loop as long as there are queued BB's.
iterateBBs(REGISTERS_AND_PROGRAM_OPERATIONS);
// all should be constructed, but if there are unreachable BB's
// we handle those also
while (!blocksByState_[BB_UNREACHED].empty()) {
if (Application::verboseLevel() > Application::VERBOSE_LEVEL_DEFAULT) {
Application::logStream() << "Warning: Unreachable Basic Block!"
<< std::endl;
Application::logStream() << "In procedure: " << cfg_->name() <<
std::endl;
// cfg.writeToDotFile("unreachable_bb.dot");
}
changeState(**blocksByState_[BB_UNREACHED].begin(), BB_QUEUED);
iterateBBs(REGISTERS_AND_PROGRAM_OPERATIONS);
}
// free bb data
AssocTools::deleteAllValues(bbData_);
}
/**
* Does the second phase of ddg construction.
*
* handles mem deps and fu state deps.
*/
void
DataDependenceGraphBuilder::createMemAndFUstateDeps() {
// initializes states of all BB's to unreached.
initializeBBStates();
// queues first bb for processing
queueFirstBB();
// then iterates over all basic blocks.
iterateBBs(MEMORY_AND_SIDE_EFFECTS);
// all should be constructed, but if there are unreachable BB's
// we might want to handle those also
while (!blocksByState_[BB_UNREACHED].empty()) {
changeState(**blocksByState_[BB_UNREACHED].begin(), BB_QUEUED);
iterateBBs(MEMORY_AND_SIDE_EFFECTS);
}
// free bb data
AssocTools::deleteAllValues(bbData_);
}
/**
* Iterates over basic blocks as long as there is some BB to process.
*
* Handles a BB, updates the live value lists of its successors.
* If incoming live values of a BB change, it's scheduled for
* reprocessing.
*
* @param phase whether to handle register& operation deps or
* memory and side-effect dependencies.
*/
void
DataDependenceGraphBuilder::iterateBBs(
ConstructionPhase phase) {
while (!blocksByState_[BB_QUEUED].empty()) {
std::list<BBData*>::iterator bbIter =
blocksByState_[BB_QUEUED].begin();
BBData& bbd = **bbIter;
// construct or update BB
if (bbd.constructed_) {
updateBB(bbd, phase);
} else {
constructIndividualBB(bbd, phase);
}
// mark as ready
changeState(bbd, BB_READY);
// create deps after and update that to succeeding BBs.
// succeeding BB's are also queued to be scheduled here.
// queue succeeding BB's in case either
// * their input data has changed
// * current BB was processed for the first time
if (phase == REGISTERS_AND_PROGRAM_OPERATIONS) {
if (updateRegistersAliveAfter(bbd) || !bbd.constructed_) {
setSucceedingPredeps(bbd, !bbd.constructed_, phase);
}
} else {
if (updateMemAndFuAliveAfter(bbd) || !bbd.constructed_) {
setSucceedingPredeps(bbd, !bbd.constructed_, phase);
}
}
bbd.constructed_ = true;
}
}
/**
* Updates bookkeeping used for calculating register deaths.
*
* Marks registers used at or after some BB to it's predecessor BB's.
*
* @param bbd basic block to process.
* @param firstTime whether this BB is analyzer for the first time.
*/
void
DataDependenceGraphBuilder::updatePreceedingRegistersUsedAfter(
BBData& bbd, bool firstTime) {
BasicBlockNode& bbn = *bbd.bblock_;
BasicBlock& bb = bbn.basicBlock();
BasicBlockNodeSet predecessors = cfg_->predecessors(bbn);
for (BasicBlockNodeSet::iterator predIter = predecessors.begin();
predIter != predecessors.end(); predIter++) {
BasicBlockNode* pred = *predIter;
BasicBlock& predBB = pred->basicBlock();
BBData& predData = *bbData_[pred];
size_t size = predBB.liveRangeData_->registersUsedAfter_.size();
AssocTools::append(
bb.liveRangeData_->registersUsedInOrAfter_, predBB.liveRangeData_->registersUsedAfter_);
// if updated, need to be handled again.
if (predBB.liveRangeData_->registersUsedAfter_.size() > size || firstTime) {
if (predData.state_ != BB_QUEUED) {
changeState(predData, BB_QUEUED);
}
}
}
}
/**
* Sets outgoing data from this BB to incoming data of successors.
*
* Also queues them to be reprocessed if they are changed.
*
* @param bbd BBD whose successors will be updated.
* @param queueAll If true, queues all successors even if they do not change.
* @param phase whether to handle register& operation deps or
* memory and side-effect dependencies.
*/
void
DataDependenceGraphBuilder::setSucceedingPredeps(
BBData& bbd, bool queueAll,
ConstructionPhase phase) {
BasicBlockNode& bbn = *bbd.bblock_;
BasicBlock& bb = bbn.basicBlock();
BasicBlockNodeSet forwardSuccessors = cfg_->successors(bbn, true);
for (BasicBlockNodeSet::iterator succIter = forwardSuccessors.begin();
succIter != forwardSuccessors.end(); succIter++) {
setSucceedingPredepsForBB(
bb, **succIter, queueAll, false, phase);
}
// successors over loop edges.
BasicBlockNodeSet backwardSuccessors = cfg_->successors(bbn, false, true);
for (BasicBlockNodeSet::iterator succIter = backwardSuccessors.begin();
succIter != backwardSuccessors.end(); succIter++) {
setSucceedingPredepsForBB(
bb, **succIter, queueAll, true, phase);
}
}
/**
* Sets outgoing data from this BB to incoming data of one successor.
*
* Also queues them to be reprocessed if they are changed.
*
* @param bb BB whose successor will be updated.
* @param successor successor BB whose incoming data is being updated.
* @param queueAll If true, queues all successors even if they do not change.
* @param loop whether to add loop property to the copied
* bookkeeping, ie create edges with loop property.
* @param phase whether to handle register& operation deps or
* memory and side-effect dependencies.
*/
void
DataDependenceGraphBuilder::setSucceedingPredepsForBB(
BasicBlock& bb, BasicBlockNode& successor, bool queueAll, bool loop,
ConstructionPhase phase) {
BasicBlock& succBB = successor.basicBlock();
BBData& succData = *bbData_[&successor];
bool changed = false;
if (phase == REGISTERS_AND_PROGRAM_OPERATIONS) {
changed |= LiveRangeData::appendUseMapSets(
bb.liveRangeData_->regDefAfter_,
succBB.liveRangeData_->regDefReaches_, loop);
if (currentDDG_->hasAllRegisterAntidependencies() ||
(&bb == &succBB &&
currentDDG_->hasSingleBBLoopRegisterAntidependencies())) {
changed |= LiveRangeData::appendUseMapSets(
bb.liveRangeData_->regUseAfter_,
succBB.liveRangeData_->regUseReaches_, loop);
}
} else {
// mem deps + fu state deps
changed |= LiveRangeData::appendUseMapSets(
bb.liveRangeData_->memDefAfter_,
succBB.liveRangeData_->memDefReaches_, loop);
changed |= LiveRangeData::appendUseMapSets(
bb.liveRangeData_->memUseAfter_,
succBB.liveRangeData_->memUseReaches_, loop);
size_t size = succBB.liveRangeData_->fuDepReaches_.size();
LiveRangeData::appendMoveNodeUse(
bb.liveRangeData_->fuDepAfter_,
succBB.liveRangeData_->fuDepReaches_, loop);
if (succBB.liveRangeData_->fuDepReaches_.size() > size) {
changed = true;
}
}
// need to queue successor for update?
if (changed || queueAll) {
changeState(succData, BB_QUEUED, loop);
}
}
///////////////////////////////////////////////////////////////////////////////
// Low-level of Multi-BB DDG construction
///////////////////////////////////////////////////////////////////////////////
/**
* Updates live register lists after a basic block has been processed.
*
* Copies use and define definitions from the basic block and
* it's prodecessors to the after alive data structures.
*
* @param bbd BBData for bb being processed
* @return true if the after alive data structures have been changed
*/
bool DataDependenceGraphBuilder::updateRegistersAliveAfter(
BBData& bbd) {
BasicBlock& bb = bbd.bblock_->basicBlock();
bool changed = false;
// copy reg definitions that are alive
for (MoveNodeUseMapSet::iterator iter =
bb.liveRangeData_->regDefReaches_.begin();
iter != bb.liveRangeData_->regDefReaches_.end(); iter++) {
TCEString reg = iter->first;
std::set<MoveNodeUse>& preDefs = iter->second;
// todo: clear or not?
std::set<MoveNodeUse>& defAfter = bb.liveRangeData_->regDefAfter_[reg];
size_t size = defAfter.size();
// only copy incomin dep if this has no unconditional writes
if (bb.liveRangeData_->regKills_.find(reg) == bb.liveRangeData_->regKills_.end()) {
for (std::set<MoveNodeUse>::iterator i = preDefs.begin();
i != preDefs.end(); i++ ) {
defAfter.insert(*i);
}
}
// if size increased, the data has changed
if (size < defAfter.size()) {
changed = true;
}
}
// own deps. need to do only once but now does after every.
changed |= LiveRangeData::appendUseMapSets(
bb.liveRangeData_->regDefines_,
bb.liveRangeData_->regDefAfter_, false);
if (currentDDG_->hasAllRegisterAntidependencies()) {
// copy uses that are alive
for (MoveNodeUseMapSet::iterator iter =
bb.liveRangeData_->regUseReaches_.begin(); iter != bb.liveRangeData_->regUseReaches_.end();
iter++) {
TCEString reg = iter->first;
std::set<MoveNodeUse>& preUses = iter->second;
std::set<MoveNodeUse>& useAfter = bb.liveRangeData_->regUseAfter_[reg];
size_t size = useAfter.size();
if (bb.liveRangeData_->regKills_.find(reg) == bb.liveRangeData_->regKills_.end()) {
for (std::set<MoveNodeUse>::iterator i = preUses.begin();
i != preUses.end(); i++ ) {
useAfter.insert(*i);
}
}
// if size increased, the data has changed
if (size < useAfter.size()) {
changed = true;
}
}
}
// own deps. need to do only once but now does after every.
changed |= LiveRangeData::appendUseMapSets(
bb.liveRangeData_->regLastUses_,
bb.liveRangeData_->regUseAfter_, false);
return changed;
}
/**
* Updates live mem access lists and fu state usages after a basic block
* has been processed.
*
* Copies use and write definitions from the basic block and
* it's prodecessors to the after alive data structures.
*
* @param bbd BBData for bb being processed
* @return true if the after alive data structures have been changed
*/
bool DataDependenceGraphBuilder::updateMemAndFuAliveAfter(BBData& bbd) {
BasicBlock& bb = bbd.bblock_->basicBlock();
bool changed = false;
// copy mem definitions that are alive
for (MoveNodeUseMapSet::iterator iter = bb.liveRangeData_->memDefReaches_.begin();
iter != bb.liveRangeData_->memDefReaches_.end(); iter++) {
TCEString category = iter->first;
std::set<MoveNodeUse>& preDefs = iter->second;
std::set<MoveNodeUse>& defAfter = bb.liveRangeData_->memDefAfter_[category];
std::set<MoveNodeUse>& ownDefines = bb.liveRangeData_->memDefines_[category];
size_t size = defAfter.size();
// only copy incomin dep if this has no unconditional writes,
if (bb.liveRangeData_->memKills_.find(category) == bb.liveRangeData_->memKills_.end()) {
for (std::set<MoveNodeUse>::iterator i = preDefs.begin();
i != preDefs.end(); i++ ) {
// MoveNode* preAddress = addressMove(*(i->mn()));
ProgramOperation& prevPop = i->mn()->destinationOperation();
bool overWritten = false;
for (std::set<MoveNodeUse>::iterator j = ownDefines.begin();
j != ownDefines.end(); j++) {
if (j->mn()->move().isUnconditional()) {
// MoveNode* ownAddress = addressMove(*(j->mn()));
ProgramOperation& ownPop = j->mn()->destinationOperation();
if (analyzeMemoryAlias(prevPop, ownPop, i->bbRelation()) ==
MemoryAliasAnalyzer::ALIAS_TRUE) {
overWritten = true;
break;
}
}
}
if (!overWritten) {
defAfter.insert(*i);
}
}
}
// if size increased, the data has changed
if (size < defAfter.size()) {
changed = true;
}
}
// own deps. need to do only once but now does after every.
changed |= LiveRangeData::appendUseMapSets(
bb.liveRangeData_->memDefines_,
bb.liveRangeData_->memDefAfter_, false);
// copy uses that are alive
for (MoveNodeUseMapSet::iterator iter = bb.liveRangeData_->memUseReaches_.begin();
iter != bb.liveRangeData_->memUseReaches_.end(); iter++) {
TCEString category = iter->first;
std::set<MoveNodeUse>& preUses = iter->second;
std::set<MoveNodeUse>& useAfter = bb.liveRangeData_->memUseAfter_[category];
std::set<MoveNodeUse>& ownDefines = bb.liveRangeData_->memDefines_[category];
size_t size = useAfter.size();
if (bb.liveRangeData_->memKills_.find(category) == bb.liveRangeData_->memKills_.end()) {
for (std::set<MoveNodeUse>::iterator i = preUses.begin();
i != preUses.end(); i++ ) {
// MoveNode* preAddress = addressMove(*(i->mn()));
ProgramOperation& prevPop = i->mn()->destinationOperation();
bool overWritten = false;
for (std::set<MoveNodeUse>::iterator j =
ownDefines.begin(); j != ownDefines.end(); j++) {
if (j->mn()->move().isUnconditional()) {
ProgramOperation& ownPop = j->mn()->destinationOperation();
if (analyzeMemoryAlias(prevPop, ownPop, i->bbRelation()) ==
MemoryAliasAnalyzer::ALIAS_TRUE) {
overWritten = true;
break;
}
}
}
if (!overWritten) {
useAfter.insert(*i);
}
}
}
// if size increased, the data has changed
if (size < useAfter.size()) {
changed = true;
}
}
// fu deps
size_t size = bb.liveRangeData_->fuDepAfter_.size();
AssocTools::append(bb.liveRangeData_->fuDeps_, bb.liveRangeData_->fuDepAfter_);
if (bb.liveRangeData_->fuDepAfter_.size() > size) {
changed = true;
}
return changed;
}
/**
* Processes the pseudo deps from entry node.
*
* This procedure must be called when currentBB is the first real
* BB of the procedure.
*/
void DataDependenceGraphBuilder::processEntryNode(MoveNode& mn) {
// initializes RA
currentBB_->basicBlock().liveRangeData_->regDefReaches_[RA_NAME].insert(mn);
// sp
MoveNodeUse mnd2(mn);
TCEString sp = specialRegisters_[REG_SP];
if (sp != "") {
currentBB_->basicBlock().liveRangeData_->regDefReaches_[sp].insert(mnd2);
}
if (rvIsParamReg_) {
TCEString rv = specialRegisters_[REG_RV];
if (rv != "") {
currentBB_->basicBlock().liveRangeData_->regDefReaches_[rv].insert(
mnd2);
}
}
// params
// this is for old frontend generated code.
for (int i = 0;;i++) {
TCEString paramReg = specialRegisters_[REG_IPARAM+i];
if(paramReg != "") {
currentBB_->basicBlock().liveRangeData_->regDefReaches_[paramReg].insert(mnd2);
} else {
break;
}
}
TCEString fp = specialRegisters_[REG_FP];
if (fp != "") {
currentBB_->basicBlock().liveRangeData_->regDefReaches_[fp].insert(
mnd2);
}
}
/**
* Reprocesses a basic block which has already once been processed.
*
* Checks dependencies to first uses and definitions of registers,
* does not recreate edges inside the basic block.
*
* @param bbd BBData for basic block which is being reprocessed.
* @param phase whether to handle register& operation deps or
* memory and side-effect dependencies.
*/
void
DataDependenceGraphBuilder::updateBB(
BBData& bbd, ConstructionPhase phase) {
currentData_ = &bbd;
currentBB_ = bbd.bblock_;
BasicBlock& bb = bbd.bblock_->basicBlock();
// register and operation dependencies
if (phase == REGISTERS_AND_PROGRAM_OPERATIONS) {
//loop all regs having ext deps and create reg edges
for (MoveNodeUseMapSet::iterator firstUseIter =
bb.liveRangeData_->regFirstUses_.begin();
firstUseIter != bb.liveRangeData_->regFirstUses_.end();
firstUseIter++) {
TCEString reg = firstUseIter->first;
std::set<MoveNodeUse>& firstUseSet = firstUseIter->second;
for (std::set<MoveNodeUse>::iterator iter2 = firstUseSet.begin();
iter2 != firstUseSet.end(); iter2++) {
currentDDG_->updateRegUse(
*iter2, reg, currentBB_->basicBlock());
}
}
if (currentDDG_->hasSingleBBLoopRegisterAntidependencies()) {
// antidependencies to registers
for (MoveNodeUseMapSet::iterator firstDefineIter =
bb.liveRangeData_->regFirstDefines_.begin();
firstDefineIter != bb.liveRangeData_->regFirstDefines_.end();
firstDefineIter++) {
TCEString reg = firstDefineIter->first;
std::set<MoveNodeUse>& firstDefineSet =
firstDefineIter->second;
for (std::set<MoveNodeUse>::iterator iter2=
firstDefineSet.begin();
iter2 != firstDefineSet.end(); iter2++) {
currentDDG_->updateRegWrite(
*iter2, reg, currentBB_->basicBlock());
}
}
}
} else {
// phase 1 .. mem deps and fu state/side effect dependencies.
//loop all first mem uses having ext deps and create mem edges
for (MoveNodeUseMapSet::iterator firstUseIter =
bb.liveRangeData_->memFirstUses_.begin();
firstUseIter != bb.liveRangeData_->memFirstUses_.end();
firstUseIter++) {
TCEString category = firstUseIter->first;
std::set<MoveNodeUse>& firstUseSet = firstUseIter->second;
for (std::set<MoveNodeUse>::iterator iter2 = firstUseSet.begin();
iter2 != firstUseSet.end(); iter2++) {
updateMemUse(*iter2, category);
}
}
// antidependencies to memory
for (MoveNodeUseMapSet::iterator firstDefineIter =
bb.liveRangeData_->memFirstDefines_.begin();
firstDefineIter != bb.liveRangeData_->memFirstDefines_.end();
firstDefineIter++) {
TCEString category = firstDefineIter->first;
std::set<MoveNodeUse>& firstDefineSet = firstDefineIter->second;
for (std::set<MoveNodeUse>::iterator iter2=firstDefineSet.begin();
iter2 != firstDefineSet.end(); iter2++) {
updateMemWrite(*iter2, category);
}
}
// and fu state deps
for (MoveNodeUseSet::iterator iter =
bb.liveRangeData_->fuDeps_.begin();
iter != bb.liveRangeData_->fuDeps_.end(); iter++) {
Terminal& dest = iter->mn()->move().destination();
TerminalFUPort& tfpd = dynamic_cast<TerminalFUPort&>(dest);
Operation &dop = tfpd.hintOperation();
createSideEffectEdges(
currentBB_->basicBlock().liveRangeData_->fuDepReaches_,
*iter->mn(), dop);
}
}
}
/**
* Checks memory write against uses and defs in incoming basic blocks.
* Creates the needed dependence edges.
*
* @param mnd MoveNodeUse of movenode being processed.
* @param category which memory category this memory write belongs.
*/
void
DataDependenceGraphBuilder::updateMemWrite(
MoveNodeUse mnd, const TCEString& category) {
// create waw edges from all alive writes to this node.
for (MoveNodeUseSet::iterator iter =
currentBB_->basicBlock().liveRangeData_->memDefReaches_[category].begin();
iter != currentBB_->basicBlock().liveRangeData_->memDefReaches_[category].end();) {
checkAndCreateMemDep(*iter++, mnd, DataDependenceEdge::DEP_WAW);
}
// create war edges from all alive reads to this node.
for (MoveNodeUseSet::iterator iter = currentBB_->basicBlock().liveRangeData_->
memUseReaches_[category].begin();
iter != currentBB_->basicBlock().liveRangeData_->memUseReaches_[category].end();) {
checkAndCreateMemDep(*iter++, mnd, DataDependenceEdge::DEP_WAR);
}
}
/**
* Checks memory read against uses and defs in incoming basic blocks.
* Creates the needed dependence edges.
*
* @param mnd MoveNodeUse of movenode being processed.
* @param category which memory category this memory write belongs.
*/
void DataDependenceGraphBuilder::updateMemUse(
MoveNodeUse mnd, const TCEString& category) {
for (MoveNodeUseSet::iterator iter =
currentBB_->basicBlock().liveRangeData_->memDefReaches_[category].begin();
iter != currentBB_->basicBlock().liveRangeData_->memDefReaches_[category].end();
iter++) {
checkAndCreateMemDep(*iter, mnd,DataDependenceEdge::DEP_RAW);
}
}
///////////////////////////////////////////////////////////////////////////////
// Searching of ends of liveranges, ie last uses of values
///////////////////////////////////////////////////////////////////////////////
/**
* Searches the last usages a registers.
*
* This information is used for checking whether given register contains
* live value at given cycle.
*/
void
DataDependenceGraphBuilder::searchRegisterDeaths() {
// initializes states of all BB's to unreached.
initializeBBStates();
// start from end of cfg. (sink nodes), queue them
ControlFlowGraph::NodeSet lastBBs = cfg_->sinkNodes();
for (ControlFlowGraph::NodeSet::iterator iter =
lastBBs.begin(); iter != lastBBs.end(); iter++) {
changeState(*(bbData_[*iter]), BB_QUEUED);
}
// then iterate over all BB's, going from BB to it's
// predecessors.
iterateRegisterDeaths();
// all should have gone thru, but if there are 4ever loop causing
// BB's not reachable from the end.
// we might want to handle those also.
while (!blocksByState_[BB_UNREACHED].empty()) {
if (Application::verboseLevel() > Application::VERBOSE_LEVEL_DEFAULT) {
Application::logStream() << "Warning: BB in 4ever loop!"
<< std::endl;
Application::logStream() << "In procedure: " << cfg_->name() <<
std::endl;
// cfg.writeToDotFile("4everloop_bb.dot");
}
changeState(**blocksByState_[BB_UNREACHED].begin(), BB_QUEUED);
iterateRegisterDeaths();
}
// free bb data
AssocTools::deleteAllValues(bbData_);
}
/**
* Iterates thru all queued BB's and find register deaths from them.
*
* Loops as long as something keeps changing.
*/
void
DataDependenceGraphBuilder::iterateRegisterDeaths() {
// loop as long as we have unprocessed/changed BB's
while (!blocksByState_[BB_QUEUED].empty()) {
std::list<BBData*>::iterator bbIter =
blocksByState_[BB_QUEUED].begin();
BBData& bbd = **bbIter;
// mark as ready
changeState(bbd, BB_READY);
if (updateRegistersUsedInOrAfter(bbd) || (!bbd.constructed_)) {
// if there asre more registers read after start of this BB,
// have to update this information to preceedign BBs,
// and check if they need to be reprocessed.
updatePreceedingRegistersUsedAfter(bbd, !bbd.constructed_);
}
bbd.constructed_ = true;
}
}
/**
* Updates bookkeeping about registers used in this or later BBs.
*
* This is a helper function used by searchRegisterDeaths() method.
*
* @param bbd Data about one basicblock.
* @return whether the bookkeeping was changed,
ie the predecessors of this BB need to be reprocessed.
*/
bool
DataDependenceGraphBuilder::updateRegistersUsedInOrAfter(
BBData& bbd) {
BasicBlock& bb = bbd.bblock_->basicBlock();
size_t size = bb.liveRangeData_->registersUsedInOrAfter_.size();
// if definition not here, it's earlier - copy.
// if definition here, not alive unless read here.
for (std::set<TCEString>::iterator i = bb.liveRangeData_->registersUsedAfter_.begin();
i != bb.liveRangeData_->registersUsedAfter_.end(); i++) {
// if not written in this, written earlier.
if (bb.liveRangeData_->regKills_.find(*i) == bb.liveRangeData_->regKills_.end()) {
bb.liveRangeData_->registersUsedInOrAfter_.insert(*i);
}
}
// reads in this BB.liveRangeData_-> Only reads whose defining value comes/can come
// outside this BB.liveRangeData_->
for (MoveNodeUseMapSet::iterator i = bb.liveRangeData_->regFirstUses_.begin();
i != bb.liveRangeData_->regFirstUses_.end(); i++) {
bb.liveRangeData_->registersUsedInOrAfter_.insert(i->first);
}
if (bb.liveRangeData_->registersUsedInOrAfter_.size() > size) {
return true;
}
return false;
}
/**
* Check if operations are assigned to differnt FU
*
* Operations forced to different FUs are independent since
* the operation state is per FU. Check if the moves have
* forced set of FUs and if the sets overlap.
*
* @param srcMN MoveNode first node for dependency check
* @param dstMN MoveNode for which dependency needs to be checked
* @return Nodes are alawys mapped to different FU
*/
bool
DataDependenceGraphBuilder::isAlwaysDifferentFU(
const MoveNode* srcMN, const MoveNode* dstMN) {
if (srcMN->move().hasAnnotations(
TTAProgram::ProgramAnnotation::ANN_ALLOWED_UNIT_DST) &&
dstMN->move().hasAnnotations(
TTAProgram::ProgramAnnotation::ANN_ALLOWED_UNIT_DST)) {
bool alwaysDifferentFUs = true;
for (int idx = 0;
idx < srcMN->move().annotationCount(
TTAProgram::ProgramAnnotation::ANN_ALLOWED_UNIT_DST);
++idx) {
if (dstMN->move().hasAnnotation(
TTAProgram::ProgramAnnotation::ANN_ALLOWED_UNIT_DST,
srcMN->move()
.annotation(
idx, TTAProgram::ProgramAnnotation::
ANN_ALLOWED_UNIT_DST)
.stringValue())) {
alwaysDifferentFUs = false;
break;
}
}
return alwaysDifferentFUs;
}
return false;
}
/**
* Internal constant for the name of the return address port
*/
const TCEString DataDependenceGraphBuilder::RA_NAME = "RA";
///////////////////////////////////////////////////////////////////////////////
// BBData
///////////////////////////////////////////////////////////////////////////////
/**
* Constructor
*/
DataDependenceGraphBuilder::BBData::BBData(BasicBlockNode& bb) :
poReadsHandled_(0),
state_(BB_UNREACHED), constructed_(false), bblock_(&bb) {
}
/**
* Destructor.
*/
DataDependenceGraphBuilder::BBData::~BBData() {
}
| 35.76544 | 108 | 0.607284 | [
"object",
"vector"
] |
1b349a68e4f7a265fcdb1776dc7f4792b684c680 | 1,913 | cpp | C++ | tst/unit/test_primitive_group.cpp | lanl/PANACEA | 9779bdb6dcc3be41ea7b286ae55a21bb269e0339 | [
"BSD-3-Clause"
] | null | null | null | tst/unit/test_primitive_group.cpp | lanl/PANACEA | 9779bdb6dcc3be41ea7b286ae55a21bb269e0339 | [
"BSD-3-Clause"
] | null | null | null | tst/unit/test_primitive_group.cpp | lanl/PANACEA | 9779bdb6dcc3be41ea7b286ae55a21bb269e0339 | [
"BSD-3-Clause"
] | null | null | null |
// Local private PANACEA includes
#include "primitives/primitive_group.hpp"
#include "constants.hpp"
#include "descriptors/descriptor_wrapper.hpp"
#include "io/file_io_factory.hpp"
#include "kernels/kernel_specifications.hpp"
#include "primitives/primitive_factory.hpp"
#include "private_settings.hpp"
// Public PANACEA includes
#include "panacea/base_descriptor_wrapper.hpp"
#include "panacea/file_io.hpp"
// Third party includes
#include <catch2/catch.hpp>
// Standard includes
#include <iostream>
#include <vector>
using namespace std;
using namespace panacea;
TEST_CASE("Testing:primitive group write & read", "[unit,panacea]") {
// 3 points 2 dimensions
std::vector<std::vector<double>> data{{1.0, 4.0}, {2.0, 5.0}, {3.0, 6.0}};
DescriptorWrapper<std::vector<std::vector<double>> *> dwrapper_init(&data, 3,
2);
KernelSpecification kernel_settings(
settings::KernelCorrelation::Uncorrelated,
settings::KernelCount::OneToOne, settings::KernelPrimitive::Gaussian,
settings::KernelNormalization::None, settings::KernelMemory::Share,
settings::KernelCenterCalculation::None,
settings::KernelAlgorithm::Flexible, settings::RandomizeDimensions::No,
settings::RandomizeNumberDimensions::No, constants::automate);
PrimitiveFactory prim_factory;
auto prim_grp = prim_factory.createGroup(dwrapper_init, kernel_settings,
"test_prim_group");
std::fstream fs;
fs.open("test_prim_group.restart", std::fstream::out);
PrimitiveGroup::write(settings::FileType::TXTRestart, fs, &prim_grp);
fs.close();
PrimitiveGroup prim_grp2;
std::fstream fs2;
fs2.open("test_prim_group.restart", std::fstream::in);
PrimitiveGroup::read(settings::FileType::TXTRestart, fs2, &prim_grp2);
fs2.close();
REQUIRE(prim_grp2.name == "test_prim_group");
}
| 32.982759 | 79 | 0.706221 | [
"vector"
] |
1b350251535e469c06bab1dbf9ce761994a7f11e | 9,741 | tcc | C++ | third-party/thrift/src/thrift/compiler/test/fixtures/complex-union/gen-cpp2/module_types.tcc | hkirsman/hhvm_centos7_builds | 2a1fd6de0d2d289c1575f43f10018f3bec23bb13 | [
"PHP-3.01",
"Zend-2.0"
] | null | null | null | third-party/thrift/src/thrift/compiler/test/fixtures/complex-union/gen-cpp2/module_types.tcc | hkirsman/hhvm_centos7_builds | 2a1fd6de0d2d289c1575f43f10018f3bec23bb13 | [
"PHP-3.01",
"Zend-2.0"
] | null | null | null | third-party/thrift/src/thrift/compiler/test/fixtures/complex-union/gen-cpp2/module_types.tcc | hkirsman/hhvm_centos7_builds | 2a1fd6de0d2d289c1575f43f10018f3bec23bb13 | [
"PHP-3.01",
"Zend-2.0"
] | null | null | null | /**
* Autogenerated by Thrift
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
*/
#pragma once
#include "module_types.h"
#include <thrift/lib/cpp/TApplicationException.h>
#include <folly/MoveWrapper.h>
#include <folly/io/IOBuf.h>
#include <folly/io/IOBufQueue.h>
#include <thrift/lib/cpp/transport/THeader.h>
#include <thrift/lib/cpp2/server/Cpp2ConnContext.h>
#include <thrift/lib/cpp2/GeneratedCodeHelper.h>
#include <thrift/lib/cpp2/protocol/BinaryProtocol.h>
#include <thrift/lib/cpp2/protocol/CompactProtocol.h>
namespace cpp2 {
template <class Protocol_>
uint32_t ComplexUnion::read(Protocol_* iprot) {
uint32_t xfer = 0;
std::string fname;
apache::thrift::protocol::TType ftype;
int16_t fid;
xfer += iprot->readStructBegin(fname);
using apache::thrift::TProtocolException;
xfer += iprot->readFieldBegin(fname, ftype, fid);
if (ftype == apache::thrift::protocol::T_STOP) {
this->__clear();
} else {
if (fid == std::numeric_limits<int16_t>::min()) {
if (fname == "intValue") {
fid = 1;
ftype = apache::thrift::protocol::T_I64;
}
else if (fname == "stringValue") {
fid = 2;
ftype = apache::thrift::protocol::T_STRING;
}
else if (fname == "intListValue") {
fid = 3;
ftype = apache::thrift::protocol::T_LIST;
}
else if (fname == "stringListValue") {
fid = 4;
ftype = apache::thrift::protocol::T_LIST;
}
}
switch (fid) {
case 1:
{
if (ftype == apache::thrift::protocol::T_I64) {
this->set_intValue();
xfer += iprot->readI64(this->mutable_intValue());
} else {
xfer += iprot->skip(ftype);
}
break;
}
case 2:
{
if (ftype == apache::thrift::protocol::T_STRING) {
this->set_stringValue();
xfer += iprot->readString(this->mutable_stringValue());
} else {
xfer += iprot->skip(ftype);
}
break;
}
case 3:
{
if (ftype == apache::thrift::protocol::T_LIST) {
this->set_intListValue();
this->mutable_intListValue() = std::vector<int64_t>();
uint32_t _size0;
apache::thrift::protocol::TType _etype3;
xfer += iprot->readListBegin(_etype3, _size0);
uint32_t _i4;
if (_size0 == std::numeric_limits<uint32_t>::max()) {
for (_i4 = 0; iprot->peekList(); _i4++) {
this->mutable_intListValue().resize(_i4 + 1);
xfer += iprot->readI64(this->mutable_intListValue()[_i4]);
}
}
else {
this->mutable_intListValue().resize(_size0);
for (_i4 = 0; _i4 < _size0; ++_i4) {
xfer += iprot->readI64(this->mutable_intListValue()[_i4]);
}
}
xfer += iprot->readListEnd();
} else {
xfer += iprot->skip(ftype);
}
break;
}
case 4:
{
if (ftype == apache::thrift::protocol::T_LIST) {
this->set_stringListValue();
this->mutable_stringListValue() = std::vector<std::string>();
uint32_t _size5;
apache::thrift::protocol::TType _etype8;
xfer += iprot->readListBegin(_etype8, _size5);
uint32_t _i9;
if (_size5 == std::numeric_limits<uint32_t>::max()) {
for (_i9 = 0; iprot->peekList(); _i9++) {
this->mutable_stringListValue().resize(_i9 + 1);
xfer += iprot->readString(this->mutable_stringListValue()[_i9]);
}
}
else {
this->mutable_stringListValue().resize(_size5);
for (_i9 = 0; _i9 < _size5; ++_i9) {
xfer += iprot->readString(this->mutable_stringListValue()[_i9]);
}
}
xfer += iprot->readListEnd();
} else {
xfer += iprot->skip(ftype);
}
break;
}
default:
{
xfer += iprot->skip(ftype);
break;
}
}
xfer += iprot->readFieldEnd();
xfer += iprot->readFieldBegin(fname, ftype, fid);
xfer += iprot->readFieldEnd();
}
xfer += iprot->readStructEnd();
return xfer;
}
template <class Protocol_>
uint32_t ComplexUnion::serializedSize(Protocol_* prot_) const {
uint32_t xfer = 0;
xfer += prot_->serializedStructSize("ComplexUnion");
switch(this->getType()) {
case ComplexUnion::Type::intValue:
{
xfer += prot_->serializedFieldSize("intValue", apache::thrift::protocol::T_I64, 1);
xfer += prot_->serializedSizeI64(this->get_intValue());
break;
}
case ComplexUnion::Type::stringValue:
{
xfer += prot_->serializedFieldSize("stringValue", apache::thrift::protocol::T_STRING, 2);
xfer += prot_->serializedSizeString(this->get_stringValue());
break;
}
case ComplexUnion::Type::intListValue:
{
xfer += prot_->serializedFieldSize("intListValue", apache::thrift::protocol::T_LIST, 3);
xfer += prot_->serializedSizeListBegin(apache::thrift::protocol::T_I64, this->get_intListValue().size());
for (auto _iter10 = this->get_intListValue().begin(); _iter10 != this->get_intListValue().end(); ++_iter10) {
xfer += prot_->serializedSizeI64((*_iter10));
}
xfer += prot_->serializedSizeListEnd();
break;
}
case ComplexUnion::Type::stringListValue:
{
xfer += prot_->serializedFieldSize("stringListValue", apache::thrift::protocol::T_LIST, 4);
xfer += prot_->serializedSizeListBegin(apache::thrift::protocol::T_STRING, this->get_stringListValue().size());
for (auto _iter11 = this->get_stringListValue().begin(); _iter11 != this->get_stringListValue().end(); ++_iter11) {
xfer += prot_->serializedSizeString((*_iter11));
}
xfer += prot_->serializedSizeListEnd();
break;
}
case ComplexUnion::Type::__EMPTY__:;
}
xfer += prot_->serializedSizeStop();
return xfer;
}
template <class Protocol_>
uint32_t ComplexUnion::serializedSizeZC(Protocol_* prot_) const {
uint32_t xfer = 0;
xfer += prot_->serializedStructSize("ComplexUnion");
switch(this->getType()) {
case ComplexUnion::Type::intValue:
{
xfer += prot_->serializedFieldSize("intValue", apache::thrift::protocol::T_I64, 1);
xfer += prot_->serializedSizeI64(this->get_intValue());
break;
}
case ComplexUnion::Type::stringValue:
{
xfer += prot_->serializedFieldSize("stringValue", apache::thrift::protocol::T_STRING, 2);
xfer += prot_->serializedSizeString(this->get_stringValue());
break;
}
case ComplexUnion::Type::intListValue:
{
xfer += prot_->serializedFieldSize("intListValue", apache::thrift::protocol::T_LIST, 3);
xfer += prot_->serializedSizeListBegin(apache::thrift::protocol::T_I64, this->get_intListValue().size());
for (auto _iter12 = this->get_intListValue().begin(); _iter12 != this->get_intListValue().end(); ++_iter12) {
xfer += prot_->serializedSizeI64((*_iter12));
}
xfer += prot_->serializedSizeListEnd();
break;
}
case ComplexUnion::Type::stringListValue:
{
xfer += prot_->serializedFieldSize("stringListValue", apache::thrift::protocol::T_LIST, 4);
xfer += prot_->serializedSizeListBegin(apache::thrift::protocol::T_STRING, this->get_stringListValue().size());
for (auto _iter13 = this->get_stringListValue().begin(); _iter13 != this->get_stringListValue().end(); ++_iter13) {
xfer += prot_->serializedSizeString((*_iter13));
}
xfer += prot_->serializedSizeListEnd();
break;
}
case ComplexUnion::Type::__EMPTY__:;
}
xfer += prot_->serializedSizeStop();
return xfer;
}
template <class Protocol_>
uint32_t ComplexUnion::write(Protocol_* prot_) const {
uint32_t xfer = 0;
xfer += prot_->writeStructBegin("ComplexUnion");
switch(this->getType()) {
case ComplexUnion::Type::intValue:
{
xfer += prot_->writeFieldBegin("intValue", apache::thrift::protocol::T_I64, 1);
xfer += prot_->writeI64(this->get_intValue());
xfer += prot_->writeFieldEnd();
break;
}
case ComplexUnion::Type::stringValue:
{
xfer += prot_->writeFieldBegin("stringValue", apache::thrift::protocol::T_STRING, 2);
xfer += prot_->writeString(this->get_stringValue());
xfer += prot_->writeFieldEnd();
break;
}
case ComplexUnion::Type::intListValue:
{
xfer += prot_->writeFieldBegin("intListValue", apache::thrift::protocol::T_LIST, 3);
xfer += prot_->writeListBegin(apache::thrift::protocol::T_I64, this->get_intListValue().size());
for (auto _iter14 = this->get_intListValue().begin(); _iter14 != this->get_intListValue().end(); ++_iter14) {
xfer += prot_->writeI64((*_iter14));
}
xfer += prot_->writeListEnd();
xfer += prot_->writeFieldEnd();
break;
}
case ComplexUnion::Type::stringListValue:
{
xfer += prot_->writeFieldBegin("stringListValue", apache::thrift::protocol::T_LIST, 4);
xfer += prot_->writeListBegin(apache::thrift::protocol::T_STRING, this->get_stringListValue().size());
for (auto _iter15 = this->get_stringListValue().begin(); _iter15 != this->get_stringListValue().end(); ++_iter15) {
xfer += prot_->writeString((*_iter15));
}
xfer += prot_->writeListEnd();
xfer += prot_->writeFieldEnd();
break;
}
case ComplexUnion::Type::__EMPTY__:;
}
xfer += prot_->writeFieldStop();
xfer += prot_->writeStructEnd();
return xfer;
}
} // cpp2
namespace apache { namespace thrift {
}} // apache::thrift
namespace cpp2 {
} // cpp2 | 34.059441 | 121 | 0.608048 | [
"vector"
] |
1b35528ff078999b40826c4bae9a01d25765ce7b | 2,695 | hpp | C++ | src/core/headers/LayerVao.hpp | nebular/PixEngine_core | fc5f928641ed8c0d14254fdfc68973b3b144297f | [
"BSD-3-Clause"
] | 1 | 2020-10-23T21:16:49.000Z | 2020-10-23T21:16:49.000Z | template/PixFuTemplate/PixFu.Framework/Versions/A/Headers/core/LayerVao.hpp | nebular/PixFu_macOS | fbe6630fa0bc035a83c4f900e0e7f6006f45da2e | [
"CC-BY-4.0"
] | 2 | 2020-03-02T22:43:09.000Z | 2020-03-02T22:46:44.000Z | src/core/headers/LayerVao.hpp | nebular/PixFu | fc5f928641ed8c0d14254fdfc68973b3b144297f | [
"BSD-3-Clause"
] | null | null | null | //
// Layer.cpp
// PixFu
//
// A VAO Layer, abstracts drawing a mesh from an array of vertexes and indices.
// Vertexes are interleaved <POS - NORM - TEXCOORDS> so it uses only one buffer
// The VAO buffers are constructed by calling the init() method, and from then on
// draw() to draw the mesh.
//
// This class does not know about shaders, derived classes are expected to take care
// of that as needed.
//
// Created by rodo on 11/02/2020.
// Copyright © 2020 rodo. All rights reserved.
//
#pragma clang diagnostic push
#pragma GCC diagnostic ignored "-Wunknown-pragmas"
#pragma ide diagnostic ignored "OCUnusedGlobalDeclarationInspection"
#pragma ide diagnostic ignored "OCUnusedStructInspection"
#pragma once
#include "FuExtension.hpp"
#include <string>
#include <vector>
#include "glm/vec2.hpp"
#include "glm/vec3.hpp"
namespace Pix {
// The Vertex contains the position, the normal and the texture cooordinates
typedef struct Vertex {
glm::vec3 vertice;
glm::vec3 normal = {0, 1, 0};
glm::vec2 tex = {0, 0};
} Vertex_t;
/*
* A VAO Layer, abstracts drawing a mesh from an array of vertexes and indices.
* Vertexes are interleaved <POS - NORM - TEXCOORDS> so it uses only one buffer
* The VAO buffers are constructed by calling the init() method, and from then on
* draw() to draw the mesh.
*/
typedef struct sMesh {
float *pVertices = nullptr;
unsigned nVertices = 0;
unsigned *pIndices = nullptr;
unsigned nIndices = 0;
unsigned vao = (unsigned) -1;
unsigned vbo = (unsigned) -1;
unsigned ebo = (unsigned) -1;
} Mesh_t;
class LayerVao {
static const std::string TAG;
void init(Mesh_t &mesh);
protected:
std::vector<Mesh_t> vMeshes;
/**
* Add a new mesh to render
* @param vertices Vertices, must be PPP/NNN/TT
* @param numvertices Number of vertices
* @param indices Indices
* @param numindices umber of indices.
* @return The mesh ID
*/
unsigned add(float *vertices, unsigned numvertices,
unsigned *indices, unsigned numindices);
/**
* Add a nes mesh to render
* @param vertices Vector of Vertexes
* @param indices Vector of indices
* @return The mesh ID
*/
unsigned add(std::vector<Vertex_t> &vertices, std::vector<unsigned> &indices);
/**
* Binds a mesh for GL-drawing
* @param index The mesh id
*/
void bind(int index = 0);
/**
* Unbinds bound mesh
*/
void unbind();
public:
static GLenum DRAWMODE;
virtual ~LayerVao();
// called by the loop to update the surface
void draw(int index = 0, bool bind = true);
// called by the loop to finish the surface
void deinit();
};
}
#pragma clang diagnostic pop
| 23.434783 | 85 | 0.681633 | [
"mesh",
"render",
"vector"
] |
1b37d5c38b903f0401eebc091e6c7175de6a39ed | 4,573 | cc | C++ | remoting/host/win/rdp_client_unittest.cc | kjthegod/chromium | cf940f7f418436b77e15b1ea23e6fa100ca1c91a | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 1 | 2019-11-28T10:46:52.000Z | 2019-11-28T10:46:52.000Z | remoting/host/win/rdp_client_unittest.cc | kjthegod/chromium | cf940f7f418436b77e15b1ea23e6fa100ca1c91a | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | null | null | null | remoting/host/win/rdp_client_unittest.cc | kjthegod/chromium | cf940f7f418436b77e15b1ea23e6fa100ca1c91a | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 2 | 2015-03-27T11:15:39.000Z | 2016-08-17T14:19:56.000Z | // Copyright (c) 2013 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.
// ATL headers have to go first.
#include <atlbase.h>
#include <atlhost.h>
#include <string>
#include "base/basictypes.h"
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/guid.h"
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
#include "base/win/scoped_com_initializer.h"
#include "remoting/base/auto_thread_task_runner.h"
#include "remoting/host/win/rdp_client.h"
#include "remoting/host/win/wts_terminal_monitor.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gmock_mutant.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h"
using testing::_;
using testing::AtMost;
using testing::InvokeWithoutArgs;
namespace remoting {
namespace {
// Default width and hight of the RDP client window.
const long kDefaultWidth = 1024;
const long kDefaultHeight = 768;
class MockRdpClientEventHandler : public RdpClient::EventHandler {
public:
MockRdpClientEventHandler() {}
virtual ~MockRdpClientEventHandler() {}
MOCK_METHOD0(OnRdpConnected, void());
MOCK_METHOD0(OnRdpClosed, void());
private:
DISALLOW_COPY_AND_ASSIGN(MockRdpClientEventHandler);
};
// a14498c6-7f3b-4e42-9605-6c4a20d53c87
static GUID RdpClientModuleLibid = {
0xa14498c6,
0x7f3b,
0x4e42,
{ 0x96, 0x05, 0x6c, 0x4a, 0x20, 0xd5, 0x3c, 0x87 }
};
class RdpClientModule : public ATL::CAtlModuleT<RdpClientModule> {
public:
RdpClientModule();
virtual ~RdpClientModule();
DECLARE_LIBID(RdpClientModuleLibid)
private:
base::win::ScopedCOMInitializer com_initializer_;
};
RdpClientModule::RdpClientModule() {
AtlAxWinInit();
}
RdpClientModule::~RdpClientModule() {
AtlAxWinTerm();
ATL::_pAtlModule = nullptr;
}
} // namespace
class RdpClientTest : public testing::Test {
public:
RdpClientTest();
virtual ~RdpClientTest();
virtual void SetUp() override;
virtual void TearDown() override;
// Caaled when an RDP connection is established.
void OnRdpConnected();
// Tears down |rdp_client_|.
void CloseRdpClient();
protected:
// The ATL module instance required by the ATL code.
scoped_ptr<RdpClientModule> module_;
// The UI message loop used by RdpClient. The loop is stopped once there is no
// more references to |task_runner_|.
base::MessageLoopForUI message_loop_;
base::RunLoop run_loop_;
scoped_refptr<AutoThreadTaskRunner> task_runner_;
// Mocks RdpClient::EventHandler for testing.
MockRdpClientEventHandler event_handler_;
// Points to the object being tested.
scoped_ptr<RdpClient> rdp_client_;
// Unique terminal identifier passed to RdpClient.
std::string terminal_id_;
};
RdpClientTest::RdpClientTest() {
}
RdpClientTest::~RdpClientTest() {
}
void RdpClientTest::SetUp() {
// Arrange to run |message_loop_| until no components depend on it.
task_runner_ = new AutoThreadTaskRunner(
message_loop_.message_loop_proxy(), run_loop_.QuitClosure());
module_.reset(new RdpClientModule());
}
void RdpClientTest::TearDown() {
EXPECT_TRUE(!rdp_client_);
module_.reset();
}
void RdpClientTest::OnRdpConnected() {
uint32 session_id = WtsTerminalMonitor::LookupSessionId(terminal_id_);
std::string id;
EXPECT_TRUE(WtsTerminalMonitor::LookupTerminalId(session_id, &id));
EXPECT_EQ(id, terminal_id_);
message_loop_.PostTask(FROM_HERE, base::Bind(&RdpClientTest::CloseRdpClient,
base::Unretained(this)));
}
void RdpClientTest::CloseRdpClient() {
EXPECT_TRUE(rdp_client_);
rdp_client_.reset();
}
// Creates a loopback RDP connection.
TEST_F(RdpClientTest, Basic) {
terminal_id_ = base::GenerateGUID();
// An ability to establish a loopback RDP connection depends on many factors
// including OS SKU and having RDP enabled. Accept both successful connection
// and a connection error as a successful outcome.
EXPECT_CALL(event_handler_, OnRdpConnected())
.Times(AtMost(1))
.WillOnce(Invoke(this, &RdpClientTest::OnRdpConnected));
EXPECT_CALL(event_handler_, OnRdpClosed())
.Times(AtMost(1))
.WillOnce(InvokeWithoutArgs(this, &RdpClientTest::CloseRdpClient));
rdp_client_.reset(new RdpClient(
task_runner_, task_runner_,
webrtc::DesktopSize(kDefaultWidth, kDefaultHeight),
terminal_id_, &event_handler_));
task_runner_ = nullptr;
run_loop_.Run();
}
} // namespace remoting
| 26.281609 | 80 | 0.743494 | [
"object"
] |
1b380ac92dddd36c16a564097a3269283bb1bd5e | 3,475 | cpp | C++ | src/gct/pipeline_rasterization_state_create_info.cpp | Fadis/gct | bde211f9336e945e4db21f5abb4ce01dcad78049 | [
"MIT"
] | 1 | 2022-03-03T09:27:09.000Z | 2022-03-03T09:27:09.000Z | src/gct/pipeline_rasterization_state_create_info.cpp | Fadis/gct | bde211f9336e945e4db21f5abb4ce01dcad78049 | [
"MIT"
] | 1 | 2021-12-02T03:45:45.000Z | 2021-12-03T23:44:37.000Z | src/gct/pipeline_rasterization_state_create_info.cpp | Fadis/gct | bde211f9336e945e4db21f5abb4ce01dcad78049 | [
"MIT"
] | null | null | null | #include <gct/shader_module.hpp>
#include <gct/pipeline_rasterization_state_create_info.hpp>
#include <vulkan2json/PipelineRasterizationStateCreateInfo.hpp>
#ifdef VK_EXT_CONSERVATIVE_RASTERIZATION_EXTENSION_NAME
#include <vulkan2json/PipelineRasterizationConservativeStateCreateInfoEXT.hpp>
#endif
#ifdef VK_EXT_DEPTH_CLIP_ENABLE_EXTENSION_NAME
#include <vulkan2json/PipelineRasterizationDepthClipStateCreateInfoEXT.hpp>
#endif
#ifdef VK_EXT_LINE_RASTERIZATION_EXTENSION_NAME
#include <vulkan2json/PipelineRasterizationLineStateCreateInfoEXT.hpp>
#endif
#ifdef VK_EXT_PROVOKING_VERTEX_EXTENSION_NAME
#include <vulkan2json/PipelineRasterizationProvokingVertexStateCreateInfoEXT.hpp>
#endif
#ifdef VK_AMD_RASTERIZATION_ORDER_EXTENSION_NAME
#include <vulkan2json/PipelineRasterizationStateRasterizationOrderAMD.hpp>
#endif
#ifdef VK_EXT_TRANSFORM_FEEDBACK_EXTENSION_NAME
#include <vulkan2json/PipelineRasterizationStateStreamCreateInfoEXT.hpp>
#endif
namespace gct {
void to_json( nlohmann::json &root, const pipeline_rasterization_state_create_info_t &v ) {
root = nlohmann::json::object();
root[ "basic" ] = v.get_basic();
#ifdef VK_EXT_CONSERVATIVE_RASTERIZATION_EXTENSION_NAME
LIBGCT_EXTENSION_TO_JSON( conservative )
#endif
#ifdef VK_EXT_DEPTH_CLIP_ENABLE_EXTENSION_NAME
LIBGCT_EXTENSION_TO_JSON( depth_clip )
#endif
#ifdef VK_EXT_LINE_RASTERIZATION_EXTENSION_NAME
LIBGCT_EXTENSION_TO_JSON( line )
#endif
#ifdef VK_EXT_PROVOKING_VERTEX_EXTENSION_NAME
LIBGCT_EXTENSION_TO_JSON( provoking_vertex )
#endif
#ifdef VK_AMD_RASTERIZATION_ORDER_EXTENSION_NAME
LIBGCT_EXTENSION_TO_JSON( rasterization_order )
#endif
#ifdef VK_EXT_TRANSFORM_FEEDBACK_EXTENSION_NAME
LIBGCT_EXTENSION_TO_JSON( stream )
#endif
}
void from_json( const nlohmann::json &root, pipeline_rasterization_state_create_info_t &v ) {
if( !root.is_object() ) throw incompatible_json( "The JSON is incompatible to pipeline_rasterization_state_create_info_t", __FILE__, __LINE__ );
LIBGCT_EXTENSION_FROM_JSON( basic )
#ifdef VK_EXT_CONSERVATIVE_RASTERIZATION_EXTENSION_NAME
LIBGCT_EXTENSION_FROM_JSON( conservative )
#endif
#ifdef VK_EXT_DEPTH_CLIP_ENABLE_EXTENSION_NAME
LIBGCT_EXTENSION_FROM_JSON( depth_clip )
#endif
#ifdef VK_EXT_LINE_RASTERIZATION_EXTENSION_NAME
LIBGCT_EXTENSION_FROM_JSON( line )
#endif
#ifdef VK_EXT_PROVOKING_VERTEX_EXTENSION_NAME
LIBGCT_EXTENSION_FROM_JSON( provoking_vertex )
#endif
#ifdef VK_AMD_RASTERIZATION_ORDER_EXTENSION_NAME
LIBGCT_EXTENSION_FROM_JSON( rasterization_order )
#endif
#ifdef VK_EXT_TRANSFORM_FEEDBACK_EXTENSION_NAME
LIBGCT_EXTENSION_FROM_JSON( stream )
#endif
}
pipeline_rasterization_state_create_info_t &pipeline_rasterization_state_create_info_t::rebuild_chain() {
LIBGCT_EXTENSION_BEGIN_REBUILD_CHAIN
#ifdef VK_EXT_CONSERVATIVE_RASTERIZATION_EXTENSION_NAME
LIBGCT_EXTENSION_REBUILD_CHAIN( conservative )
#endif
#ifdef VK_EXT_DEPTH_CLIP_ENABLE_EXTENSION_NAME
LIBGCT_EXTENSION_REBUILD_CHAIN( depth_clip )
#endif
#ifdef VK_EXT_LINE_RASTERIZATION_EXTENSION_NAME
LIBGCT_EXTENSION_REBUILD_CHAIN( line )
#endif
#ifdef VK_EXT_PROVOKING_VERTEX_EXTENSION_NAME
LIBGCT_EXTENSION_REBUILD_CHAIN( provoking_vertex )
#endif
#ifdef VK_AMD_RASTERIZATION_ORDER_EXTENSION_NAME
LIBGCT_EXTENSION_REBUILD_CHAIN( rasterization_order )
#endif
#ifdef VK_EXT_TRANSFORM_FEEDBACK_EXTENSION_NAME
LIBGCT_EXTENSION_REBUILD_CHAIN( stream )
#endif
LIBGCT_EXTENSION_END_REBUILD_CHAIN
}
}
| 37.771739 | 148 | 0.856403 | [
"object"
] |
1b38beee06d517670c6c4a1279c3b6164585df2b | 5,647 | hpp | C++ | modules/core/src/MetaObject/signals/TSlot.hpp | dtmoodie/MetaObject | 8238d143d578ff9c0c6506e7e627eca15e42369e | [
"MIT"
] | 2 | 2017-10-26T04:41:49.000Z | 2018-02-09T05:12:19.000Z | modules/core/src/MetaObject/signals/TSlot.hpp | dtmoodie/MetaObject | 8238d143d578ff9c0c6506e7e627eca15e42369e | [
"MIT"
] | null | null | null | modules/core/src/MetaObject/signals/TSlot.hpp | dtmoodie/MetaObject | 8238d143d578ff9c0c6506e7e627eca15e42369e | [
"MIT"
] | 3 | 2017-01-08T21:09:48.000Z | 2018-02-10T04:27:32.000Z | #ifndef MO_SIGNALS_TSLOT_HPP
#define MO_SIGNALS_TSLOT_HPP
#include "ArgumentPack.hpp"
#include "Connection.hpp"
#include "ISlot.hpp"
#include "MetaObject/core/AsyncStream.hpp"
#include "TSignal.hpp"
#include "TSignalRelay.hpp"
#include <ct/bind.hpp>
#include <functional>
namespace mo
{
template <typename Sig>
class TSlot
{
};
template <typename Sig, class Mutex>
class TSignalRelay;
template <typename R, typename... T>
class TSlot<R(T...)> : public std::function<R(T...)>, public ISlot
{
public:
TSlot();
template <class... ARGS>
TSlot(ARGS&&... args);
~TSlot() override;
TSlot& operator=(const std::function<R(T...)>& other);
TSlot& operator=(const TSlot& other);
// R invokeArgpack(const ArgumentPack<T...>&);
std::shared_ptr<Connection> connect(ISignal& sig) override;
std::shared_ptr<Connection> connect(TSignal<R(T...)>& signal);
std::shared_ptr<Connection> connect(std::shared_ptr<ISignalRelay>& relay) override;
std::shared_ptr<Connection> connect(std::shared_ptr<TSignalRelay<R(T...)>>& relay);
bool disconnect(std::weak_ptr<ISignalRelay> relay) override;
void clear() override;
const TypeInfo& getSignature() const override;
operator bool() const;
template <class U, class V>
void bind(R (U::*fptr)(T...), V* ptr)
{
(*this) = ct::variadicBind(fptr, ptr);
}
private:
// template <int... Is>
// R invokeArgpack(const ArgumentPack<T...>& arg_pack, ct::int_sequence<Is...>);
std::vector<std::shared_ptr<TSignalRelay<R(T...)>>> _relays;
};
///////////////////////////////////////////////////////////////////////
/// IMPLEMENTATION
///////////////////////////////////////////////////////////////////////
template <class R, class... T>
TSlot<R(T...)>::TSlot()
{
}
template <class R, class... T>
template <class... ARGS>
TSlot<R(T...)>::TSlot(ARGS&&... args)
: std::function<R(T...)>(std::forward<ARGS>(args)...)
{
}
template <class R, class... T>
TSlot<R(T...)>::~TSlot()
{
clear();
}
template <class R, class... T>
TSlot<R(T...)>& TSlot<R(T...)>::operator=(const std::function<R(T...)>& other)
{
std::function<R(T...)>::operator=(other);
return *this;
}
template <class R, class... T>
TSlot<R(T...)>& TSlot<R(T...)>::operator=(const TSlot<R(T...)>& other)
{
this->_relays = other._relays;
return *this;
}
/*template <class R, class... T>
R TSlot<R(T...)>::invokeArgpack(const ArgumentPack<T...>& arg_pack)
{
return invokeArgpack(arg_pack, ct::make_int_sequence<sizeof...(T)>{});
}
template <class R, class... T>
template <int... Is>
R TSlot<R(T...)>::invokeArgpack(const ArgumentPack<T...>& arg_pack, ct::int_sequence<Is...>)
{
return (*this)(std::get<Is>(arg_pack.data)...);
}*/
template <class R, class... T>
std::shared_ptr<Connection> TSlot<R(T...)>::connect(ISignal& sig)
{
auto typed = dynamic_cast<TSignal<R(T...)>*>(&sig);
if (typed)
{
return connect(*typed);
}
return std::shared_ptr<Connection>();
}
template <class R, class... T>
std::shared_ptr<Connection> TSlot<R(T...)>::connect(TSignal<R(T...)>& typed)
{
std::shared_ptr<TSignalRelay<R(T...)>> relay(new TSignalRelay<R(T...)>());
relay->connect(*this);
typed.connect(relay);
_relays.push_back(relay);
return std::shared_ptr<Connection>(new SlotConnection(this, relay));
}
template <class R, class... T>
std::shared_ptr<Connection> TSlot<R(T...)>::connect(std::shared_ptr<TSignalRelay<R(T...)>>& relay)
{
relay->connect(*this);
_relays.push_back(relay);
return std::shared_ptr<Connection>(new SlotConnection(this, std::dynamic_pointer_cast<ISignalRelay>(relay)));
}
template <class R, class... T>
std::shared_ptr<Connection> TSlot<R(T...)>::connect(std::shared_ptr<ISignalRelay>& relay)
{
if (relay == nullptr)
{
relay.reset(new TSignalRelay<R(T...)>());
}
auto typed = std::dynamic_pointer_cast<TSignalRelay<R(T...)>>(relay);
if (typed)
{
_relays.push_back(typed);
if (relay->connect(*this))
{
return std::shared_ptr<Connection>(new SlotConnection(this, relay));
}
}
return std::shared_ptr<Connection>();
}
template <class R, class... T>
bool TSlot<R(T...)>::disconnect(std::weak_ptr<ISignalRelay> relay_)
{
auto relay = relay_.lock();
for (auto itr = _relays.begin(); itr != _relays.end(); ++itr)
{
if ((*itr) == relay)
{
(*itr)->disconnect(*this);
_relays.erase(itr);
return true;
}
}
return false;
}
template <class R, class... T>
void TSlot<R(T...)>::clear()
{
for (auto& relay : _relays)
{
relay->disconnect(*this);
}
}
template <class R, class... T>
const TypeInfo& TSlot<R(T...)>::getSignature() const
{
static TypeInfo type = TypeInfo::create<R(T...)>();
return type;
}
template <class R, class... T>
TSlot<R(T...)>::operator bool() const
{
return std::function<R(T...)>::operator bool();
}
} // namespace mo
#endif // MO_SIGNALS_TSLOT_HPP | 29.259067 | 117 | 0.538693 | [
"vector"
] |
1b3ccf00d5a3211cbfb4c58f922e86b73c817371 | 1,826 | cpp | C++ | xmlparser/xmlparser.cpp | ale-tachibana/XMLBUMPARSER | 3fb400e553998d854f457521b9f4dde04fbdb4f0 | [
"MIT"
] | null | null | null | xmlparser/xmlparser.cpp | ale-tachibana/XMLBUMPARSER | 3fb400e553998d854f457521b9f4dde04fbdb4f0 | [
"MIT"
] | null | null | null | xmlparser/xmlparser.cpp | ale-tachibana/XMLBUMPARSER | 3fb400e553998d854f457521b9f4dde04fbdb4f0 | [
"MIT"
] | null | null | null | #include "stdafx.h"
#include "xml_main.hpp"
#include <string>
#include <iostream>
#include "txtsample.h"
int _tmain(int argc, _TCHAR* argv[])
{
//sample how to use
xmlbum::xml_parser xml;
std::string string_teste;
int teste;
//can load from file path
std::string filepath = "../skinned_mesh.dae";
std::shared_ptr<xmlbum::xml_item> item = xml.parse_file(filepath);
//can also load from a string
//std::shared_ptr<xmlbum::xml_item> item = xml.parse_string(xmlsample);
//get subitem, exact string
std::shared_ptr<xmlbum::xml_item> item2 = item->GetItem("COLLADA")->GetItem("library_geometries")->GetItem("geometry")->GetItem("mesh")->GetItem("source")->GetItem("float_array");
std::cout << item2->value() << "\n";
//get same object as item2 from root
std::shared_ptr<xmlbum::xml_item> item3 = item2->root()->GetItem("COLLADA")->GetItem("library_geometries")->GetItem("geometry")->GetItem("mesh")->GetItem("source")->GetItem("float_array");
std::cout << item3->tag() << "\n";
//search subitems, regex
std::vector<std::shared_ptr<xmlbum::xml_item>> items4 = item->SearchItems("", "geom");
for (std::shared_ptr<xmlbum::xml_item> it : items4) {
std::cout << "found " << it->tag() << "\n";
}
//search subitems, exact tag
std::vector<std::shared_ptr<xmlbum::xml_item>> items5 = item->SearchItems("float_array","");
for (std::shared_ptr<xmlbum::xml_item> it : items5)
std::cout << "found " << it->tag() << "\n";
//get attibutes
std::vector<std::shared_ptr<xmlbum::xml_item>> items6 = item->SearchItems("technique", "");
for (std::shared_ptr<xmlbum::xml_item> it : items6) {
std::cout << "profile: " << it->GetAttribute("profile") << "\n";
std::cout << "sid: " << it->GetAttribute("sid") << "\n";
}
return 0;
}
| 32.035088 | 190 | 0.638554 | [
"mesh",
"geometry",
"object",
"vector"
] |
1b3e49c433dee3248d9d35946461b3a9232ff939 | 1,823 | cpp | C++ | CesiumGltfWriter/src/AccessorWriter.cpp | zy6p/cesium-native | d7b02d0c229e54e626e313bf2cfab31ed6e8ac3b | [
"Apache-2.0"
] | null | null | null | CesiumGltfWriter/src/AccessorWriter.cpp | zy6p/cesium-native | d7b02d0c229e54e626e313bf2cfab31ed6e8ac3b | [
"Apache-2.0"
] | null | null | null | CesiumGltfWriter/src/AccessorWriter.cpp | zy6p/cesium-native | d7b02d0c229e54e626e313bf2cfab31ed6e8ac3b | [
"Apache-2.0"
] | null | null | null | #include "AccessorWriter.h"
#include "AccessorSparseWriter.h"
#include "ExtensionWriter.h"
#include "JsonObjectWriter.h"
#include <magic_enum.hpp>
#include <stdexcept>
#include <type_traits>
void CesiumGltf::writeAccessor(
const std::vector<Accessor>& accessors,
CesiumGltf::JsonWriter& jsonWriter) {
if (accessors.empty()) {
return;
}
auto& j = jsonWriter;
j.Key("accessors");
j.StartArray();
for (const auto& accessor : accessors) {
j.StartObject();
if (accessor.bufferView >= 0) {
j.Key("bufferView");
j.Int(accessor.bufferView);
}
if (accessor.byteOffset >= 0) {
j.Key("byteOffset");
j.Int64(accessor.byteOffset);
}
j.Key("componentType");
j.Int(magic_enum::enum_integer(accessor.componentType));
if (accessor.normalized) {
j.Key("normalized");
j.Bool(accessor.normalized);
}
j.Key("count");
j.Int64(accessor.count);
j.Key("type");
j.String(magic_enum::enum_name(accessor.type));
if (!accessor.max.empty()) {
j.Key("max");
j.StartArray();
for (const auto channelMax : accessor.max) {
j.Double(channelMax);
}
j.EndArray();
}
if (!accessor.min.empty()) {
j.Key("min");
j.StartArray();
for (const auto channelMin : accessor.min) {
j.Double(channelMin);
}
j.EndArray();
}
if (accessor.sparse) {
writeAccessorSparse(*accessor.sparse, jsonWriter);
}
if (!accessor.name.empty()) {
j.Key("name");
j.String(accessor.name.c_str());
}
if (!accessor.extensions.empty()) {
writeExtensions(accessor.extensions, j);
}
if (!accessor.extras.empty()) {
j.Key("extras");
writeJsonValue(accessor.extras, j);
}
j.EndObject();
}
j.EndArray();
}
| 20.954023 | 60 | 0.597916 | [
"vector"
] |
1b3ef8f35ee8650620743461c471d7ec4bfd2e44 | 5,266 | cpp | C++ | simulator/simulator.cpp | leandrohw/et2-simulator | ed87e38f1b62ab7e1a7bc684da3364d1154b5878 | [
"Apache-2.0"
] | null | null | null | simulator/simulator.cpp | leandrohw/et2-simulator | ed87e38f1b62ab7e1a7bc684da3364d1154b5878 | [
"Apache-2.0"
] | 11 | 2018-04-10T02:46:30.000Z | 2018-04-24T18:12:58.000Z | simulator/simulator.cpp | leandrohw/et2-simulator | ed87e38f1b62ab7e1a7bc684da3364d1154b5878 | [
"Apache-2.0"
] | null | null | null | #include "simulator/simulator.h"
#include "absl/strings/str_join.h"
#include "absl/strings/str_split.h"
#include "absl/strings/numbers.h"
#include "glog/logging.h"
namespace et_simulator {
bool Simulator::ParseObjectAllocation(std::vector<std::string> trace) {
if (trace.size() != 5) {
return false;
}
std::string type = trace[3];
int object_id;
int size;
int thread_id;
if (absl::SimpleAtoi(trace[1], &object_id) &&
absl::SimpleAtoi(trace[2], &size) &&
absl::SimpleAtoi(trace[4], &thread_id)) {
tree_->HandleObjectAllocation(object_id, size,
type, thread_id);
return true;
}
return false;
}
bool Simulator::ParseObjectUpdate(std::vector<std::string> trace) {
if (trace.size() != 5) {
return false;
}
int old_target;
int object_id;
int new_target;
int thread_id;
if (absl::SimpleAtoi(trace[1], &old_target) &&
absl::SimpleAtoi(trace[2], &object_id) &&
absl::SimpleAtoi(trace[3], &new_target) &&
absl::SimpleAtoi(trace[4], &thread_id)) {
tree_->HandleObjectUpdate(old_target, object_id,
new_target, thread_id);
return true;
}
return false;
}
bool Simulator::ParseMethodEntry(std::vector<std::string> trace) {
if (trace.size() != 4) {
return false;
}
int method_id;
int object_id;
int thread_id;
if (absl::SimpleAtoi(trace[1], &method_id)&&
absl::SimpleAtoi(trace[2], &object_id) &&
absl::SimpleAtoi(trace[3], &thread_id)) {
tree_->HandleMethodEntry(method_id, object_id, thread_id);
return true;
}
return false;
}
bool Simulator::ParseMethodExit(std::vector<std::string> trace) {
if (trace.size() != 4) {
return false;
}
int method_id;
int object_id;
int thread_id;
if (absl::SimpleAtoi(trace[1], &method_id)&&
absl::SimpleAtoi(trace[2], &object_id) &&
absl::SimpleAtoi(trace[3], &thread_id)){
tree_->HandleMethodExit(method_id, object_id, thread_id);
return true;
}
return false;
}
bool Simulator::Execute(std::string line) {
std::vector<std::string> trace = absl::StrSplit(line, ' ');
if (trace.size() < 1 || trace[0].length() != 1) {
return false;
}
char kind = trace[0][0];
switch (kind) {
case 'A':
return ParseObjectAllocation(trace);
case 'U':
return ParseObjectUpdate(trace);
case 'M':
return ParseMethodEntry(trace);
case 'E':
return ParseMethodExit(trace);
case 'R':
// -- Throw out roots for now
return true;
default:
LOG(INFO) << "UNKNOWN";
}
return false;
}
void Simulator::ReadTraceFile() {
std::string line;
int64_t record_count = 0;
std::ifstream in;
in.open(trace_file_);
if (!trace_file_.empty()) {
std::ifstream in;
in.open(trace_file_);
if (in.fail()) {
LOG(FATAL) << "Failed to open name file " << trace_file_;
}
while (!in.eof()) {
LOG_EVERY_N(INFO, 1000000) << "At " << record_count;
getline(in, line);
if (!Execute(line)) {
LOG(FATAL) << "Parsing event " << line << " failed.";
}
record_count++;
}
} else {
LOG(INFO) << "Traces file was not specified.";
}
}
// void Simulator::ReadNameFile()
// {
// char kind;
// int method_id;
// std::string class_name;
// std::string method_name;
// std::string signature;
// int class_id;
// int super_id;
// char inher;
// char flag;
// int field_id;
// std::string field_name;
// std::string type;
// std::ifstream name_file;
// name_file.open(name_file_);
//
// if (name_file.fail()) {
// std::cout << "Failed to open name file " << name_file_ << std::endl;
// exit(EXIT_FAILURE);
// }
//
// while (!name_file.eof()) {
//
// name_file >> kind;
//
// switch (kind) {
// case 'N':
// {
// name_file >> std::hex >> method_id;
// name_file >> class_name;
// name_file >> method_name;
// name_file >> signature;
// Method * method = new Method(method_id, class_name,
// method_name, signature);
// if (class_name == "java/lang/Thread" && method_name == "start") {
// thread_start_method_id = method_id;
// }
// }
// break;
//
// case 'C':
// name_file >> std::hex >> class_id;
// name_file >> class_name;
// name_file >> std::hex >> super_id;
// name_file >> inher;
// break;
//
// case 'F':
// name_file >> flag;
// name_file >> std::hex >> field_id;
// name_file >> field_name;
// name_file >> std::hex >> class_id;
// name_file >> class_name;
// name_file >> type;
// break;
//
// case 'I':
// name_file >> std::hex >> class_id;
// name_file >> class_name;
// break;
//
// case 'E':
// name_file >> std::hex >> class_id;
// name_file >> class_name;
// break;
// }
// }
// }
void Simulator::Simulate() {
ReadTraceFile();
Report();
}
void Simulator::Report() {
// TODO(leandrohw): decide how to output data
}
} // namespace et_simulator
| 23.508929 | 78 | 0.562096 | [
"vector"
] |
1b4047b1ccbd20421c5179c743db886d06399255 | 2,939 | cpp | C++ | GLEssentials/Source/Classes/glviewshape.cpp | mrtrizer/iOSGLES2 | 39a48c5be370f7b37bae908126cc61366882188f | [
"AML"
] | null | null | null | GLEssentials/Source/Classes/glviewshape.cpp | mrtrizer/iOSGLES2 | 39a48c5be370f7b37bae908126cc61366882188f | [
"AML"
] | null | null | null | GLEssentials/Source/Classes/glviewshape.cpp | mrtrizer/iOSGLES2 | 39a48c5be370f7b37bae908126cc61366882188f | [
"AML"
] | null | null | null | #include "glm/gtc/type_ptr.hpp"
#include "glviewshape.h"
static const char shapeVShader[] =
"attribute vec2 aPosition;\n"
"uniform mat4 uMVMatrix;\n"
"uniform mat4 uPMatrix;\n"
"varying vec4 vColor;\n"
"void main() {\n"
" gl_Position = uPMatrix * uMVMatrix * vec4(aPosition,0,1);\n"
"}\n";
static const char shapeFShader[] =
//#if defined(GL_ES) || defined(EMSCRIPTEN)
"precision mediump float;\n"
//#endif
"uniform vec4 uColor;\n"
"void main() {\n"
" gl_FragColor = uColor;\n"
"}\n";
GLViewShape::GLViewShape() :
GLView(shapeVShader, shapeFShader),
colorRGBA({1.0f, 0.0f, 0.0f, 1.0f}){
}
/// Generates vertices for circle drawing in GL_TRIANGLE_FAN format
/// @param count Count of vertices ( >= 3).
std::vector<GLTools::Vertex> GViewCircle::circleTriangleFan(float r, int count) {
if (count < 3)
throw std::runtime_error("Too few vertices in circle (has to be >= 3).");
std::vector<GLTools::Vertex> vertexList(count + 2);
float step = M_PI * 2 / count;
vertexList[0] = GLTools::Vertex({0,0});
for (int i = 0; i < count + 1; i++)
vertexList[i + 1] = {std::cos(step * i) * r, std::sin(step * i) * r};
return vertexList;
}
void GLViewShape::draw(const glm::mat4 &pMartrix, const glm::mat4 &mvMatrix) {
getShader()->render(getAttribArray(), [this, mvMatrix, pMartrix](){
glUniformMatrix4fv(getShader()->findUniform("uMVMatrix"),1,false,glm::value_ptr(mvMatrix));
glUniformMatrix4fv(getShader()->findUniform("uPMatrix"),1,false,glm::value_ptr(pMartrix));
glUniform4fv(getShader()->findUniform("uColor"),1, reinterpret_cast<GLfloat *>(&colorRGBA));
});
}
GViewCircle::GViewCircle(int vertexCnt, double r):
vertexCnt(vertexCnt),
circle(GL_TRIANGLE_FAN){
std::vector<GLTools::Vertex> vertexList = circleTriangleFan(r,vertexCnt);
circle.addVBO<GLTools::Vertex>(vertexList.data(), //data array
vertexList.size() * sizeof(GLTools::Vertex), //size
GL_FLOAT, //item format
getShader()->findAttr("aPosition") //attribute id
);
}
GViewRect::GViewRect(float width, float height):
rect(GL_TRIANGLE_STRIP){
std::vector<GLTools::Vertex> vertexList({
{0,0},
{0,height},
{width,0},
{width,height}
});
rect.addVBO<GLTools::Vertex>(vertexList.data(),
vertexList.size() * sizeof(GLTools::Vertex),
GL_FLOAT,
getShader()->findAttr("aPosition"));
}
| 39.716216 | 100 | 0.541681 | [
"render",
"vector"
] |
1b408c6323b70693a36a32d7fd08adec1f3cb5a9 | 392,817 | cpp | C++ | esp32_wifi_microphone_a1s_aac/lib/fdk-aac/src/libFDK/FDK_tools_rom.cpp | vernonet/ESP32_PRJ | 52a3ba27cb5c3044bfc75bfc6650404981fb59ee | [
"Unlicense"
] | 1 | 2021-11-13T20:53:32.000Z | 2021-11-13T20:53:32.000Z | esp32_wifi_microphone_a1s_aac_async/lib/fdk-aac/src/libFDK/FDK_tools_rom.cpp | vernonet/ESP32_PRJ | 52a3ba27cb5c3044bfc75bfc6650404981fb59ee | [
"Unlicense"
] | null | null | null | esp32_wifi_microphone_a1s_aac_async/lib/fdk-aac/src/libFDK/FDK_tools_rom.cpp | vernonet/ESP32_PRJ | 52a3ba27cb5c3044bfc75bfc6650404981fb59ee | [
"Unlicense"
] | 1 | 2021-11-15T13:12:59.000Z | 2021-11-15T13:12:59.000Z | /* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V. All rights reserved.
1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
scheme for digital audio. This FDK AAC Codec software is intended to be used on
a wide variety of Android devices.
AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
general perceptual audio codecs. AAC-ELD is considered the best-performing
full-bandwidth communications codec by independent studies and is widely
deployed. AAC has been standardized by ISO and IEC as part of the MPEG
specifications.
Patent licenses for necessary patent claims for the FDK AAC Codec (including
those of Fraunhofer) may be obtained through Via Licensing
(www.vialicensing.com) or through the respective patent owners individually for
the purpose of encoding or decoding bit streams in products that are compliant
with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
Android devices already license these patent claims through Via Licensing or
directly from the patent owners, and therefore FDK AAC Codec software may
already be covered under those patent licenses when it is used for those
licensed purposes only.
Commercially-licensed AAC software libraries, including floating-point versions
with enhanced sound quality, are also available from Fraunhofer. Users are
encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification,
are permitted without payment of copyright license fees provided that you
satisfy the following conditions:
You must retain the complete text of this software license in redistributions of
the FDK AAC Codec or your modifications thereto in source code form.
You must retain the complete text of this software license in the documentation
and/or other materials provided with redistributions of the FDK AAC Codec or
your modifications thereto in binary form. You must make available free of
charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
The name of Fraunhofer may not be used to endorse or promote products derived
from this library without prior written permission.
You may not charge copyright license fees for anyone to use, copy or distribute
the FDK AAC Codec software or your modifications thereto.
Your modified versions of the FDK AAC Codec must carry prominent notices stating
that you changed the software and the date of any change. For modified versions
of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
AAC Codec Library for Android."
3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
Fraunhofer provides no warranty of patent non-infringement with respect to this
software.
You may use this FDK AAC Codec software or modifications thereto only for
purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
including but not limited to the implied warranties of merchantability and
fitness for a particular purpose. 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), arising in any way out of the use of
this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
Fraunhofer Institute for Integrated Circuits IIS
Attention: Audio and Multimedia Departments - FDK AAC LL
Am Wolfsmantel 33
91058 Erlangen, Germany
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------- */
/******************* Library for basic calculation routines ********************
Author(s): Oliver Moser
Description: ROM tables used by FDK tools
*******************************************************************************/
#include "libFDK/FDK_tools_rom.h"
RAM_ALIGN
LNK_SECTION_CONSTDATA
const FIXP_STP SineTable80[] = {
STCP(0x7fffffff, 0x00000000), STCP(0x7ff9af04, 0x02835b5a),
STCP(0x7fe6bcb0, 0x05067734), STCP(0x7fc72ae2, 0x07891418),
STCP(0x7f9afcb9, 0x0a0af299), STCP(0x7f62368f, 0x0c8bd35e),
STCP(0x7f1cde01, 0x0f0b7727), STCP(0x7ecaf9e5, 0x11899ed3),
STCP(0x7e6c9251, 0x14060b68), STCP(0x7e01b096, 0x16807e15),
STCP(0x7d8a5f40, 0x18f8b83c), STCP(0x7d06aa16, 0x1b6e7b7a),
STCP(0x7c769e18, 0x1de189a6), STCP(0x7bda497d, 0x2051a4dd),
STCP(0x7b31bbb2, 0x22be8f87), STCP(0x7a7d055b, 0x25280c5e),
STCP(0x79bc384d, 0x278dde6e), STCP(0x78ef678f, 0x29efc925),
STCP(0x7816a759, 0x2c4d9050), STCP(0x77320d0d, 0x2ea6f827),
STCP(0x7641af3d, 0x30fbc54d), STCP(0x7545a5a0, 0x334bbcde),
STCP(0x743e0918, 0x3596a46c), STCP(0x732af3a7, 0x37dc420c),
STCP(0x720c8075, 0x3a1c5c57), STCP(0x70e2cbc6, 0x3c56ba70),
STCP(0x6fadf2fc, 0x3e8b240e), STCP(0x6e6e1492, 0x40b9617d),
STCP(0x6d23501b, 0x42e13ba4), STCP(0x6bcdc639, 0x45027c0c),
STCP(0x6a6d98a4, 0x471cece7), STCP(0x6902ea1d, 0x4930590f),
STCP(0x678dde6e, 0x4b3c8c12), STCP(0x660e9a6a, 0x4d415234),
STCP(0x648543e4, 0x4f3e7875), STCP(0x62f201ac, 0x5133cc94),
STCP(0x6154fb91, 0x53211d18), STCP(0x5fae5a55, 0x55063951),
STCP(0x5dfe47ad, 0x56e2f15d), STCP(0x5c44ee40, 0x58b71632),
STCP(0x5a82799a, 0x5a82799a),
};
RAM_ALIGN
LNK_SECTION_CONSTDATA
const FIXP_STP SineTable384[] = {
STCP(0x7fffffff, 0x00000000), STCP(0x7fffb9d1, 0x00860a79),
STCP(0x7ffee744, 0x010c1460), STCP(0x7ffd885a, 0x01921d20),
STCP(0x7ffb9d15, 0x02182427), STCP(0x7ff92577, 0x029e28e2),
STCP(0x7ff62182, 0x03242abf), STCP(0x7ff2913a, 0x03aa292a),
STCP(0x7fee74a2, 0x0430238f), STCP(0x7fe9cbc0, 0x04b6195d),
STCP(0x7fe49698, 0x053c0a01), STCP(0x7fded530, 0x05c1f4e7),
STCP(0x7fd8878e, 0x0647d97c), STCP(0x7fd1adb9, 0x06cdb72f),
STCP(0x7fca47b9, 0x07538d6b), STCP(0x7fc25596, 0x07d95b9e),
STCP(0x7fb9d759, 0x085f2137), STCP(0x7fb0cd0a, 0x08e4dda0),
STCP(0x7fa736b4, 0x096a9049), STCP(0x7f9d1461, 0x09f0389f),
STCP(0x7f92661d, 0x0a75d60e), STCP(0x7f872bf3, 0x0afb6805),
STCP(0x7f7b65ef, 0x0b80edf1), STCP(0x7f6f141f, 0x0c066740),
STCP(0x7f62368f, 0x0c8bd35e), STCP(0x7f54cd4f, 0x0d1131ba),
STCP(0x7f46d86c, 0x0d9681c2), STCP(0x7f3857f6, 0x0e1bc2e4),
STCP(0x7f294bfd, 0x0ea0f48c), STCP(0x7f19b491, 0x0f26162a),
STCP(0x7f0991c4, 0x0fab272b), STCP(0x7ef8e3a6, 0x103026fe),
STCP(0x7ee7aa4c, 0x10b5150f), STCP(0x7ed5e5c6, 0x1139f0cf),
STCP(0x7ec3962a, 0x11beb9aa), STCP(0x7eb0bb8a, 0x12436f10),
STCP(0x7e9d55fc, 0x12c8106f), STCP(0x7e896595, 0x134c9d34),
STCP(0x7e74ea6a, 0x13d114d0), STCP(0x7e5fe493, 0x145576b1),
STCP(0x7e4a5426, 0x14d9c245), STCP(0x7e34393b, 0x155df6fc),
STCP(0x7e1d93ea, 0x15e21445), STCP(0x7e06644c, 0x1666198d),
STCP(0x7deeaa7a, 0x16ea0646), STCP(0x7dd6668f, 0x176dd9de),
STCP(0x7dbd98a4, 0x17f193c5), STCP(0x7da440d6, 0x1875336a),
STCP(0x7d8a5f40, 0x18f8b83c), STCP(0x7d6ff3fe, 0x197c21ad),
STCP(0x7d54ff2e, 0x19ff6f2a), STCP(0x7d3980ec, 0x1a82a026),
STCP(0x7d1d7958, 0x1b05b40f), STCP(0x7d00e88f, 0x1b88aa55),
STCP(0x7ce3ceb2, 0x1c0b826a), STCP(0x7cc62bdf, 0x1c8e3bbe),
STCP(0x7ca80038, 0x1d10d5c2), STCP(0x7c894bde, 0x1d934fe5),
STCP(0x7c6a0ef2, 0x1e15a99a), STCP(0x7c4a4996, 0x1e97e251),
STCP(0x7c29fbee, 0x1f19f97b), STCP(0x7c09261d, 0x1f9bee8a),
STCP(0x7be7c847, 0x201dc0ef), STCP(0x7bc5e290, 0x209f701c),
STCP(0x7ba3751d, 0x2120fb83), STCP(0x7b808015, 0x21a26295),
STCP(0x7b5d039e, 0x2223a4c5), STCP(0x7b38ffde, 0x22a4c185),
STCP(0x7b1474fd, 0x2325b847), STCP(0x7aef6323, 0x23a6887f),
STCP(0x7ac9ca7a, 0x2427319d), STCP(0x7aa3ab29, 0x24a7b317),
STCP(0x7a7d055b, 0x25280c5e), STCP(0x7a55d93a, 0x25a83ce6),
STCP(0x7a2e26f2, 0x26284422), STCP(0x7a05eead, 0x26a82186),
STCP(0x79dd3098, 0x2727d486), STCP(0x79b3ece0, 0x27a75c95),
STCP(0x798a23b1, 0x2826b928), STCP(0x795fd53a, 0x28a5e9b4),
STCP(0x793501a9, 0x2924edac), STCP(0x7909a92d, 0x29a3c485),
STCP(0x78ddcbf5, 0x2a226db5), STCP(0x78b16a32, 0x2aa0e8b0),
STCP(0x78848414, 0x2b1f34eb), STCP(0x785719cc, 0x2b9d51dd),
STCP(0x78292b8d, 0x2c1b3efb), STCP(0x77fab989, 0x2c98fbba),
STCP(0x77cbc3f2, 0x2d168792), STCP(0x779c4afc, 0x2d93e1f8),
STCP(0x776c4edb, 0x2e110a62), STCP(0x773bcfc4, 0x2e8e0048),
STCP(0x770acdec, 0x2f0ac320), STCP(0x76d94989, 0x2f875262),
STCP(0x76a742d1, 0x3003ad85), STCP(0x7674b9fa, 0x307fd401),
STCP(0x7641af3d, 0x30fbc54d), STCP(0x760e22d1, 0x317780e2),
STCP(0x75da14ef, 0x31f30638), STCP(0x75a585cf, 0x326e54c7),
STCP(0x757075ac, 0x32e96c09), STCP(0x753ae4c0, 0x33644b76),
STCP(0x7504d345, 0x33def287), STCP(0x74ce4177, 0x345960b7),
STCP(0x74972f92, 0x34d3957e), STCP(0x745f9dd1, 0x354d9057),
STCP(0x74278c72, 0x35c750bc), STCP(0x73eefbb3, 0x3640d627),
STCP(0x73b5ebd1, 0x36ba2014), STCP(0x737c5d0b, 0x37332dfd),
STCP(0x73424fa0, 0x37abff5d), STCP(0x7307c3d0, 0x382493b0),
STCP(0x72ccb9db, 0x389cea72), STCP(0x72913201, 0x3915031f),
STCP(0x72552c85, 0x398cdd32), STCP(0x7218a9a7, 0x3a04782a),
STCP(0x71dba9ab, 0x3a7bd382), STCP(0x719e2cd2, 0x3af2eeb7),
STCP(0x71603361, 0x3b69c947), STCP(0x7121bd9c, 0x3be062b0),
STCP(0x70e2cbc6, 0x3c56ba70), STCP(0x70a35e25, 0x3cccd004),
STCP(0x706374ff, 0x3d42a2ec), STCP(0x7023109a, 0x3db832a6),
STCP(0x6fe2313c, 0x3e2d7eb1), STCP(0x6fa0d72c, 0x3ea2868c),
STCP(0x6f5f02b2, 0x3f1749b8), STCP(0x6f1cb416, 0x3f8bc7b4),
STCP(0x6ed9eba1, 0x40000000), STCP(0x6e96a99d, 0x4073f21d),
STCP(0x6e52ee52, 0x40e79d8c), STCP(0x6e0eba0c, 0x415b01ce),
STCP(0x6dca0d14, 0x41ce1e65), STCP(0x6d84e7b7, 0x4240f2d1),
STCP(0x6d3f4a40, 0x42b37e96), STCP(0x6cf934fc, 0x4325c135),
STCP(0x6cb2a837, 0x4397ba32), STCP(0x6c6ba43e, 0x44096910),
STCP(0x6c242960, 0x447acd50), STCP(0x6bdc37eb, 0x44ebe679),
STCP(0x6b93d02e, 0x455cb40c), STCP(0x6b4af279, 0x45cd358f),
STCP(0x6b019f1a, 0x463d6a87), STCP(0x6ab7d663, 0x46ad5278),
STCP(0x6a6d98a4, 0x471cece7), STCP(0x6a22e630, 0x478c395a),
STCP(0x69d7bf57, 0x47fb3757), STCP(0x698c246c, 0x4869e665),
STCP(0x694015c3, 0x48d84609), STCP(0x68f393ae, 0x494655cc),
STCP(0x68a69e81, 0x49b41533), STCP(0x68593691, 0x4a2183c8),
STCP(0x680b5c33, 0x4a8ea111), STCP(0x67bd0fbd, 0x4afb6c98),
STCP(0x676e5183, 0x4b67e5e4), STCP(0x671f21dc, 0x4bd40c80),
STCP(0x66cf8120, 0x4c3fdff4), STCP(0x667f6fa5, 0x4cab5fc9),
STCP(0x662eedc3, 0x4d168b8b), STCP(0x65ddfbd3, 0x4d8162c4),
STCP(0x658c9a2d, 0x4debe4fe), STCP(0x653ac92b, 0x4e5611c5),
STCP(0x64e88926, 0x4ebfe8a5), STCP(0x6495da79, 0x4f296928),
STCP(0x6442bd7e, 0x4f9292dc), STCP(0x63ef3290, 0x4ffb654d),
STCP(0x639b3a0b, 0x5063e008), STCP(0x6346d44b, 0x50cc029c),
STCP(0x62f201ac, 0x5133cc94), STCP(0x629cc28c, 0x519b3d80),
STCP(0x62471749, 0x520254ef), STCP(0x61f1003f, 0x5269126e),
STCP(0x619a7dce, 0x52cf758f), STCP(0x61439053, 0x53357ddf),
STCP(0x60ec3830, 0x539b2af0), STCP(0x609475c3, 0x54007c51),
STCP(0x603c496c, 0x54657194), STCP(0x5fe3b38d, 0x54ca0a4b),
STCP(0x5f8ab487, 0x552e4605), STCP(0x5f314cba, 0x55922457),
STCP(0x5ed77c8a, 0x55f5a4d2), STCP(0x5e7d4458, 0x5658c709),
STCP(0x5e22a487, 0x56bb8a90), STCP(0x5dc79d7c, 0x571deefa),
STCP(0x5d6c2f99, 0x577ff3da), STCP(0x5d105b44, 0x57e198c7),
STCP(0x5cb420e0, 0x5842dd54), STCP(0x5c5780d3, 0x58a3c118),
STCP(0x5bfa7b82, 0x590443a7), STCP(0x5b9d1154, 0x59646498),
STCP(0x5b3f42ae, 0x59c42381), STCP(0x5ae10ff9, 0x5a237ffa),
STCP(0x5a82799a, 0x5a82799a),
};
RAM_ALIGN
LNK_SECTION_CONSTDATA
const FIXP_STP SineTable480[] = {
STCP(0x7fffffff, 0x00000000), STCP(0x7fffd315, 0x006b3b9b),
STCP(0x7fff4c54, 0x00d676eb), STCP(0x7ffe6bbf, 0x0141b1a5),
STCP(0x7ffd3154, 0x01aceb7c), STCP(0x7ffb9d15, 0x02182427),
STCP(0x7ff9af04, 0x02835b5a), STCP(0x7ff76721, 0x02ee90c8),
STCP(0x7ff4c56f, 0x0359c428), STCP(0x7ff1c9ef, 0x03c4f52f),
STCP(0x7fee74a2, 0x0430238f), STCP(0x7feac58d, 0x049b4f00),
STCP(0x7fe6bcb0, 0x05067734), STCP(0x7fe25a0f, 0x05719be2),
STCP(0x7fdd9dad, 0x05dcbcbe), STCP(0x7fd8878e, 0x0647d97c),
STCP(0x7fd317b4, 0x06b2f1d2), STCP(0x7fcd4e24, 0x071e0575),
STCP(0x7fc72ae2, 0x07891418), STCP(0x7fc0adf2, 0x07f41d72),
STCP(0x7fb9d759, 0x085f2137), STCP(0x7fb2a71b, 0x08ca1f1b),
STCP(0x7fab1d3d, 0x093516d4), STCP(0x7fa339c5, 0x09a00817),
STCP(0x7f9afcb9, 0x0a0af299), STCP(0x7f92661d, 0x0a75d60e),
STCP(0x7f8975f9, 0x0ae0b22c), STCP(0x7f802c52, 0x0b4b86a8),
STCP(0x7f76892f, 0x0bb65336), STCP(0x7f6c8c96, 0x0c21178c),
STCP(0x7f62368f, 0x0c8bd35e), STCP(0x7f578721, 0x0cf68662),
STCP(0x7f4c7e54, 0x0d61304e), STCP(0x7f411c2f, 0x0dcbd0d5),
STCP(0x7f3560b9, 0x0e3667ad), STCP(0x7f294bfd, 0x0ea0f48c),
STCP(0x7f1cde01, 0x0f0b7727), STCP(0x7f1016ce, 0x0f75ef33),
STCP(0x7f02f66f, 0x0fe05c64), STCP(0x7ef57cea, 0x104abe71),
STCP(0x7ee7aa4c, 0x10b5150f), STCP(0x7ed97e9c, 0x111f5ff4),
STCP(0x7ecaf9e5, 0x11899ed3), STCP(0x7ebc1c31, 0x11f3d164),
STCP(0x7eace58a, 0x125df75b), STCP(0x7e9d55fc, 0x12c8106f),
STCP(0x7e8d6d91, 0x13321c53), STCP(0x7e7d2c54, 0x139c1abf),
STCP(0x7e6c9251, 0x14060b68), STCP(0x7e5b9f93, 0x146fee03),
STCP(0x7e4a5426, 0x14d9c245), STCP(0x7e38b017, 0x154387e6),
STCP(0x7e26b371, 0x15ad3e9a), STCP(0x7e145e42, 0x1616e618),
STCP(0x7e01b096, 0x16807e15), STCP(0x7deeaa7a, 0x16ea0646),
STCP(0x7ddb4bfc, 0x17537e63), STCP(0x7dc79529, 0x17bce621),
STCP(0x7db3860f, 0x18263d36), STCP(0x7d9f1ebd, 0x188f8357),
STCP(0x7d8a5f40, 0x18f8b83c), STCP(0x7d7547a7, 0x1961db9b),
STCP(0x7d5fd801, 0x19caed29), STCP(0x7d4a105d, 0x1a33ec9c),
STCP(0x7d33f0ca, 0x1a9cd9ac), STCP(0x7d1d7958, 0x1b05b40f),
STCP(0x7d06aa16, 0x1b6e7b7a), STCP(0x7cef8315, 0x1bd72fa4),
STCP(0x7cd80464, 0x1c3fd045), STCP(0x7cc02e15, 0x1ca85d12),
STCP(0x7ca80038, 0x1d10d5c2), STCP(0x7c8f7ade, 0x1d793a0b),
STCP(0x7c769e18, 0x1de189a6), STCP(0x7c5d69f7, 0x1e49c447),
STCP(0x7c43de8e, 0x1eb1e9a7), STCP(0x7c29fbee, 0x1f19f97b),
STCP(0x7c0fc22a, 0x1f81f37c), STCP(0x7bf53153, 0x1fe9d75f),
STCP(0x7bda497d, 0x2051a4dd), STCP(0x7bbf0aba, 0x20b95bac),
STCP(0x7ba3751d, 0x2120fb83), STCP(0x7b8788ba, 0x2188841a),
STCP(0x7b6b45a5, 0x21eff528), STCP(0x7b4eabf1, 0x22574e65),
STCP(0x7b31bbb2, 0x22be8f87), STCP(0x7b1474fd, 0x2325b847),
STCP(0x7af6d7e6, 0x238cc85d), STCP(0x7ad8e482, 0x23f3bf7e),
STCP(0x7aba9ae6, 0x245a9d65), STCP(0x7a9bfb27, 0x24c161c7),
STCP(0x7a7d055b, 0x25280c5e), STCP(0x7a5db997, 0x258e9ce0),
STCP(0x7a3e17f2, 0x25f51307), STCP(0x7a1e2082, 0x265b6e8a),
STCP(0x79fdd35c, 0x26c1af22), STCP(0x79dd3098, 0x2727d486),
STCP(0x79bc384d, 0x278dde6e), STCP(0x799aea92, 0x27f3cc94),
STCP(0x7979477d, 0x28599eb0), STCP(0x79574f28, 0x28bf547b),
STCP(0x793501a9, 0x2924edac), STCP(0x79125f19, 0x298a69fc),
STCP(0x78ef678f, 0x29efc925), STCP(0x78cc1b26, 0x2a550adf),
STCP(0x78a879f4, 0x2aba2ee4), STCP(0x78848414, 0x2b1f34eb),
STCP(0x7860399e, 0x2b841caf), STCP(0x783b9aad, 0x2be8e5e8),
STCP(0x7816a759, 0x2c4d9050), STCP(0x77f15fbc, 0x2cb21ba0),
STCP(0x77cbc3f2, 0x2d168792), STCP(0x77a5d413, 0x2d7ad3de),
STCP(0x777f903c, 0x2ddf0040), STCP(0x7758f886, 0x2e430c6f),
STCP(0x77320d0d, 0x2ea6f827), STCP(0x770acdec, 0x2f0ac320),
STCP(0x76e33b3f, 0x2f6e6d16), STCP(0x76bb5521, 0x2fd1f5c1),
STCP(0x76931bae, 0x30355cdd), STCP(0x766a8f04, 0x3098a223),
STCP(0x7641af3d, 0x30fbc54d), STCP(0x76187c77, 0x315ec617),
STCP(0x75eef6ce, 0x31c1a43b), STCP(0x75c51e61, 0x32245f72),
STCP(0x759af34c, 0x3286f779), STCP(0x757075ac, 0x32e96c09),
STCP(0x7545a5a0, 0x334bbcde), STCP(0x751a8346, 0x33ade9b3),
STCP(0x74ef0ebc, 0x340ff242), STCP(0x74c34820, 0x3471d647),
STCP(0x74972f92, 0x34d3957e), STCP(0x746ac52f, 0x35352fa1),
STCP(0x743e0918, 0x3596a46c), STCP(0x7410fb6b, 0x35f7f39c),
STCP(0x73e39c49, 0x36591cea), STCP(0x73b5ebd1, 0x36ba2014),
STCP(0x7387ea23, 0x371afcd5), STCP(0x73599760, 0x377bb2e9),
STCP(0x732af3a7, 0x37dc420c), STCP(0x72fbff1b, 0x383ca9fb),
STCP(0x72ccb9db, 0x389cea72), STCP(0x729d2409, 0x38fd032d),
STCP(0x726d3dc6, 0x395cf3e9), STCP(0x723d0734, 0x39bcbc63),
STCP(0x720c8075, 0x3a1c5c57), STCP(0x71dba9ab, 0x3a7bd382),
STCP(0x71aa82f7, 0x3adb21a1), STCP(0x71790c7e, 0x3b3a4672),
STCP(0x71474660, 0x3b9941b1), STCP(0x711530c2, 0x3bf8131c),
STCP(0x70e2cbc6, 0x3c56ba70), STCP(0x70b01790, 0x3cb5376b),
STCP(0x707d1443, 0x3d1389cb), STCP(0x7049c203, 0x3d71b14d),
STCP(0x701620f5, 0x3dcfadb0), STCP(0x6fe2313c, 0x3e2d7eb1),
STCP(0x6fadf2fc, 0x3e8b240e), STCP(0x6f79665b, 0x3ee89d86),
STCP(0x6f448b7e, 0x3f45ead8), STCP(0x6f0f6289, 0x3fa30bc1),
STCP(0x6ed9eba1, 0x40000000), STCP(0x6ea426ed, 0x405cc754),
STCP(0x6e6e1492, 0x40b9617d), STCP(0x6e37b4b6, 0x4115ce38),
STCP(0x6e010780, 0x41720d46), STCP(0x6dca0d14, 0x41ce1e65),
STCP(0x6d92c59b, 0x422a0154), STCP(0x6d5b313b, 0x4285b5d4),
STCP(0x6d23501b, 0x42e13ba4), STCP(0x6ceb2261, 0x433c9283),
STCP(0x6cb2a837, 0x4397ba32), STCP(0x6c79e1c2, 0x43f2b271),
STCP(0x6c40cf2c, 0x444d7aff), STCP(0x6c07709b, 0x44a8139e),
STCP(0x6bcdc639, 0x45027c0c), STCP(0x6b93d02e, 0x455cb40c),
STCP(0x6b598ea3, 0x45b6bb5e), STCP(0x6b1f01c0, 0x461091c2),
STCP(0x6ae429ae, 0x466a36f9), STCP(0x6aa90697, 0x46c3aac5),
STCP(0x6a6d98a4, 0x471cece7), STCP(0x6a31e000, 0x4775fd1f),
STCP(0x69f5dcd3, 0x47cedb31), STCP(0x69b98f48, 0x482786dc),
STCP(0x697cf78a, 0x487fffe4), STCP(0x694015c3, 0x48d84609),
STCP(0x6902ea1d, 0x4930590f), STCP(0x68c574c4, 0x498838b6),
STCP(0x6887b5e2, 0x49dfe4c2), STCP(0x6849ada3, 0x4a375cf5),
STCP(0x680b5c33, 0x4a8ea111), STCP(0x67ccc1be, 0x4ae5b0da),
STCP(0x678dde6e, 0x4b3c8c12), STCP(0x674eb271, 0x4b93327c),
STCP(0x670f3df3, 0x4be9a3db), STCP(0x66cf8120, 0x4c3fdff4),
STCP(0x668f7c25, 0x4c95e688), STCP(0x664f2f2e, 0x4cebb75c),
STCP(0x660e9a6a, 0x4d415234), STCP(0x65cdbe05, 0x4d96b6d3),
STCP(0x658c9a2d, 0x4debe4fe), STCP(0x654b2f10, 0x4e40dc79),
STCP(0x65097cdb, 0x4e959d08), STCP(0x64c783bd, 0x4eea2670),
STCP(0x648543e4, 0x4f3e7875), STCP(0x6442bd7e, 0x4f9292dc),
STCP(0x63fff0ba, 0x4fe6756a), STCP(0x63bcddc7, 0x503a1fe5),
STCP(0x637984d4, 0x508d9211), STCP(0x6335e611, 0x50e0cbb4),
STCP(0x62f201ac, 0x5133cc94), STCP(0x62add7d6, 0x51869476),
STCP(0x626968be, 0x51d92321), STCP(0x6224b495, 0x522b7859),
STCP(0x61dfbb8a, 0x527d93e6), STCP(0x619a7dce, 0x52cf758f),
STCP(0x6154fb91, 0x53211d18), STCP(0x610f3505, 0x53728a4a),
STCP(0x60c92a5a, 0x53c3bcea), STCP(0x6082dbc1, 0x5414b4c1),
STCP(0x603c496c, 0x54657194), STCP(0x5ff5738d, 0x54b5f32c),
STCP(0x5fae5a55, 0x55063951), STCP(0x5f66fdf5, 0x555643c8),
STCP(0x5f1f5ea1, 0x55a6125c), STCP(0x5ed77c8a, 0x55f5a4d2),
STCP(0x5e8f57e2, 0x5644faf4), STCP(0x5e46f0dd, 0x5694148b),
STCP(0x5dfe47ad, 0x56e2f15d), STCP(0x5db55c86, 0x57319135),
STCP(0x5d6c2f99, 0x577ff3da), STCP(0x5d22c11c, 0x57ce1917),
STCP(0x5cd91140, 0x581c00b3), STCP(0x5c8f203b, 0x5869aa79),
STCP(0x5c44ee40, 0x58b71632), STCP(0x5bfa7b82, 0x590443a7),
STCP(0x5bafc837, 0x595132a2), STCP(0x5b64d492, 0x599de2ee),
STCP(0x5b19a0c8, 0x59ea5454), STCP(0x5ace2d0f, 0x5a36869f),
STCP(0x5a82799a, 0x5a82799a),
};
RAM_ALIGN
LNK_SECTION_CONSTDATA
const FIXP_STP SineTable512[] = {
STCP(0x7fffffff, 0x00000000), STCP(0x7fffd886, 0x006487e3),
STCP(0x7fff6216, 0x00c90f88), STCP(0x7ffe9cb2, 0x012d96b1),
STCP(0x7ffd885a, 0x01921d20), STCP(0x7ffc250f, 0x01f6a297),
STCP(0x7ffa72d1, 0x025b26d7), STCP(0x7ff871a2, 0x02bfa9a4),
STCP(0x7ff62182, 0x03242abf), STCP(0x7ff38274, 0x0388a9ea),
STCP(0x7ff09478, 0x03ed26e6), STCP(0x7fed5791, 0x0451a177),
STCP(0x7fe9cbc0, 0x04b6195d), STCP(0x7fe5f108, 0x051a8e5c),
STCP(0x7fe1c76b, 0x057f0035), STCP(0x7fdd4eec, 0x05e36ea9),
STCP(0x7fd8878e, 0x0647d97c), STCP(0x7fd37153, 0x06ac406f),
STCP(0x7fce0c3e, 0x0710a345), STCP(0x7fc85854, 0x077501be),
STCP(0x7fc25596, 0x07d95b9e), STCP(0x7fbc040a, 0x083db0a7),
STCP(0x7fb563b3, 0x08a2009a), STCP(0x7fae7495, 0x09064b3a),
STCP(0x7fa736b4, 0x096a9049), STCP(0x7f9faa15, 0x09cecf89),
STCP(0x7f97cebd, 0x0a3308bd), STCP(0x7f8fa4b0, 0x0a973ba5),
STCP(0x7f872bf3, 0x0afb6805), STCP(0x7f7e648c, 0x0b5f8d9f),
STCP(0x7f754e80, 0x0bc3ac35), STCP(0x7f6be9d4, 0x0c27c389),
STCP(0x7f62368f, 0x0c8bd35e), STCP(0x7f5834b7, 0x0cefdb76),
STCP(0x7f4de451, 0x0d53db92), STCP(0x7f434563, 0x0db7d376),
STCP(0x7f3857f6, 0x0e1bc2e4), STCP(0x7f2d1c0e, 0x0e7fa99e),
STCP(0x7f2191b4, 0x0ee38766), STCP(0x7f15b8ee, 0x0f475bff),
STCP(0x7f0991c4, 0x0fab272b), STCP(0x7efd1c3c, 0x100ee8ad),
STCP(0x7ef05860, 0x1072a048), STCP(0x7ee34636, 0x10d64dbd),
STCP(0x7ed5e5c6, 0x1139f0cf), STCP(0x7ec8371a, 0x119d8941),
STCP(0x7eba3a39, 0x120116d5), STCP(0x7eabef2c, 0x1264994e),
STCP(0x7e9d55fc, 0x12c8106f), STCP(0x7e8e6eb2, 0x132b7bf9),
STCP(0x7e7f3957, 0x138edbb1), STCP(0x7e6fb5f4, 0x13f22f58),
STCP(0x7e5fe493, 0x145576b1), STCP(0x7e4fc53e, 0x14b8b17f),
STCP(0x7e3f57ff, 0x151bdf86), STCP(0x7e2e9cdf, 0x157f0086),
STCP(0x7e1d93ea, 0x15e21445), STCP(0x7e0c3d29, 0x16451a83),
STCP(0x7dfa98a8, 0x16a81305), STCP(0x7de8a670, 0x170afd8d),
STCP(0x7dd6668f, 0x176dd9de), STCP(0x7dc3d90d, 0x17d0a7bc),
STCP(0x7db0fdf8, 0x183366e9), STCP(0x7d9dd55a, 0x18961728),
STCP(0x7d8a5f40, 0x18f8b83c), STCP(0x7d769bb5, 0x195b49ea),
STCP(0x7d628ac6, 0x19bdcbf3), STCP(0x7d4e2c7f, 0x1a203e1b),
STCP(0x7d3980ec, 0x1a82a026), STCP(0x7d24881b, 0x1ae4f1d6),
STCP(0x7d0f4218, 0x1b4732ef), STCP(0x7cf9aef0, 0x1ba96335),
STCP(0x7ce3ceb2, 0x1c0b826a), STCP(0x7ccda169, 0x1c6d9053),
STCP(0x7cb72724, 0x1ccf8cb3), STCP(0x7ca05ff1, 0x1d31774d),
STCP(0x7c894bde, 0x1d934fe5), STCP(0x7c71eaf9, 0x1df5163f),
STCP(0x7c5a3d50, 0x1e56ca1e), STCP(0x7c4242f2, 0x1eb86b46),
STCP(0x7c29fbee, 0x1f19f97b), STCP(0x7c116853, 0x1f7b7481),
STCP(0x7bf88830, 0x1fdcdc1b), STCP(0x7bdf5b94, 0x203e300d),
STCP(0x7bc5e290, 0x209f701c), STCP(0x7bac1d31, 0x21009c0c),
STCP(0x7b920b89, 0x2161b3a0), STCP(0x7b77ada8, 0x21c2b69c),
STCP(0x7b5d039e, 0x2223a4c5), STCP(0x7b420d7a, 0x22847de0),
STCP(0x7b26cb4f, 0x22e541af), STCP(0x7b0b3d2c, 0x2345eff8),
STCP(0x7aef6323, 0x23a6887f), STCP(0x7ad33d45, 0x24070b08),
STCP(0x7ab6cba4, 0x24677758), STCP(0x7a9a0e50, 0x24c7cd33),
STCP(0x7a7d055b, 0x25280c5e), STCP(0x7a5fb0d8, 0x2588349d),
STCP(0x7a4210d8, 0x25e845b6), STCP(0x7a24256f, 0x26483f6c),
STCP(0x7a05eead, 0x26a82186), STCP(0x79e76ca7, 0x2707ebc7),
STCP(0x79c89f6e, 0x27679df4), STCP(0x79a98715, 0x27c737d3),
STCP(0x798a23b1, 0x2826b928), STCP(0x796a7554, 0x288621b9),
STCP(0x794a7c12, 0x28e5714b), STCP(0x792a37fe, 0x2944a7a2),
STCP(0x7909a92d, 0x29a3c485), STCP(0x78e8cfb2, 0x2a02c7b8),
STCP(0x78c7aba2, 0x2a61b101), STCP(0x78a63d11, 0x2ac08026),
STCP(0x78848414, 0x2b1f34eb), STCP(0x786280bf, 0x2b7dcf17),
STCP(0x78403329, 0x2bdc4e6f), STCP(0x781d9b65, 0x2c3ab2b9),
STCP(0x77fab989, 0x2c98fbba), STCP(0x77d78daa, 0x2cf72939),
STCP(0x77b417df, 0x2d553afc), STCP(0x7790583e, 0x2db330c7),
STCP(0x776c4edb, 0x2e110a62), STCP(0x7747fbce, 0x2e6ec792),
STCP(0x77235f2d, 0x2ecc681e), STCP(0x76fe790e, 0x2f29ebcc),
STCP(0x76d94989, 0x2f875262), STCP(0x76b3d0b4, 0x2fe49ba7),
STCP(0x768e0ea6, 0x3041c761), STCP(0x76680376, 0x309ed556),
STCP(0x7641af3d, 0x30fbc54d), STCP(0x761b1211, 0x3158970e),
STCP(0x75f42c0b, 0x31b54a5e), STCP(0x75ccfd42, 0x3211df04),
STCP(0x75a585cf, 0x326e54c7), STCP(0x757dc5ca, 0x32caab6f),
STCP(0x7555bd4c, 0x3326e2c3), STCP(0x752d6c6c, 0x3382fa88),
STCP(0x7504d345, 0x33def287), STCP(0x74dbf1ef, 0x343aca87),
STCP(0x74b2c884, 0x34968250), STCP(0x7489571c, 0x34f219a8),
STCP(0x745f9dd1, 0x354d9057), STCP(0x74359cbd, 0x35a8e625),
STCP(0x740b53fb, 0x36041ad9), STCP(0x73e0c3a3, 0x365f2e3b),
STCP(0x73b5ebd1, 0x36ba2014), STCP(0x738acc9e, 0x3714f02a),
STCP(0x735f6626, 0x376f9e46), STCP(0x7333b883, 0x37ca2a30),
STCP(0x7307c3d0, 0x382493b0), STCP(0x72db8828, 0x387eda8e),
STCP(0x72af05a7, 0x38d8fe93), STCP(0x72823c67, 0x3932ff87),
STCP(0x72552c85, 0x398cdd32), STCP(0x7227d61c, 0x39e6975e),
STCP(0x71fa3949, 0x3a402dd2), STCP(0x71cc5626, 0x3a99a057),
STCP(0x719e2cd2, 0x3af2eeb7), STCP(0x716fbd68, 0x3b4c18ba),
STCP(0x71410805, 0x3ba51e29), STCP(0x71120cc5, 0x3bfdfecd),
STCP(0x70e2cbc6, 0x3c56ba70), STCP(0x70b34525, 0x3caf50da),
STCP(0x708378ff, 0x3d07c1d6), STCP(0x70536771, 0x3d600d2c),
STCP(0x7023109a, 0x3db832a6), STCP(0x6ff27497, 0x3e10320d),
STCP(0x6fc19385, 0x3e680b2c), STCP(0x6f906d84, 0x3ebfbdcd),
STCP(0x6f5f02b2, 0x3f1749b8), STCP(0x6f2d532c, 0x3f6eaeb8),
STCP(0x6efb5f12, 0x3fc5ec98), STCP(0x6ec92683, 0x401d0321),
STCP(0x6e96a99d, 0x4073f21d), STCP(0x6e63e87f, 0x40cab958),
STCP(0x6e30e34a, 0x4121589b), STCP(0x6dfd9a1c, 0x4177cfb1),
STCP(0x6dca0d14, 0x41ce1e65), STCP(0x6d963c54, 0x42244481),
STCP(0x6d6227fa, 0x427a41d0), STCP(0x6d2dd027, 0x42d0161e),
STCP(0x6cf934fc, 0x4325c135), STCP(0x6cc45698, 0x437b42e1),
STCP(0x6c8f351c, 0x43d09aed), STCP(0x6c59d0a9, 0x4425c923),
STCP(0x6c242960, 0x447acd50), STCP(0x6bee3f62, 0x44cfa740),
STCP(0x6bb812d1, 0x452456bd), STCP(0x6b81a3cd, 0x4578db93),
STCP(0x6b4af279, 0x45cd358f), STCP(0x6b13fef5, 0x4621647d),
STCP(0x6adcc964, 0x46756828), STCP(0x6aa551e9, 0x46c9405c),
STCP(0x6a6d98a4, 0x471cece7), STCP(0x6a359db9, 0x47706d93),
STCP(0x69fd614a, 0x47c3c22f), STCP(0x69c4e37a, 0x4816ea86),
STCP(0x698c246c, 0x4869e665), STCP(0x69532442, 0x48bcb599),
STCP(0x6919e320, 0x490f57ee), STCP(0x68e06129, 0x4961cd33),
STCP(0x68a69e81, 0x49b41533), STCP(0x686c9b4b, 0x4a062fbd),
STCP(0x683257ab, 0x4a581c9e), STCP(0x67f7d3c5, 0x4aa9dba2),
STCP(0x67bd0fbd, 0x4afb6c98), STCP(0x67820bb7, 0x4b4ccf4d),
STCP(0x6746c7d8, 0x4b9e0390), STCP(0x670b4444, 0x4bef092d),
STCP(0x66cf8120, 0x4c3fdff4), STCP(0x66937e91, 0x4c9087b1),
STCP(0x66573cbb, 0x4ce10034), STCP(0x661abbc5, 0x4d31494b),
STCP(0x65ddfbd3, 0x4d8162c4), STCP(0x65a0fd0b, 0x4dd14c6e),
STCP(0x6563bf92, 0x4e210617), STCP(0x6526438f, 0x4e708f8f),
STCP(0x64e88926, 0x4ebfe8a5), STCP(0x64aa907f, 0x4f0f1126),
STCP(0x646c59bf, 0x4f5e08e3), STCP(0x642de50d, 0x4faccfab),
STCP(0x63ef3290, 0x4ffb654d), STCP(0x63b0426d, 0x5049c999),
STCP(0x637114cc, 0x5097fc5e), STCP(0x6331a9d4, 0x50e5fd6d),
STCP(0x62f201ac, 0x5133cc94), STCP(0x62b21c7b, 0x518169a5),
STCP(0x6271fa69, 0x51ced46e), STCP(0x62319b9d, 0x521c0cc2),
STCP(0x61f1003f, 0x5269126e), STCP(0x61b02876, 0x52b5e546),
STCP(0x616f146c, 0x53028518), STCP(0x612dc447, 0x534ef1b5),
STCP(0x60ec3830, 0x539b2af0), STCP(0x60aa7050, 0x53e73097),
STCP(0x60686ccf, 0x5433027d), STCP(0x60262dd6, 0x547ea073),
STCP(0x5fe3b38d, 0x54ca0a4b), STCP(0x5fa0fe1f, 0x55153fd4),
STCP(0x5f5e0db3, 0x556040e2), STCP(0x5f1ae274, 0x55ab0d46),
STCP(0x5ed77c8a, 0x55f5a4d2), STCP(0x5e93dc1f, 0x56400758),
STCP(0x5e50015d, 0x568a34a9), STCP(0x5e0bec6e, 0x56d42c99),
STCP(0x5dc79d7c, 0x571deefa), STCP(0x5d8314b1, 0x57677b9d),
STCP(0x5d3e5237, 0x57b0d256), STCP(0x5cf95638, 0x57f9f2f8),
STCP(0x5cb420e0, 0x5842dd54), STCP(0x5c6eb258, 0x588b9140),
STCP(0x5c290acc, 0x58d40e8c), STCP(0x5be32a67, 0x591c550e),
STCP(0x5b9d1154, 0x59646498), STCP(0x5b56bfbd, 0x59ac3cfd),
STCP(0x5b1035cf, 0x59f3de12), STCP(0x5ac973b5, 0x5a3b47ab),
STCP(0x5a82799a, 0x5a82799a),
};
RAM_ALIGN
LNK_SECTION_CONSTDATA
const FIXP_STP SineTable1024[] = {
STCP(0x7fffffff, 0x00000000), STCP(0x7ffff621, 0x003243f5),
STCP(0x7fffd886, 0x006487e3), STCP(0x7fffa72c, 0x0096cbc1),
STCP(0x7fff6216, 0x00c90f88), STCP(0x7fff0943, 0x00fb5330),
STCP(0x7ffe9cb2, 0x012d96b1), STCP(0x7ffe1c65, 0x015fda03),
STCP(0x7ffd885a, 0x01921d20), STCP(0x7ffce093, 0x01c45ffe),
STCP(0x7ffc250f, 0x01f6a297), STCP(0x7ffb55ce, 0x0228e4e2),
STCP(0x7ffa72d1, 0x025b26d7), STCP(0x7ff97c18, 0x028d6870),
STCP(0x7ff871a2, 0x02bfa9a4), STCP(0x7ff75370, 0x02f1ea6c),
STCP(0x7ff62182, 0x03242abf), STCP(0x7ff4dbd9, 0x03566a96),
STCP(0x7ff38274, 0x0388a9ea), STCP(0x7ff21553, 0x03bae8b2),
STCP(0x7ff09478, 0x03ed26e6), STCP(0x7feeffe1, 0x041f6480),
STCP(0x7fed5791, 0x0451a177), STCP(0x7feb9b85, 0x0483ddc3),
STCP(0x7fe9cbc0, 0x04b6195d), STCP(0x7fe7e841, 0x04e8543e),
STCP(0x7fe5f108, 0x051a8e5c), STCP(0x7fe3e616, 0x054cc7b1),
STCP(0x7fe1c76b, 0x057f0035), STCP(0x7fdf9508, 0x05b137df),
STCP(0x7fdd4eec, 0x05e36ea9), STCP(0x7fdaf519, 0x0615a48b),
STCP(0x7fd8878e, 0x0647d97c), STCP(0x7fd6064c, 0x067a0d76),
STCP(0x7fd37153, 0x06ac406f), STCP(0x7fd0c8a3, 0x06de7262),
STCP(0x7fce0c3e, 0x0710a345), STCP(0x7fcb3c23, 0x0742d311),
STCP(0x7fc85854, 0x077501be), STCP(0x7fc560cf, 0x07a72f45),
STCP(0x7fc25596, 0x07d95b9e), STCP(0x7fbf36aa, 0x080b86c2),
STCP(0x7fbc040a, 0x083db0a7), STCP(0x7fb8bdb8, 0x086fd947),
STCP(0x7fb563b3, 0x08a2009a), STCP(0x7fb1f5fc, 0x08d42699),
STCP(0x7fae7495, 0x09064b3a), STCP(0x7faadf7c, 0x09386e78),
STCP(0x7fa736b4, 0x096a9049), STCP(0x7fa37a3c, 0x099cb0a7),
STCP(0x7f9faa15, 0x09cecf89), STCP(0x7f9bc640, 0x0a00ece8),
STCP(0x7f97cebd, 0x0a3308bd), STCP(0x7f93c38c, 0x0a6522fe),
STCP(0x7f8fa4b0, 0x0a973ba5), STCP(0x7f8b7227, 0x0ac952aa),
STCP(0x7f872bf3, 0x0afb6805), STCP(0x7f82d214, 0x0b2d7baf),
STCP(0x7f7e648c, 0x0b5f8d9f), STCP(0x7f79e35a, 0x0b919dcf),
STCP(0x7f754e80, 0x0bc3ac35), STCP(0x7f70a5fe, 0x0bf5b8cb),
STCP(0x7f6be9d4, 0x0c27c389), STCP(0x7f671a05, 0x0c59cc68),
STCP(0x7f62368f, 0x0c8bd35e), STCP(0x7f5d3f75, 0x0cbdd865),
STCP(0x7f5834b7, 0x0cefdb76), STCP(0x7f531655, 0x0d21dc87),
STCP(0x7f4de451, 0x0d53db92), STCP(0x7f489eaa, 0x0d85d88f),
STCP(0x7f434563, 0x0db7d376), STCP(0x7f3dd87c, 0x0de9cc40),
STCP(0x7f3857f6, 0x0e1bc2e4), STCP(0x7f32c3d1, 0x0e4db75b),
STCP(0x7f2d1c0e, 0x0e7fa99e), STCP(0x7f2760af, 0x0eb199a4),
STCP(0x7f2191b4, 0x0ee38766), STCP(0x7f1baf1e, 0x0f1572dc),
STCP(0x7f15b8ee, 0x0f475bff), STCP(0x7f0faf25, 0x0f7942c7),
STCP(0x7f0991c4, 0x0fab272b), STCP(0x7f0360cb, 0x0fdd0926),
STCP(0x7efd1c3c, 0x100ee8ad), STCP(0x7ef6c418, 0x1040c5bb),
STCP(0x7ef05860, 0x1072a048), STCP(0x7ee9d914, 0x10a4784b),
STCP(0x7ee34636, 0x10d64dbd), STCP(0x7edc9fc6, 0x11082096),
STCP(0x7ed5e5c6, 0x1139f0cf), STCP(0x7ecf1837, 0x116bbe60),
STCP(0x7ec8371a, 0x119d8941), STCP(0x7ec14270, 0x11cf516a),
STCP(0x7eba3a39, 0x120116d5), STCP(0x7eb31e78, 0x1232d979),
STCP(0x7eabef2c, 0x1264994e), STCP(0x7ea4ac58, 0x1296564d),
STCP(0x7e9d55fc, 0x12c8106f), STCP(0x7e95ec1a, 0x12f9c7aa),
STCP(0x7e8e6eb2, 0x132b7bf9), STCP(0x7e86ddc6, 0x135d2d53),
STCP(0x7e7f3957, 0x138edbb1), STCP(0x7e778166, 0x13c0870a),
STCP(0x7e6fb5f4, 0x13f22f58), STCP(0x7e67d703, 0x1423d492),
STCP(0x7e5fe493, 0x145576b1), STCP(0x7e57dea7, 0x148715ae),
STCP(0x7e4fc53e, 0x14b8b17f), STCP(0x7e47985b, 0x14ea4a1f),
STCP(0x7e3f57ff, 0x151bdf86), STCP(0x7e37042a, 0x154d71aa),
STCP(0x7e2e9cdf, 0x157f0086), STCP(0x7e26221f, 0x15b08c12),
STCP(0x7e1d93ea, 0x15e21445), STCP(0x7e14f242, 0x16139918),
STCP(0x7e0c3d29, 0x16451a83), STCP(0x7e0374a0, 0x1676987f),
STCP(0x7dfa98a8, 0x16a81305), STCP(0x7df1a942, 0x16d98a0c),
STCP(0x7de8a670, 0x170afd8d), STCP(0x7ddf9034, 0x173c6d80),
STCP(0x7dd6668f, 0x176dd9de), STCP(0x7dcd2981, 0x179f429f),
STCP(0x7dc3d90d, 0x17d0a7bc), STCP(0x7dba7534, 0x1802092c),
STCP(0x7db0fdf8, 0x183366e9), STCP(0x7da77359, 0x1864c0ea),
STCP(0x7d9dd55a, 0x18961728), STCP(0x7d9423fc, 0x18c7699b),
STCP(0x7d8a5f40, 0x18f8b83c), STCP(0x7d808728, 0x192a0304),
STCP(0x7d769bb5, 0x195b49ea), STCP(0x7d6c9ce9, 0x198c8ce7),
STCP(0x7d628ac6, 0x19bdcbf3), STCP(0x7d58654d, 0x19ef0707),
STCP(0x7d4e2c7f, 0x1a203e1b), STCP(0x7d43e05e, 0x1a517128),
STCP(0x7d3980ec, 0x1a82a026), STCP(0x7d2f0e2b, 0x1ab3cb0d),
STCP(0x7d24881b, 0x1ae4f1d6), STCP(0x7d19eebf, 0x1b161479),
STCP(0x7d0f4218, 0x1b4732ef), STCP(0x7d048228, 0x1b784d30),
STCP(0x7cf9aef0, 0x1ba96335), STCP(0x7ceec873, 0x1bda74f6),
STCP(0x7ce3ceb2, 0x1c0b826a), STCP(0x7cd8c1ae, 0x1c3c8b8c),
STCP(0x7ccda169, 0x1c6d9053), STCP(0x7cc26de5, 0x1c9e90b8),
STCP(0x7cb72724, 0x1ccf8cb3), STCP(0x7cabcd28, 0x1d00843d),
STCP(0x7ca05ff1, 0x1d31774d), STCP(0x7c94df83, 0x1d6265dd),
STCP(0x7c894bde, 0x1d934fe5), STCP(0x7c7da505, 0x1dc4355e),
STCP(0x7c71eaf9, 0x1df5163f), STCP(0x7c661dbc, 0x1e25f282),
STCP(0x7c5a3d50, 0x1e56ca1e), STCP(0x7c4e49b7, 0x1e879d0d),
STCP(0x7c4242f2, 0x1eb86b46), STCP(0x7c362904, 0x1ee934c3),
STCP(0x7c29fbee, 0x1f19f97b), STCP(0x7c1dbbb3, 0x1f4ab968),
STCP(0x7c116853, 0x1f7b7481), STCP(0x7c0501d2, 0x1fac2abf),
STCP(0x7bf88830, 0x1fdcdc1b), STCP(0x7bebfb70, 0x200d888d),
STCP(0x7bdf5b94, 0x203e300d), STCP(0x7bd2a89e, 0x206ed295),
STCP(0x7bc5e290, 0x209f701c), STCP(0x7bb9096b, 0x20d0089c),
STCP(0x7bac1d31, 0x21009c0c), STCP(0x7b9f1de6, 0x21312a65),
STCP(0x7b920b89, 0x2161b3a0), STCP(0x7b84e61f, 0x219237b5),
STCP(0x7b77ada8, 0x21c2b69c), STCP(0x7b6a6227, 0x21f3304f),
STCP(0x7b5d039e, 0x2223a4c5), STCP(0x7b4f920e, 0x225413f8),
STCP(0x7b420d7a, 0x22847de0), STCP(0x7b3475e5, 0x22b4e274),
STCP(0x7b26cb4f, 0x22e541af), STCP(0x7b190dbc, 0x23159b88),
STCP(0x7b0b3d2c, 0x2345eff8), STCP(0x7afd59a4, 0x23763ef7),
STCP(0x7aef6323, 0x23a6887f), STCP(0x7ae159ae, 0x23d6cc87),
STCP(0x7ad33d45, 0x24070b08), STCP(0x7ac50dec, 0x243743fa),
STCP(0x7ab6cba4, 0x24677758), STCP(0x7aa8766f, 0x2497a517),
STCP(0x7a9a0e50, 0x24c7cd33), STCP(0x7a8b9348, 0x24f7efa2),
STCP(0x7a7d055b, 0x25280c5e), STCP(0x7a6e648a, 0x2558235f),
STCP(0x7a5fb0d8, 0x2588349d), STCP(0x7a50ea47, 0x25b84012),
STCP(0x7a4210d8, 0x25e845b6), STCP(0x7a332490, 0x26184581),
STCP(0x7a24256f, 0x26483f6c), STCP(0x7a151378, 0x26783370),
STCP(0x7a05eead, 0x26a82186), STCP(0x79f6b711, 0x26d809a5),
STCP(0x79e76ca7, 0x2707ebc7), STCP(0x79d80f6f, 0x2737c7e3),
STCP(0x79c89f6e, 0x27679df4), STCP(0x79b91ca4, 0x27976df1),
STCP(0x79a98715, 0x27c737d3), STCP(0x7999dec4, 0x27f6fb92),
STCP(0x798a23b1, 0x2826b928), STCP(0x797a55e0, 0x2856708d),
STCP(0x796a7554, 0x288621b9), STCP(0x795a820e, 0x28b5cca5),
STCP(0x794a7c12, 0x28e5714b), STCP(0x793a6361, 0x29150fa1),
STCP(0x792a37fe, 0x2944a7a2), STCP(0x7919f9ec, 0x29743946),
STCP(0x7909a92d, 0x29a3c485), STCP(0x78f945c3, 0x29d34958),
STCP(0x78e8cfb2, 0x2a02c7b8), STCP(0x78d846fb, 0x2a323f9e),
STCP(0x78c7aba2, 0x2a61b101), STCP(0x78b6fda8, 0x2a911bdc),
STCP(0x78a63d11, 0x2ac08026), STCP(0x789569df, 0x2aefddd8),
STCP(0x78848414, 0x2b1f34eb), STCP(0x78738bb3, 0x2b4e8558),
STCP(0x786280bf, 0x2b7dcf17), STCP(0x7851633b, 0x2bad1221),
STCP(0x78403329, 0x2bdc4e6f), STCP(0x782ef08b, 0x2c0b83fa),
STCP(0x781d9b65, 0x2c3ab2b9), STCP(0x780c33b8, 0x2c69daa6),
STCP(0x77fab989, 0x2c98fbba), STCP(0x77e92cd9, 0x2cc815ee),
STCP(0x77d78daa, 0x2cf72939), STCP(0x77c5dc01, 0x2d263596),
STCP(0x77b417df, 0x2d553afc), STCP(0x77a24148, 0x2d843964),
STCP(0x7790583e, 0x2db330c7), STCP(0x777e5cc3, 0x2de2211e),
STCP(0x776c4edb, 0x2e110a62), STCP(0x775a2e89, 0x2e3fec8b),
STCP(0x7747fbce, 0x2e6ec792), STCP(0x7735b6af, 0x2e9d9b70),
STCP(0x77235f2d, 0x2ecc681e), STCP(0x7710f54c, 0x2efb2d95),
STCP(0x76fe790e, 0x2f29ebcc), STCP(0x76ebea77, 0x2f58a2be),
STCP(0x76d94989, 0x2f875262), STCP(0x76c69647, 0x2fb5fab2),
STCP(0x76b3d0b4, 0x2fe49ba7), STCP(0x76a0f8d2, 0x30133539),
STCP(0x768e0ea6, 0x3041c761), STCP(0x767b1231, 0x30705217),
STCP(0x76680376, 0x309ed556), STCP(0x7654e279, 0x30cd5115),
STCP(0x7641af3d, 0x30fbc54d), STCP(0x762e69c4, 0x312a31f8),
STCP(0x761b1211, 0x3158970e), STCP(0x7607a828, 0x3186f487),
STCP(0x75f42c0b, 0x31b54a5e), STCP(0x75e09dbd, 0x31e39889),
STCP(0x75ccfd42, 0x3211df04), STCP(0x75b94a9c, 0x32401dc6),
STCP(0x75a585cf, 0x326e54c7), STCP(0x7591aedd, 0x329c8402),
STCP(0x757dc5ca, 0x32caab6f), STCP(0x7569ca99, 0x32f8cb07),
STCP(0x7555bd4c, 0x3326e2c3), STCP(0x75419de7, 0x3354f29b),
STCP(0x752d6c6c, 0x3382fa88), STCP(0x751928e0, 0x33b0fa84),
STCP(0x7504d345, 0x33def287), STCP(0x74f06b9e, 0x340ce28b),
STCP(0x74dbf1ef, 0x343aca87), STCP(0x74c7663a, 0x3468aa76),
STCP(0x74b2c884, 0x34968250), STCP(0x749e18cd, 0x34c4520d),
STCP(0x7489571c, 0x34f219a8), STCP(0x74748371, 0x351fd918),
STCP(0x745f9dd1, 0x354d9057), STCP(0x744aa63f, 0x357b3f5d),
STCP(0x74359cbd, 0x35a8e625), STCP(0x74208150, 0x35d684a6),
STCP(0x740b53fb, 0x36041ad9), STCP(0x73f614c0, 0x3631a8b8),
STCP(0x73e0c3a3, 0x365f2e3b), STCP(0x73cb60a8, 0x368cab5c),
STCP(0x73b5ebd1, 0x36ba2014), STCP(0x73a06522, 0x36e78c5b),
STCP(0x738acc9e, 0x3714f02a), STCP(0x73752249, 0x37424b7b),
STCP(0x735f6626, 0x376f9e46), STCP(0x73499838, 0x379ce885),
STCP(0x7333b883, 0x37ca2a30), STCP(0x731dc70a, 0x37f76341),
STCP(0x7307c3d0, 0x382493b0), STCP(0x72f1aed9, 0x3851bb77),
STCP(0x72db8828, 0x387eda8e), STCP(0x72c54fc1, 0x38abf0ef),
STCP(0x72af05a7, 0x38d8fe93), STCP(0x7298a9dd, 0x39060373),
STCP(0x72823c67, 0x3932ff87), STCP(0x726bbd48, 0x395ff2c9),
STCP(0x72552c85, 0x398cdd32), STCP(0x723e8a20, 0x39b9bebc),
STCP(0x7227d61c, 0x39e6975e), STCP(0x7211107e, 0x3a136712),
STCP(0x71fa3949, 0x3a402dd2), STCP(0x71e35080, 0x3a6ceb96),
STCP(0x71cc5626, 0x3a99a057), STCP(0x71b54a41, 0x3ac64c0f),
STCP(0x719e2cd2, 0x3af2eeb7), STCP(0x7186fdde, 0x3b1f8848),
STCP(0x716fbd68, 0x3b4c18ba), STCP(0x71586b74, 0x3b78a007),
STCP(0x71410805, 0x3ba51e29), STCP(0x7129931f, 0x3bd19318),
STCP(0x71120cc5, 0x3bfdfecd), STCP(0x70fa74fc, 0x3c2a6142),
STCP(0x70e2cbc6, 0x3c56ba70), STCP(0x70cb1128, 0x3c830a50),
STCP(0x70b34525, 0x3caf50da), STCP(0x709b67c0, 0x3cdb8e09),
STCP(0x708378ff, 0x3d07c1d6), STCP(0x706b78e3, 0x3d33ec39),
STCP(0x70536771, 0x3d600d2c), STCP(0x703b44ad, 0x3d8c24a8),
STCP(0x7023109a, 0x3db832a6), STCP(0x700acb3c, 0x3de4371f),
STCP(0x6ff27497, 0x3e10320d), STCP(0x6fda0cae, 0x3e3c2369),
STCP(0x6fc19385, 0x3e680b2c), STCP(0x6fa90921, 0x3e93e950),
STCP(0x6f906d84, 0x3ebfbdcd), STCP(0x6f77c0b3, 0x3eeb889c),
STCP(0x6f5f02b2, 0x3f1749b8), STCP(0x6f463383, 0x3f430119),
STCP(0x6f2d532c, 0x3f6eaeb8), STCP(0x6f1461b0, 0x3f9a5290),
STCP(0x6efb5f12, 0x3fc5ec98), STCP(0x6ee24b57, 0x3ff17cca),
STCP(0x6ec92683, 0x401d0321), STCP(0x6eaff099, 0x40487f94),
STCP(0x6e96a99d, 0x4073f21d), STCP(0x6e7d5193, 0x409f5ab6),
STCP(0x6e63e87f, 0x40cab958), STCP(0x6e4a6e66, 0x40f60dfb),
STCP(0x6e30e34a, 0x4121589b), STCP(0x6e174730, 0x414c992f),
STCP(0x6dfd9a1c, 0x4177cfb1), STCP(0x6de3dc11, 0x41a2fc1a),
STCP(0x6dca0d14, 0x41ce1e65), STCP(0x6db02d29, 0x41f93689),
STCP(0x6d963c54, 0x42244481), STCP(0x6d7c3a98, 0x424f4845),
STCP(0x6d6227fa, 0x427a41d0), STCP(0x6d48047e, 0x42a5311b),
STCP(0x6d2dd027, 0x42d0161e), STCP(0x6d138afb, 0x42faf0d4),
STCP(0x6cf934fc, 0x4325c135), STCP(0x6cdece2f, 0x4350873c),
STCP(0x6cc45698, 0x437b42e1), STCP(0x6ca9ce3b, 0x43a5f41e),
STCP(0x6c8f351c, 0x43d09aed), STCP(0x6c748b3f, 0x43fb3746),
STCP(0x6c59d0a9, 0x4425c923), STCP(0x6c3f055d, 0x4450507e),
STCP(0x6c242960, 0x447acd50), STCP(0x6c093cb6, 0x44a53f93),
STCP(0x6bee3f62, 0x44cfa740), STCP(0x6bd3316a, 0x44fa0450),
STCP(0x6bb812d1, 0x452456bd), STCP(0x6b9ce39b, 0x454e9e80),
STCP(0x6b81a3cd, 0x4578db93), STCP(0x6b66536b, 0x45a30df0),
STCP(0x6b4af279, 0x45cd358f), STCP(0x6b2f80fb, 0x45f7526b),
STCP(0x6b13fef5, 0x4621647d), STCP(0x6af86c6c, 0x464b6bbe),
STCP(0x6adcc964, 0x46756828), STCP(0x6ac115e2, 0x469f59b4),
STCP(0x6aa551e9, 0x46c9405c), STCP(0x6a897d7d, 0x46f31c1a),
STCP(0x6a6d98a4, 0x471cece7), STCP(0x6a51a361, 0x4746b2bc),
STCP(0x6a359db9, 0x47706d93), STCP(0x6a1987b0, 0x479a1d67),
STCP(0x69fd614a, 0x47c3c22f), STCP(0x69e12a8c, 0x47ed5be6),
STCP(0x69c4e37a, 0x4816ea86), STCP(0x69a88c19, 0x48406e08),
STCP(0x698c246c, 0x4869e665), STCP(0x696fac78, 0x48935397),
STCP(0x69532442, 0x48bcb599), STCP(0x69368bce, 0x48e60c62),
STCP(0x6919e320, 0x490f57ee), STCP(0x68fd2a3d, 0x49389836),
STCP(0x68e06129, 0x4961cd33), STCP(0x68c387e9, 0x498af6df),
STCP(0x68a69e81, 0x49b41533), STCP(0x6889a4f6, 0x49dd282a),
STCP(0x686c9b4b, 0x4a062fbd), STCP(0x684f8186, 0x4a2f2be6),
STCP(0x683257ab, 0x4a581c9e), STCP(0x68151dbe, 0x4a8101de),
STCP(0x67f7d3c5, 0x4aa9dba2), STCP(0x67da79c3, 0x4ad2a9e2),
STCP(0x67bd0fbd, 0x4afb6c98), STCP(0x679f95b7, 0x4b2423be),
STCP(0x67820bb7, 0x4b4ccf4d), STCP(0x676471c0, 0x4b756f40),
STCP(0x6746c7d8, 0x4b9e0390), STCP(0x67290e02, 0x4bc68c36),
STCP(0x670b4444, 0x4bef092d), STCP(0x66ed6aa1, 0x4c177a6e),
STCP(0x66cf8120, 0x4c3fdff4), STCP(0x66b187c3, 0x4c6839b7),
STCP(0x66937e91, 0x4c9087b1), STCP(0x6675658c, 0x4cb8c9dd),
STCP(0x66573cbb, 0x4ce10034), STCP(0x66390422, 0x4d092ab0),
STCP(0x661abbc5, 0x4d31494b), STCP(0x65fc63a9, 0x4d595bfe),
STCP(0x65ddfbd3, 0x4d8162c4), STCP(0x65bf8447, 0x4da95d96),
STCP(0x65a0fd0b, 0x4dd14c6e), STCP(0x65826622, 0x4df92f46),
STCP(0x6563bf92, 0x4e210617), STCP(0x6545095f, 0x4e48d0dd),
STCP(0x6526438f, 0x4e708f8f), STCP(0x65076e25, 0x4e984229),
STCP(0x64e88926, 0x4ebfe8a5), STCP(0x64c99498, 0x4ee782fb),
STCP(0x64aa907f, 0x4f0f1126), STCP(0x648b7ce0, 0x4f369320),
STCP(0x646c59bf, 0x4f5e08e3), STCP(0x644d2722, 0x4f857269),
STCP(0x642de50d, 0x4faccfab), STCP(0x640e9386, 0x4fd420a4),
STCP(0x63ef3290, 0x4ffb654d), STCP(0x63cfc231, 0x50229da1),
STCP(0x63b0426d, 0x5049c999), STCP(0x6390b34a, 0x5070e92f),
STCP(0x637114cc, 0x5097fc5e), STCP(0x635166f9, 0x50bf031f),
STCP(0x6331a9d4, 0x50e5fd6d), STCP(0x6311dd64, 0x510ceb40),
STCP(0x62f201ac, 0x5133cc94), STCP(0x62d216b3, 0x515aa162),
STCP(0x62b21c7b, 0x518169a5), STCP(0x6292130c, 0x51a82555),
STCP(0x6271fa69, 0x51ced46e), STCP(0x6251d298, 0x51f576ea),
STCP(0x62319b9d, 0x521c0cc2), STCP(0x6211557e, 0x524295f0),
STCP(0x61f1003f, 0x5269126e), STCP(0x61d09be5, 0x528f8238),
STCP(0x61b02876, 0x52b5e546), STCP(0x618fa5f7, 0x52dc3b92),
STCP(0x616f146c, 0x53028518), STCP(0x614e73da, 0x5328c1d0),
STCP(0x612dc447, 0x534ef1b5), STCP(0x610d05b7, 0x537514c2),
STCP(0x60ec3830, 0x539b2af0), STCP(0x60cb5bb7, 0x53c13439),
STCP(0x60aa7050, 0x53e73097), STCP(0x60897601, 0x540d2005),
STCP(0x60686ccf, 0x5433027d), STCP(0x604754bf, 0x5458d7f9),
STCP(0x60262dd6, 0x547ea073), STCP(0x6004f819, 0x54a45be6),
STCP(0x5fe3b38d, 0x54ca0a4b), STCP(0x5fc26038, 0x54efab9c),
STCP(0x5fa0fe1f, 0x55153fd4), STCP(0x5f7f8d46, 0x553ac6ee),
STCP(0x5f5e0db3, 0x556040e2), STCP(0x5f3c7f6b, 0x5585adad),
STCP(0x5f1ae274, 0x55ab0d46), STCP(0x5ef936d1, 0x55d05faa),
STCP(0x5ed77c8a, 0x55f5a4d2), STCP(0x5eb5b3a2, 0x561adcb9),
STCP(0x5e93dc1f, 0x56400758), STCP(0x5e71f606, 0x566524aa),
STCP(0x5e50015d, 0x568a34a9), STCP(0x5e2dfe29, 0x56af3750),
STCP(0x5e0bec6e, 0x56d42c99), STCP(0x5de9cc33, 0x56f9147e),
STCP(0x5dc79d7c, 0x571deefa), STCP(0x5da5604f, 0x5742bc06),
STCP(0x5d8314b1, 0x57677b9d), STCP(0x5d60baa7, 0x578c2dba),
STCP(0x5d3e5237, 0x57b0d256), STCP(0x5d1bdb65, 0x57d5696d),
STCP(0x5cf95638, 0x57f9f2f8), STCP(0x5cd6c2b5, 0x581e6ef1),
STCP(0x5cb420e0, 0x5842dd54), STCP(0x5c9170bf, 0x58673e1b),
STCP(0x5c6eb258, 0x588b9140), STCP(0x5c4be5b0, 0x58afd6bd),
STCP(0x5c290acc, 0x58d40e8c), STCP(0x5c0621b2, 0x58f838a9),
STCP(0x5be32a67, 0x591c550e), STCP(0x5bc024f0, 0x594063b5),
STCP(0x5b9d1154, 0x59646498), STCP(0x5b79ef96, 0x598857b2),
STCP(0x5b56bfbd, 0x59ac3cfd), STCP(0x5b3381ce, 0x59d01475),
STCP(0x5b1035cf, 0x59f3de12), STCP(0x5aecdbc5, 0x5a1799d1),
STCP(0x5ac973b5, 0x5a3b47ab), STCP(0x5aa5fda5, 0x5a5ee79a),
STCP(0x5a82799a, 0x5a82799a),
};
RAM_ALIGN
LNK_SECTION_CONSTDATA
const FIXP_STB RotVectorReal6[] = {
STC(0x40000000),
STC(0xc0000000),
};
RAM_ALIGN
LNK_SECTION_CONSTDATA
const FIXP_STB RotVectorImag6[] = {
STC(0x6ed9eba1),
STC(0x6ed9eba1),
};
RAM_ALIGN
LNK_SECTION_CONSTDATA
const FIXP_STB RotVectorReal12[] = {
STC(0x6ed9eba1),
STC(0x40000000),
STC(0x40000000),
STC(0xc0000000),
};
RAM_ALIGN
LNK_SECTION_CONSTDATA
const FIXP_STB RotVectorImag12[] = {
STC(0x40000000),
STC(0x6ed9eba1),
STC(0x6ed9eba1),
STC(0x6ed9eba1),
};
RAM_ALIGN
LNK_SECTION_CONSTDATA
const FIXP_STB RotVectorReal24[] = {
STC(0x7ba3751d), STC(0x6ed9eba1), STC(0x5a82799a), STC(0x40000000),
STC(0x2120fb83), STC(0x00000000), STC(0xdedf047d), STC(0xc0000000),
STC(0xa57d8666), STC(0x9126145f), STC(0x845c8ae3),
};
RAM_ALIGN
LNK_SECTION_CONSTDATA
const FIXP_STB RotVectorImag24[] = {
STC(0x2120fb83), STC(0x40000000), STC(0x5a82799a), STC(0x6ed9eba1),
STC(0x7ba3751d), STC(0x7fffffff), STC(0x7ba3751d), STC(0x6ed9eba1),
STC(0x5a82799a), STC(0x40000000), STC(0x2120fb83),
};
RAM_ALIGN
LNK_SECTION_CONSTDATA
const FIXP_STB RotVectorReal48[] = {
STC(0x7ee7aa4c), STC(0x7ba3751d), STC(0x7641af3d), STC(0x7ba3751d),
STC(0x6ed9eba1), STC(0x5a82799a), STC(0x7641af3d), STC(0x5a82799a),
STC(0x30fbc54d), STC(0x6ed9eba1), STC(0x40000000), STC(0x00000000),
STC(0x658c9a2d), STC(0x2120fb83), STC(0xcf043ab3), STC(0x5a82799a),
STC(0x00000000), STC(0xa57d8666), STC(0x4debe4fe), STC(0xdedf047d),
STC(0x89be50c3), STC(0x40000000), STC(0xc0000000), STC(0x80000000),
STC(0x30fbc54d), STC(0xa57d8666), STC(0x89be50c3), STC(0x2120fb83),
STC(0x9126145f), STC(0xa57d8666), STC(0x10b5150f), STC(0x845c8ae3),
STC(0xcf043ab3),
};
RAM_ALIGN
LNK_SECTION_CONSTDATA
const FIXP_STB RotVectorImag48[] = {
STC(0x10b5150f), STC(0x2120fb83), STC(0x30fbc54d), STC(0x2120fb83),
STC(0x40000000), STC(0x5a82799a), STC(0x30fbc54d), STC(0x5a82799a),
STC(0x7641af3d), STC(0x40000000), STC(0x6ed9eba1), STC(0x7fffffff),
STC(0x4debe4fe), STC(0x7ba3751d), STC(0x7641af3d), STC(0x5a82799a),
STC(0x7fffffff), STC(0x5a82799a), STC(0x658c9a2d), STC(0x7ba3751d),
STC(0x30fbc54d), STC(0x6ed9eba1), STC(0x6ed9eba1), STC(0x00000000),
STC(0x7641af3d), STC(0x5a82799a), STC(0xcf043ab3), STC(0x7ba3751d),
STC(0x40000000), STC(0xa57d8666), STC(0x7ee7aa4c), STC(0x2120fb83),
STC(0x89be50c3),
};
RAM_ALIGN
LNK_SECTION_CONSTDATA
const FIXP_STB RotVectorReal80[] = {
STC(0x7f9afcb9), STC(0x7e6c9251), STC(0x7c769e18), STC(0x79bc384d),
STC(0x7e6c9251), STC(0x79bc384d), STC(0x720c8075), STC(0x678dde6e),
STC(0x7c769e18), STC(0x720c8075), STC(0x6154fb91), STC(0x4b3c8c12),
STC(0x79bc384d), STC(0x678dde6e), STC(0x4b3c8c12), STC(0x278dde6e),
STC(0x7641af3d), STC(0x5a82799a), STC(0x30fbc54d), STC(0x00000000),
STC(0x720c8075), STC(0x4b3c8c12), STC(0x14060b68), STC(0xd8722192),
STC(0x6d23501b), STC(0x3a1c5c57), STC(0xf5f50d67), STC(0xb4c373ee),
STC(0x678dde6e), STC(0x278dde6e), STC(0xd8722192), STC(0x98722192),
STC(0x6154fb91), STC(0x14060b68), STC(0xbd1ec45c), STC(0x8643c7b3),
STC(0x5a82799a), STC(0x00000000), STC(0xa57d8666), STC(0x80000000),
STC(0x53211d18), STC(0xebf9f498), STC(0x92dcafe5), STC(0x8643c7b3),
STC(0x4b3c8c12), STC(0xd8722192), STC(0x8643c7b3), STC(0x98722192),
STC(0x42e13ba4), STC(0xc5e3a3a9), STC(0x80650347), STC(0xb4c373ee),
STC(0x3a1c5c57), STC(0xb4c373ee), STC(0x81936daf), STC(0xd8722192),
STC(0x30fbc54d), STC(0xa57d8666), STC(0x89be50c3), STC(0x00000000),
};
RAM_ALIGN
LNK_SECTION_CONSTDATA
const FIXP_STB RotVectorImag80[] = {
STC(0x0a0af299), STC(0x14060b68), STC(0x1de189a6), STC(0x278dde6e),
STC(0x14060b68), STC(0x278dde6e), STC(0x3a1c5c57), STC(0x4b3c8c12),
STC(0x1de189a6), STC(0x3a1c5c57), STC(0x53211d18), STC(0x678dde6e),
STC(0x278dde6e), STC(0x4b3c8c12), STC(0x678dde6e), STC(0x79bc384d),
STC(0x30fbc54d), STC(0x5a82799a), STC(0x7641af3d), STC(0x7fffffff),
STC(0x3a1c5c57), STC(0x678dde6e), STC(0x7e6c9251), STC(0x79bc384d),
STC(0x42e13ba4), STC(0x720c8075), STC(0x7f9afcb9), STC(0x678dde6e),
STC(0x4b3c8c12), STC(0x79bc384d), STC(0x79bc384d), STC(0x4b3c8c12),
STC(0x53211d18), STC(0x7e6c9251), STC(0x6d23501b), STC(0x278dde6e),
STC(0x5a82799a), STC(0x7fffffff), STC(0x5a82799a), STC(0x00000000),
STC(0x6154fb91), STC(0x7e6c9251), STC(0x42e13ba4), STC(0xd8722192),
STC(0x678dde6e), STC(0x79bc384d), STC(0x278dde6e), STC(0xb4c373ee),
STC(0x6d23501b), STC(0x720c8075), STC(0x0a0af299), STC(0x98722192),
STC(0x720c8075), STC(0x678dde6e), STC(0xebf9f498), STC(0x8643c7b3),
STC(0x7641af3d), STC(0x5a82799a), STC(0xcf043ab3), STC(0x80000000),
};
RAM_ALIGN
LNK_SECTION_CONSTDATA
const FIXP_STB RotVectorReal96[] = {
STC(0x7fb9d759), STC(0x7ee7aa4c), STC(0x7ee7aa4c), STC(0x7ba3751d),
STC(0x7d8a5f40), STC(0x7641af3d), STC(0x7ba3751d), STC(0x6ed9eba1),
STC(0x793501a9), STC(0x658c9a2d), STC(0x7641af3d), STC(0x5a82799a),
STC(0x72ccb9db), STC(0x4debe4fe), STC(0x6ed9eba1), STC(0x40000000),
STC(0x6a6d98a4), STC(0x30fbc54d), STC(0x658c9a2d), STC(0x2120fb83),
STC(0x603c496c), STC(0x10b5150f), STC(0x5a82799a), STC(0x00000000),
STC(0x54657194), STC(0xef4aeaf1), STC(0x4debe4fe), STC(0xdedf047d),
STC(0x471cece7), STC(0xcf043ab3), STC(0x40000000), STC(0xc0000000),
STC(0x389cea72), STC(0xb2141b02), STC(0x30fbc54d), STC(0xa57d8666),
STC(0x2924edac), STC(0x9a7365d3), STC(0x2120fb83), STC(0x9126145f),
STC(0x18f8b83c), STC(0x89be50c3), STC(0x10b5150f), STC(0x845c8ae3),
STC(0x085f2137), STC(0x811855b4), STC(0x00000000), STC(0x80000000),
STC(0xf7a0dec9), STC(0x811855b4), STC(0xef4aeaf1), STC(0x845c8ae3),
STC(0xe70747c4), STC(0x89be50c3), STC(0xdedf047d), STC(0x9126145f),
STC(0xd6db1254), STC(0x9a7365d3), STC(0xcf043ab3), STC(0xa57d8666),
STC(0xc763158e), STC(0xb2141b02),
};
RAM_ALIGN
LNK_SECTION_CONSTDATA
const FIXP_STB RotVectorImag96[] = {
STC(0x085f2137), STC(0x10b5150f), STC(0x10b5150f), STC(0x2120fb83),
STC(0x18f8b83c), STC(0x30fbc54d), STC(0x2120fb83), STC(0x40000000),
STC(0x2924edac), STC(0x4debe4fe), STC(0x30fbc54d), STC(0x5a82799a),
STC(0x389cea72), STC(0x658c9a2d), STC(0x40000000), STC(0x6ed9eba1),
STC(0x471cece7), STC(0x7641af3d), STC(0x4debe4fe), STC(0x7ba3751d),
STC(0x54657194), STC(0x7ee7aa4c), STC(0x5a82799a), STC(0x7fffffff),
STC(0x603c496c), STC(0x7ee7aa4c), STC(0x658c9a2d), STC(0x7ba3751d),
STC(0x6a6d98a4), STC(0x7641af3d), STC(0x6ed9eba1), STC(0x6ed9eba1),
STC(0x72ccb9db), STC(0x658c9a2d), STC(0x7641af3d), STC(0x5a82799a),
STC(0x793501a9), STC(0x4debe4fe), STC(0x7ba3751d), STC(0x40000000),
STC(0x7d8a5f40), STC(0x30fbc54d), STC(0x7ee7aa4c), STC(0x2120fb83),
STC(0x7fb9d759), STC(0x10b5150f), STC(0x7fffffff), STC(0x00000000),
STC(0x7fb9d759), STC(0xef4aeaf1), STC(0x7ee7aa4c), STC(0xdedf047d),
STC(0x7d8a5f40), STC(0xcf043ab3), STC(0x7ba3751d), STC(0xc0000000),
STC(0x793501a9), STC(0xb2141b02), STC(0x7641af3d), STC(0xa57d8666),
STC(0x72ccb9db), STC(0x9a7365d3),
};
RAM_ALIGN
LNK_SECTION_CONSTDATA
const FIXP_STB RotVectorReal384[] = {
STC(0x7ffb9d15), STC(0x7fee74a2), STC(0x7fd8878e), STC(0x7fb9d759),
STC(0x7f92661d), STC(0x7f62368f), STC(0x7f294bfd), STC(0x7ee7aa4c),
STC(0x7e9d55fc), STC(0x7e4a5426), STC(0x7deeaa7a), STC(0x7fee74a2),
STC(0x7fb9d759), STC(0x7f62368f), STC(0x7ee7aa4c), STC(0x7e4a5426),
STC(0x7d8a5f40), STC(0x7ca80038), STC(0x7ba3751d), STC(0x7a7d055b),
STC(0x793501a9), STC(0x77cbc3f2), STC(0x7fd8878e), STC(0x7f62368f),
STC(0x7e9d55fc), STC(0x7d8a5f40), STC(0x7c29fbee), STC(0x7a7d055b),
STC(0x78848414), STC(0x7641af3d), STC(0x73b5ebd1), STC(0x70e2cbc6),
STC(0x6dca0d14), STC(0x7fb9d759), STC(0x7ee7aa4c), STC(0x7d8a5f40),
STC(0x7ba3751d), STC(0x793501a9), STC(0x7641af3d), STC(0x72ccb9db),
STC(0x6ed9eba1), STC(0x6a6d98a4), STC(0x658c9a2d), STC(0x603c496c),
STC(0x7f92661d), STC(0x7e4a5426), STC(0x7c29fbee), STC(0x793501a9),
STC(0x757075ac), STC(0x70e2cbc6), STC(0x6b93d02e), STC(0x658c9a2d),
STC(0x5ed77c8a), STC(0x577ff3da), STC(0x4f9292dc), STC(0x7f62368f),
STC(0x7d8a5f40), STC(0x7a7d055b), STC(0x7641af3d), STC(0x70e2cbc6),
STC(0x6a6d98a4), STC(0x62f201ac), STC(0x5a82799a), STC(0x5133cc94),
STC(0x471cece7), STC(0x3c56ba70), STC(0x7f294bfd), STC(0x7ca80038),
STC(0x78848414), STC(0x72ccb9db), STC(0x6b93d02e), STC(0x62f201ac),
STC(0x590443a7), STC(0x4debe4fe), STC(0x41ce1e65), STC(0x34d3957e),
STC(0x2727d486), STC(0x7ee7aa4c), STC(0x7ba3751d), STC(0x7641af3d),
STC(0x6ed9eba1), STC(0x658c9a2d), STC(0x5a82799a), STC(0x4debe4fe),
STC(0x40000000), STC(0x30fbc54d), STC(0x2120fb83), STC(0x10b5150f),
STC(0x7e9d55fc), STC(0x7a7d055b), STC(0x73b5ebd1), STC(0x6a6d98a4),
STC(0x5ed77c8a), STC(0x5133cc94), STC(0x41ce1e65), STC(0x30fbc54d),
STC(0x1f19f97b), STC(0x0c8bd35e), STC(0xf9b82684), STC(0x7e4a5426),
STC(0x793501a9), STC(0x70e2cbc6), STC(0x658c9a2d), STC(0x577ff3da),
STC(0x471cece7), STC(0x34d3957e), STC(0x2120fb83), STC(0x0c8bd35e),
STC(0xf7a0dec9), STC(0xe2ef2a3e), STC(0x7deeaa7a), STC(0x77cbc3f2),
STC(0x6dca0d14), STC(0x603c496c), STC(0x4f9292dc), STC(0x3c56ba70),
STC(0x2727d486), STC(0x10b5150f), STC(0xf9b82684), STC(0xe2ef2a3e),
STC(0xcd1693f7), STC(0x7d8a5f40), STC(0x7641af3d), STC(0x6a6d98a4),
STC(0x5a82799a), STC(0x471cece7), STC(0x30fbc54d), STC(0x18f8b83c),
STC(0x00000000), STC(0xe70747c4), STC(0xcf043ab3), STC(0xb8e31319),
STC(0x7d1d7958), STC(0x74972f92), STC(0x66cf8120), STC(0x54657194),
STC(0x3e2d7eb1), STC(0x25280c5e), STC(0x0a75d60e), STC(0xef4aeaf1),
STC(0xd4e0cb15), STC(0xbc6845ce), STC(0xa6fbbc59), STC(0x7ca80038),
STC(0x72ccb9db), STC(0x62f201ac), STC(0x4debe4fe), STC(0x34d3957e),
STC(0x18f8b83c), STC(0xfbcfdc71), STC(0xdedf047d), STC(0xc3a94590),
STC(0xab9a8e6c), STC(0x97f4a3cd), STC(0x7c29fbee), STC(0x70e2cbc6),
STC(0x5ed77c8a), STC(0x471cece7), STC(0x2b1f34eb), STC(0x0c8bd35e),
STC(0xed37ef91), STC(0xcf043ab3), STC(0xb3c0200c), STC(0x9d0dfe54),
STC(0x8c4a142f), STC(0x7ba3751d), STC(0x6ed9eba1), STC(0x5a82799a),
STC(0x40000000), STC(0x2120fb83), STC(0x00000000), STC(0xdedf047d),
STC(0xc0000000), STC(0xa57d8666), STC(0x9126145f), STC(0x845c8ae3),
STC(0x7b1474fd), STC(0x6cb2a837), STC(0x55f5a4d2), STC(0x389cea72),
STC(0x16ea0646), STC(0xf3742ca2), STC(0xd0f53ce0), STC(0xb2141b02),
STC(0x99307ee0), STC(0x88343c0e), STC(0x806d99e3), STC(0x7a7d055b),
STC(0x6a6d98a4), STC(0x5133cc94), STC(0x30fbc54d), STC(0x0c8bd35e),
STC(0xe70747c4), STC(0xc3a94590), STC(0xa57d8666), STC(0x8f1d343a),
STC(0x8275a0c0), STC(0x809dc971), STC(0x79dd3098), STC(0x680b5c33),
STC(0x4c3fdff4), STC(0x2924edac), STC(0x02182427), STC(0xdad7f3a2),
STC(0xb727b9f7), STC(0x9a7365d3), STC(0x877b7bec), STC(0x80118b5e),
STC(0x84eb8b03), STC(0x793501a9), STC(0x658c9a2d), STC(0x471cece7),
STC(0x2120fb83), STC(0xf7a0dec9), STC(0xcf043ab3), STC(0xab9a8e6c),
STC(0x9126145f), STC(0x8275a0c0), STC(0x811855b4), STC(0x8d334625),
STC(0x78848414), STC(0x62f201ac), STC(0x41ce1e65), STC(0x18f8b83c),
STC(0xed37ef91), STC(0xc3a94590), STC(0xa1288376), STC(0x89be50c3),
STC(0x80277872), STC(0x8582faa5), STC(0x99307ee0), STC(0x77cbc3f2),
STC(0x603c496c), STC(0x3c56ba70), STC(0x10b5150f), STC(0xe2ef2a3e),
STC(0xb8e31319), STC(0x97f4a3cd), STC(0x845c8ae3), STC(0x809dc971),
STC(0x8d334625), STC(0xa8800c26), STC(0x770acdec), STC(0x5d6c2f99),
STC(0x36ba2014), STC(0x085f2137), STC(0xd8d82b7a), STC(0xaecc336c),
STC(0x901dcec4), STC(0x811855b4), STC(0x83d60412), STC(0x97f4a3cd),
STC(0xbaa34bf4), STC(0x7641af3d), STC(0x5a82799a), STC(0x30fbc54d),
STC(0x00000000), STC(0xcf043ab3), STC(0xa57d8666), STC(0x89be50c3),
STC(0x80000000), STC(0x89be50c3), STC(0xa57d8666), STC(0xcf043ab3),
STC(0x757075ac), STC(0x577ff3da), STC(0x2b1f34eb), STC(0xf7a0dec9),
STC(0xc5842c7e), STC(0x9d0dfe54), STC(0x84eb8b03), STC(0x811855b4),
STC(0x9235f2ec), STC(0xb5715eef), STC(0xe4fa4bf1), STC(0x74972f92),
STC(0x54657194), STC(0x25280c5e), STC(0xef4aeaf1), STC(0xbc6845ce),
STC(0x9592675c), STC(0x81b5abda), STC(0x845c8ae3), STC(0x9d0dfe54),
STC(0xc763158e), STC(0xfbcfdc71), STC(0x73b5ebd1), STC(0x5133cc94),
STC(0x1f19f97b), STC(0xe70747c4), STC(0xb3c0200c), STC(0x8f1d343a),
STC(0x80277872), STC(0x89be50c3), STC(0xaa0a5b2e), STC(0xdad7f3a2),
STC(0x12c8106f), STC(0x72ccb9db), STC(0x4debe4fe), STC(0x18f8b83c),
STC(0xdedf047d), STC(0xab9a8e6c), STC(0x89be50c3), STC(0x804628a7),
STC(0x9126145f), STC(0xb8e31319), STC(0xef4aeaf1), STC(0x2924edac),
STC(0x71dba9ab), STC(0x4a8ea111), STC(0x12c8106f), STC(0xd6db1254),
STC(0xa405847e), STC(0x8582faa5), STC(0x82115586), STC(0x9a7365d3),
STC(0xc945dfec), STC(0x0430238f), STC(0x3e2d7eb1), STC(0x70e2cbc6),
STC(0x471cece7), STC(0x0c8bd35e), STC(0xcf043ab3), STC(0x9d0dfe54),
STC(0x8275a0c0), STC(0x8582faa5), STC(0xa57d8666), STC(0xdad7f3a2),
STC(0x18f8b83c), STC(0x5133cc94), STC(0x6fe2313c), STC(0x4397ba32),
STC(0x0647d97c), STC(0xc763158e), STC(0x96bfea3d), STC(0x809dc971),
STC(0x8a8f8a54), STC(0xb2141b02), STC(0xed37ef91), STC(0x2d168792),
STC(0x619a7dce),
};
RAM_ALIGN
LNK_SECTION_CONSTDATA
const FIXP_STB RotVectorImag384[] = {
STC(0x02182427), STC(0x0430238f), STC(0x0647d97c), STC(0x085f2137),
STC(0x0a75d60e), STC(0x0c8bd35e), STC(0x0ea0f48c), STC(0x10b5150f),
STC(0x12c8106f), STC(0x14d9c245), STC(0x16ea0646), STC(0x0430238f),
STC(0x085f2137), STC(0x0c8bd35e), STC(0x10b5150f), STC(0x14d9c245),
STC(0x18f8b83c), STC(0x1d10d5c2), STC(0x2120fb83), STC(0x25280c5e),
STC(0x2924edac), STC(0x2d168792), STC(0x0647d97c), STC(0x0c8bd35e),
STC(0x12c8106f), STC(0x18f8b83c), STC(0x1f19f97b), STC(0x25280c5e),
STC(0x2b1f34eb), STC(0x30fbc54d), STC(0x36ba2014), STC(0x3c56ba70),
STC(0x41ce1e65), STC(0x085f2137), STC(0x10b5150f), STC(0x18f8b83c),
STC(0x2120fb83), STC(0x2924edac), STC(0x30fbc54d), STC(0x389cea72),
STC(0x40000000), STC(0x471cece7), STC(0x4debe4fe), STC(0x54657194),
STC(0x0a75d60e), STC(0x14d9c245), STC(0x1f19f97b), STC(0x2924edac),
STC(0x32e96c09), STC(0x3c56ba70), STC(0x455cb40c), STC(0x4debe4fe),
STC(0x55f5a4d2), STC(0x5d6c2f99), STC(0x6442bd7e), STC(0x0c8bd35e),
STC(0x18f8b83c), STC(0x25280c5e), STC(0x30fbc54d), STC(0x3c56ba70),
STC(0x471cece7), STC(0x5133cc94), STC(0x5a82799a), STC(0x62f201ac),
STC(0x6a6d98a4), STC(0x70e2cbc6), STC(0x0ea0f48c), STC(0x1d10d5c2),
STC(0x2b1f34eb), STC(0x389cea72), STC(0x455cb40c), STC(0x5133cc94),
STC(0x5bfa7b82), STC(0x658c9a2d), STC(0x6dca0d14), STC(0x74972f92),
STC(0x79dd3098), STC(0x10b5150f), STC(0x2120fb83), STC(0x30fbc54d),
STC(0x40000000), STC(0x4debe4fe), STC(0x5a82799a), STC(0x658c9a2d),
STC(0x6ed9eba1), STC(0x7641af3d), STC(0x7ba3751d), STC(0x7ee7aa4c),
STC(0x12c8106f), STC(0x25280c5e), STC(0x36ba2014), STC(0x471cece7),
STC(0x55f5a4d2), STC(0x62f201ac), STC(0x6dca0d14), STC(0x7641af3d),
STC(0x7c29fbee), STC(0x7f62368f), STC(0x7fd8878e), STC(0x14d9c245),
STC(0x2924edac), STC(0x3c56ba70), STC(0x4debe4fe), STC(0x5d6c2f99),
STC(0x6a6d98a4), STC(0x74972f92), STC(0x7ba3751d), STC(0x7f62368f),
STC(0x7fb9d759), STC(0x7ca80038), STC(0x16ea0646), STC(0x2d168792),
STC(0x41ce1e65), STC(0x54657194), STC(0x6442bd7e), STC(0x70e2cbc6),
STC(0x79dd3098), STC(0x7ee7aa4c), STC(0x7fd8878e), STC(0x7ca80038),
STC(0x757075ac), STC(0x18f8b83c), STC(0x30fbc54d), STC(0x471cece7),
STC(0x5a82799a), STC(0x6a6d98a4), STC(0x7641af3d), STC(0x7d8a5f40),
STC(0x7fffffff), STC(0x7d8a5f40), STC(0x7641af3d), STC(0x6a6d98a4),
STC(0x1b05b40f), STC(0x34d3957e), STC(0x4c3fdff4), STC(0x603c496c),
STC(0x6fe2313c), STC(0x7a7d055b), STC(0x7f92661d), STC(0x7ee7aa4c),
STC(0x78848414), STC(0x6cb2a837), STC(0x5bfa7b82), STC(0x1d10d5c2),
STC(0x389cea72), STC(0x5133cc94), STC(0x658c9a2d), STC(0x74972f92),
STC(0x7d8a5f40), STC(0x7fee74a2), STC(0x7ba3751d), STC(0x70e2cbc6),
STC(0x603c496c), STC(0x4a8ea111), STC(0x1f19f97b), STC(0x3c56ba70),
STC(0x55f5a4d2), STC(0x6a6d98a4), STC(0x78848414), STC(0x7f62368f),
STC(0x7e9d55fc), STC(0x7641af3d), STC(0x66cf8120), STC(0x5133cc94),
STC(0x36ba2014), STC(0x2120fb83), STC(0x40000000), STC(0x5a82799a),
STC(0x6ed9eba1), STC(0x7ba3751d), STC(0x7fffffff), STC(0x7ba3751d),
STC(0x6ed9eba1), STC(0x5a82799a), STC(0x40000000), STC(0x2120fb83),
STC(0x2325b847), STC(0x4397ba32), STC(0x5ed77c8a), STC(0x72ccb9db),
STC(0x7deeaa7a), STC(0x7f62368f), STC(0x770acdec), STC(0x658c9a2d),
STC(0x4c3fdff4), STC(0x2d168792), STC(0x0a75d60e), STC(0x25280c5e),
STC(0x471cece7), STC(0x62f201ac), STC(0x7641af3d), STC(0x7f62368f),
STC(0x7d8a5f40), STC(0x70e2cbc6), STC(0x5a82799a), STC(0x3c56ba70),
STC(0x18f8b83c), STC(0xf3742ca2), STC(0x2727d486), STC(0x4a8ea111),
STC(0x66cf8120), STC(0x793501a9), STC(0x7ffb9d15), STC(0x7a7d055b),
STC(0x694015c3), STC(0x4debe4fe), STC(0x2b1f34eb), STC(0x0430238f),
STC(0xdcda47b9), STC(0x2924edac), STC(0x4debe4fe), STC(0x6a6d98a4),
STC(0x7ba3751d), STC(0x7fb9d759), STC(0x7641af3d), STC(0x603c496c),
STC(0x40000000), STC(0x18f8b83c), STC(0xef4aeaf1), STC(0xc763158e),
STC(0x2b1f34eb), STC(0x5133cc94), STC(0x6dca0d14), STC(0x7d8a5f40),
STC(0x7e9d55fc), STC(0x70e2cbc6), STC(0x55f5a4d2), STC(0x30fbc54d),
STC(0x0647d97c), STC(0xdad7f3a2), STC(0xb3c0200c), STC(0x2d168792),
STC(0x54657194), STC(0x70e2cbc6), STC(0x7ee7aa4c), STC(0x7ca80038),
STC(0x6a6d98a4), STC(0x4a8ea111), STC(0x2120fb83), STC(0xf3742ca2),
STC(0xc763158e), STC(0xa293d067), STC(0x2f0ac320), STC(0x577ff3da),
STC(0x73b5ebd1), STC(0x7fb9d759), STC(0x79dd3098), STC(0x62f201ac),
STC(0x3e2d7eb1), STC(0x10b5150f), STC(0xe0e60685), STC(0xb5715eef),
STC(0x946c2fd2), STC(0x30fbc54d), STC(0x5a82799a), STC(0x7641af3d),
STC(0x7fffffff), STC(0x7641af3d), STC(0x5a82799a), STC(0x30fbc54d),
STC(0x00000000), STC(0xcf043ab3), STC(0xa57d8666), STC(0x89be50c3),
STC(0x32e96c09), STC(0x5d6c2f99), STC(0x78848414), STC(0x7fb9d759),
STC(0x71dba9ab), STC(0x5133cc94), STC(0x2325b847), STC(0xef4aeaf1),
STC(0xbe31e19b), STC(0x97f4a3cd), STC(0x82e286a8), STC(0x34d3957e),
STC(0x603c496c), STC(0x7a7d055b), STC(0x7ee7aa4c), STC(0x6cb2a837),
STC(0x471cece7), STC(0x14d9c245), STC(0xdedf047d), STC(0xaecc336c),
STC(0x8d334625), STC(0x80118b5e), STC(0x36ba2014), STC(0x62f201ac),
STC(0x7c29fbee), STC(0x7d8a5f40), STC(0x66cf8120), STC(0x3c56ba70),
STC(0x0647d97c), STC(0xcf043ab3), STC(0xa1288376), STC(0x8582faa5),
STC(0x8162aa04), STC(0x389cea72), STC(0x658c9a2d), STC(0x7d8a5f40),
STC(0x7ba3751d), STC(0x603c496c), STC(0x30fbc54d), STC(0xf7a0dec9),
STC(0xc0000000), STC(0x9592675c), STC(0x811855b4), STC(0x86cafe57),
STC(0x3a7bd382), STC(0x680b5c33), STC(0x7e9d55fc), STC(0x793501a9),
STC(0x590443a7), STC(0x25280c5e), STC(0xe915f9ba), STC(0xb2141b02),
STC(0x8c4a142f), STC(0x80118b5e), STC(0x901dcec4), STC(0x3c56ba70),
STC(0x6a6d98a4), STC(0x7f62368f), STC(0x7641af3d), STC(0x5133cc94),
STC(0x18f8b83c), STC(0xdad7f3a2), STC(0xa57d8666), STC(0x8582faa5),
STC(0x8275a0c0), STC(0x9d0dfe54), STC(0x3e2d7eb1), STC(0x6cb2a837),
STC(0x7fd8878e), STC(0x72ccb9db), STC(0x48d84609), STC(0x0c8bd35e),
STC(0xcd1693f7), STC(0x9a7365d3), STC(0x8162aa04), STC(0x88343c0e),
STC(0xad308a71),
};
RAM_ALIGN
LNK_SECTION_CONSTDATA
const FIXP_STB RotVectorReal60[] = {
STC(0x7f4c7e54), STC(0x7d33f0ca), STC(0x79bc384d), STC(0x7d33f0ca),
STC(0x74ef0ebc), STC(0x678dde6e), STC(0x79bc384d), STC(0x678dde6e),
STC(0x4b3c8c12), STC(0x74ef0ebc), STC(0x55a6125c), STC(0x278dde6e),
STC(0x6ed9eba1), STC(0x40000000), STC(0x00000000), STC(0x678dde6e),
STC(0x278dde6e), STC(0xd8722192), STC(0x5f1f5ea1), STC(0x0d61304e),
STC(0xb4c373ee), STC(0x55a6125c), STC(0xf29ecfb2), STC(0x98722192),
STC(0x4b3c8c12), STC(0xd8722192), STC(0x8643c7b3), STC(0x40000000),
STC(0xc0000000), STC(0x80000000), STC(0x340ff242), STC(0xaa59eda4),
STC(0x8643c7b3), STC(0x278dde6e), STC(0x98722192), STC(0x98722192),
STC(0x1a9cd9ac), STC(0x8b10f144), STC(0xb4c373ee), STC(0x0d61304e),
STC(0x82cc0f36), STC(0xd8722192),
};
RAM_ALIGN
LNK_SECTION_CONSTDATA
const FIXP_STB RotVectorImag60[] = {
STC(0x0d61304e), STC(0x1a9cd9ac), STC(0x278dde6e), STC(0x1a9cd9ac),
STC(0x340ff242), STC(0x4b3c8c12), STC(0x278dde6e), STC(0x4b3c8c12),
STC(0x678dde6e), STC(0x340ff242), STC(0x5f1f5ea1), STC(0x79bc384d),
STC(0x40000000), STC(0x6ed9eba1), STC(0x7fffffff), STC(0x4b3c8c12),
STC(0x79bc384d), STC(0x79bc384d), STC(0x55a6125c), STC(0x7f4c7e54),
STC(0x678dde6e), STC(0x5f1f5ea1), STC(0x7f4c7e54), STC(0x4b3c8c12),
STC(0x678dde6e), STC(0x79bc384d), STC(0x278dde6e), STC(0x6ed9eba1),
STC(0x6ed9eba1), STC(0x00000000), STC(0x74ef0ebc), STC(0x5f1f5ea1),
STC(0xd8722192), STC(0x79bc384d), STC(0x4b3c8c12), STC(0xb4c373ee),
STC(0x7d33f0ca), STC(0x340ff242), STC(0x98722192), STC(0x7f4c7e54),
STC(0x1a9cd9ac), STC(0x8643c7b3),
};
RAM_ALIGN
LNK_SECTION_CONSTDATA
const FIXP_STB RotVectorReal120[] = {
STC(0x7fd317b4), STC(0x7f4c7e54), STC(0x7e6c9251), STC(0x7d33f0ca),
STC(0x7ba3751d), STC(0x79bc384d), STC(0x777f903c), STC(0x7f4c7e54),
STC(0x7d33f0ca), STC(0x79bc384d), STC(0x74ef0ebc), STC(0x6ed9eba1),
STC(0x678dde6e), STC(0x5f1f5ea1), STC(0x7e6c9251), STC(0x79bc384d),
STC(0x720c8075), STC(0x678dde6e), STC(0x5a82799a), STC(0x4b3c8c12),
STC(0x3a1c5c57), STC(0x7d33f0ca), STC(0x74ef0ebc), STC(0x678dde6e),
STC(0x55a6125c), STC(0x40000000), STC(0x278dde6e), STC(0x0d61304e),
STC(0x7ba3751d), STC(0x6ed9eba1), STC(0x5a82799a), STC(0x40000000),
STC(0x2120fb83), STC(0x00000000), STC(0xdedf047d), STC(0x79bc384d),
STC(0x678dde6e), STC(0x4b3c8c12), STC(0x278dde6e), STC(0x00000000),
STC(0xd8722192), STC(0xb4c373ee), STC(0x777f903c), STC(0x5f1f5ea1),
STC(0x3a1c5c57), STC(0x0d61304e), STC(0xdedf047d), STC(0xb4c373ee),
STC(0x94a6715d), STC(0x74ef0ebc), STC(0x55a6125c), STC(0x278dde6e),
STC(0xf29ecfb2), STC(0xc0000000), STC(0x98722192), STC(0x82cc0f36),
STC(0x720c8075), STC(0x4b3c8c12), STC(0x14060b68), STC(0xd8722192),
STC(0xa57d8666), STC(0x8643c7b3), STC(0x81936daf), STC(0x6ed9eba1),
STC(0x40000000), STC(0x00000000), STC(0xc0000000), STC(0x9126145f),
STC(0x80000000), STC(0x9126145f), STC(0x6b598ea3), STC(0x340ff242),
STC(0xebf9f498), STC(0xaa59eda4), STC(0x845c8ae3), STC(0x8643c7b3),
STC(0xaf726def), STC(0x678dde6e), STC(0x278dde6e), STC(0xd8722192),
STC(0x98722192), STC(0x80000000), STC(0x98722192), STC(0xd8722192),
STC(0x637984d4), STC(0x1a9cd9ac), STC(0xc5e3a3a9), STC(0x8b10f144),
STC(0x845c8ae3), STC(0xb4c373ee), STC(0x06b2f1d2), STC(0x5f1f5ea1),
STC(0x0d61304e), STC(0xb4c373ee), STC(0x82cc0f36), STC(0x9126145f),
STC(0xd8722192), STC(0x340ff242),
};
RAM_ALIGN
LNK_SECTION_CONSTDATA
const FIXP_STB RotVectorImag120[] = {
STC(0x06b2f1d2), STC(0x0d61304e), STC(0x14060b68), STC(0x1a9cd9ac),
STC(0x2120fb83), STC(0x278dde6e), STC(0x2ddf0040), STC(0x0d61304e),
STC(0x1a9cd9ac), STC(0x278dde6e), STC(0x340ff242), STC(0x40000000),
STC(0x4b3c8c12), STC(0x55a6125c), STC(0x14060b68), STC(0x278dde6e),
STC(0x3a1c5c57), STC(0x4b3c8c12), STC(0x5a82799a), STC(0x678dde6e),
STC(0x720c8075), STC(0x1a9cd9ac), STC(0x340ff242), STC(0x4b3c8c12),
STC(0x5f1f5ea1), STC(0x6ed9eba1), STC(0x79bc384d), STC(0x7f4c7e54),
STC(0x2120fb83), STC(0x40000000), STC(0x5a82799a), STC(0x6ed9eba1),
STC(0x7ba3751d), STC(0x7fffffff), STC(0x7ba3751d), STC(0x278dde6e),
STC(0x4b3c8c12), STC(0x678dde6e), STC(0x79bc384d), STC(0x7fffffff),
STC(0x79bc384d), STC(0x678dde6e), STC(0x2ddf0040), STC(0x55a6125c),
STC(0x720c8075), STC(0x7f4c7e54), STC(0x7ba3751d), STC(0x678dde6e),
STC(0x45b6bb5e), STC(0x340ff242), STC(0x5f1f5ea1), STC(0x79bc384d),
STC(0x7f4c7e54), STC(0x6ed9eba1), STC(0x4b3c8c12), STC(0x1a9cd9ac),
STC(0x3a1c5c57), STC(0x678dde6e), STC(0x7e6c9251), STC(0x79bc384d),
STC(0x5a82799a), STC(0x278dde6e), STC(0xebf9f498), STC(0x40000000),
STC(0x6ed9eba1), STC(0x7fffffff), STC(0x6ed9eba1), STC(0x40000000),
STC(0x00000000), STC(0xc0000000), STC(0x45b6bb5e), STC(0x74ef0ebc),
STC(0x7e6c9251), STC(0x5f1f5ea1), STC(0x2120fb83), STC(0xd8722192),
STC(0x9c867b2c), STC(0x4b3c8c12), STC(0x79bc384d), STC(0x79bc384d),
STC(0x4b3c8c12), STC(0x00000000), STC(0xb4c373ee), STC(0x8643c7b3),
STC(0x508d9211), STC(0x7d33f0ca), STC(0x720c8075), STC(0x340ff242),
STC(0xdedf047d), STC(0x98722192), STC(0x802ce84c), STC(0x55a6125c),
STC(0x7f4c7e54), STC(0x678dde6e), STC(0x1a9cd9ac), STC(0xc0000000),
STC(0x8643c7b3), STC(0x8b10f144),
};
RAM_ALIGN
LNK_SECTION_CONSTDATA
const FIXP_STB RotVectorReal192[] = {
STC(0x7fee74a2), STC(0x7fb9d759), STC(0x7f62368f), STC(0x7ee7aa4c),
STC(0x7e4a5426), STC(0x7d8a5f40), STC(0x7ca80038), STC(0x7ba3751d),
STC(0x7a7d055b), STC(0x793501a9), STC(0x77cbc3f2), STC(0x7641af3d),
STC(0x74972f92), STC(0x72ccb9db), STC(0x70e2cbc6), STC(0x7fb9d759),
STC(0x7ee7aa4c), STC(0x7d8a5f40), STC(0x7ba3751d), STC(0x793501a9),
STC(0x7641af3d), STC(0x72ccb9db), STC(0x6ed9eba1), STC(0x6a6d98a4),
STC(0x658c9a2d), STC(0x603c496c), STC(0x5a82799a), STC(0x54657194),
STC(0x4debe4fe), STC(0x471cece7), STC(0x7f62368f), STC(0x7d8a5f40),
STC(0x7a7d055b), STC(0x7641af3d), STC(0x70e2cbc6), STC(0x6a6d98a4),
STC(0x62f201ac), STC(0x5a82799a), STC(0x5133cc94), STC(0x471cece7),
STC(0x3c56ba70), STC(0x30fbc54d), STC(0x25280c5e), STC(0x18f8b83c),
STC(0x0c8bd35e), STC(0x7ee7aa4c), STC(0x7ba3751d), STC(0x7641af3d),
STC(0x6ed9eba1), STC(0x658c9a2d), STC(0x5a82799a), STC(0x4debe4fe),
STC(0x40000000), STC(0x30fbc54d), STC(0x2120fb83), STC(0x10b5150f),
STC(0x00000000), STC(0xef4aeaf1), STC(0xdedf047d), STC(0xcf043ab3),
STC(0x7e4a5426), STC(0x793501a9), STC(0x70e2cbc6), STC(0x658c9a2d),
STC(0x577ff3da), STC(0x471cece7), STC(0x34d3957e), STC(0x2120fb83),
STC(0x0c8bd35e), STC(0xf7a0dec9), STC(0xe2ef2a3e), STC(0xcf043ab3),
STC(0xbc6845ce), STC(0xab9a8e6c), STC(0x9d0dfe54), STC(0x7d8a5f40),
STC(0x7641af3d), STC(0x6a6d98a4), STC(0x5a82799a), STC(0x471cece7),
STC(0x30fbc54d), STC(0x18f8b83c), STC(0x00000000), STC(0xe70747c4),
STC(0xcf043ab3), STC(0xb8e31319), STC(0xa57d8666), STC(0x9592675c),
STC(0x89be50c3), STC(0x8275a0c0), STC(0x7ca80038), STC(0x72ccb9db),
STC(0x62f201ac), STC(0x4debe4fe), STC(0x34d3957e), STC(0x18f8b83c),
STC(0xfbcfdc71), STC(0xdedf047d), STC(0xc3a94590), STC(0xab9a8e6c),
STC(0x97f4a3cd), STC(0x89be50c3), STC(0x81b5abda), STC(0x804628a7),
STC(0x8582faa5), STC(0x7ba3751d), STC(0x6ed9eba1), STC(0x5a82799a),
STC(0x40000000), STC(0x2120fb83), STC(0x00000000), STC(0xdedf047d),
STC(0xc0000000), STC(0xa57d8666), STC(0x9126145f), STC(0x845c8ae3),
STC(0x80000000), STC(0x845c8ae3), STC(0x9126145f), STC(0xa57d8666),
STC(0x7a7d055b), STC(0x6a6d98a4), STC(0x5133cc94), STC(0x30fbc54d),
STC(0x0c8bd35e), STC(0xe70747c4), STC(0xc3a94590), STC(0xa57d8666),
STC(0x8f1d343a), STC(0x8275a0c0), STC(0x809dc971), STC(0x89be50c3),
STC(0x9d0dfe54), STC(0xb8e31319), STC(0xdad7f3a2), STC(0x793501a9),
STC(0x658c9a2d), STC(0x471cece7), STC(0x2120fb83), STC(0xf7a0dec9),
STC(0xcf043ab3), STC(0xab9a8e6c), STC(0x9126145f), STC(0x8275a0c0),
STC(0x811855b4), STC(0x8d334625), STC(0xa57d8666), STC(0xc763158e),
STC(0xef4aeaf1), STC(0x18f8b83c), STC(0x77cbc3f2), STC(0x603c496c),
STC(0x3c56ba70), STC(0x10b5150f), STC(0xe2ef2a3e), STC(0xb8e31319),
STC(0x97f4a3cd), STC(0x845c8ae3), STC(0x809dc971), STC(0x8d334625),
STC(0xa8800c26), STC(0xcf043ab3), STC(0xfbcfdc71), STC(0x2924edac),
STC(0x5133cc94),
};
RAM_ALIGN
LNK_SECTION_CONSTDATA
const FIXP_STB RotVectorImag192[] = {
STC(0x0430238f), STC(0x085f2137), STC(0x0c8bd35e), STC(0x10b5150f),
STC(0x14d9c245), STC(0x18f8b83c), STC(0x1d10d5c2), STC(0x2120fb83),
STC(0x25280c5e), STC(0x2924edac), STC(0x2d168792), STC(0x30fbc54d),
STC(0x34d3957e), STC(0x389cea72), STC(0x3c56ba70), STC(0x085f2137),
STC(0x10b5150f), STC(0x18f8b83c), STC(0x2120fb83), STC(0x2924edac),
STC(0x30fbc54d), STC(0x389cea72), STC(0x40000000), STC(0x471cece7),
STC(0x4debe4fe), STC(0x54657194), STC(0x5a82799a), STC(0x603c496c),
STC(0x658c9a2d), STC(0x6a6d98a4), STC(0x0c8bd35e), STC(0x18f8b83c),
STC(0x25280c5e), STC(0x30fbc54d), STC(0x3c56ba70), STC(0x471cece7),
STC(0x5133cc94), STC(0x5a82799a), STC(0x62f201ac), STC(0x6a6d98a4),
STC(0x70e2cbc6), STC(0x7641af3d), STC(0x7a7d055b), STC(0x7d8a5f40),
STC(0x7f62368f), STC(0x10b5150f), STC(0x2120fb83), STC(0x30fbc54d),
STC(0x40000000), STC(0x4debe4fe), STC(0x5a82799a), STC(0x658c9a2d),
STC(0x6ed9eba1), STC(0x7641af3d), STC(0x7ba3751d), STC(0x7ee7aa4c),
STC(0x7fffffff), STC(0x7ee7aa4c), STC(0x7ba3751d), STC(0x7641af3d),
STC(0x14d9c245), STC(0x2924edac), STC(0x3c56ba70), STC(0x4debe4fe),
STC(0x5d6c2f99), STC(0x6a6d98a4), STC(0x74972f92), STC(0x7ba3751d),
STC(0x7f62368f), STC(0x7fb9d759), STC(0x7ca80038), STC(0x7641af3d),
STC(0x6cb2a837), STC(0x603c496c), STC(0x5133cc94), STC(0x18f8b83c),
STC(0x30fbc54d), STC(0x471cece7), STC(0x5a82799a), STC(0x6a6d98a4),
STC(0x7641af3d), STC(0x7d8a5f40), STC(0x7fffffff), STC(0x7d8a5f40),
STC(0x7641af3d), STC(0x6a6d98a4), STC(0x5a82799a), STC(0x471cece7),
STC(0x30fbc54d), STC(0x18f8b83c), STC(0x1d10d5c2), STC(0x389cea72),
STC(0x5133cc94), STC(0x658c9a2d), STC(0x74972f92), STC(0x7d8a5f40),
STC(0x7fee74a2), STC(0x7ba3751d), STC(0x70e2cbc6), STC(0x603c496c),
STC(0x4a8ea111), STC(0x30fbc54d), STC(0x14d9c245), STC(0xf7a0dec9),
STC(0xdad7f3a2), STC(0x2120fb83), STC(0x40000000), STC(0x5a82799a),
STC(0x6ed9eba1), STC(0x7ba3751d), STC(0x7fffffff), STC(0x7ba3751d),
STC(0x6ed9eba1), STC(0x5a82799a), STC(0x40000000), STC(0x2120fb83),
STC(0x00000000), STC(0xdedf047d), STC(0xc0000000), STC(0xa57d8666),
STC(0x25280c5e), STC(0x471cece7), STC(0x62f201ac), STC(0x7641af3d),
STC(0x7f62368f), STC(0x7d8a5f40), STC(0x70e2cbc6), STC(0x5a82799a),
STC(0x3c56ba70), STC(0x18f8b83c), STC(0xf3742ca2), STC(0xcf043ab3),
STC(0xaecc336c), STC(0x9592675c), STC(0x8582faa5), STC(0x2924edac),
STC(0x4debe4fe), STC(0x6a6d98a4), STC(0x7ba3751d), STC(0x7fb9d759),
STC(0x7641af3d), STC(0x603c496c), STC(0x40000000), STC(0x18f8b83c),
STC(0xef4aeaf1), STC(0xc763158e), STC(0xa57d8666), STC(0x8d334625),
STC(0x811855b4), STC(0x8275a0c0), STC(0x2d168792), STC(0x54657194),
STC(0x70e2cbc6), STC(0x7ee7aa4c), STC(0x7ca80038), STC(0x6a6d98a4),
STC(0x4a8ea111), STC(0x2120fb83), STC(0xf3742ca2), STC(0xc763158e),
STC(0xa293d067), STC(0x89be50c3), STC(0x80118b5e), STC(0x86cafe57),
STC(0x9d0dfe54),
};
RAM_ALIGN
LNK_SECTION_CONSTDATA
const FIXP_STB RotVectorReal240[] = {
STC(0x7ff4c56f), STC(0x7fd317b4), STC(0x7f9afcb9), STC(0x7f4c7e54),
STC(0x7ee7aa4c), STC(0x7e6c9251), STC(0x7ddb4bfc), STC(0x7d33f0ca),
STC(0x7c769e18), STC(0x7ba3751d), STC(0x7aba9ae6), STC(0x79bc384d),
STC(0x78a879f4), STC(0x777f903c), STC(0x7641af3d), STC(0x7fd317b4),
STC(0x7f4c7e54), STC(0x7e6c9251), STC(0x7d33f0ca), STC(0x7ba3751d),
STC(0x79bc384d), STC(0x777f903c), STC(0x74ef0ebc), STC(0x720c8075),
STC(0x6ed9eba1), STC(0x6b598ea3), STC(0x678dde6e), STC(0x637984d4),
STC(0x5f1f5ea1), STC(0x5a82799a), STC(0x7f9afcb9), STC(0x7e6c9251),
STC(0x7c769e18), STC(0x79bc384d), STC(0x7641af3d), STC(0x720c8075),
STC(0x6d23501b), STC(0x678dde6e), STC(0x6154fb91), STC(0x5a82799a),
STC(0x53211d18), STC(0x4b3c8c12), STC(0x42e13ba4), STC(0x3a1c5c57),
STC(0x30fbc54d), STC(0x7f4c7e54), STC(0x7d33f0ca), STC(0x79bc384d),
STC(0x74ef0ebc), STC(0x6ed9eba1), STC(0x678dde6e), STC(0x5f1f5ea1),
STC(0x55a6125c), STC(0x4b3c8c12), STC(0x40000000), STC(0x340ff242),
STC(0x278dde6e), STC(0x1a9cd9ac), STC(0x0d61304e), STC(0x00000000),
STC(0x7ee7aa4c), STC(0x7ba3751d), STC(0x7641af3d), STC(0x6ed9eba1),
STC(0x658c9a2d), STC(0x5a82799a), STC(0x4debe4fe), STC(0x40000000),
STC(0x30fbc54d), STC(0x2120fb83), STC(0x10b5150f), STC(0x00000000),
STC(0xef4aeaf1), STC(0xdedf047d), STC(0xcf043ab3), STC(0x7e6c9251),
STC(0x79bc384d), STC(0x720c8075), STC(0x678dde6e), STC(0x5a82799a),
STC(0x4b3c8c12), STC(0x3a1c5c57), STC(0x278dde6e), STC(0x14060b68),
STC(0x00000000), STC(0xebf9f498), STC(0xd8722192), STC(0xc5e3a3a9),
STC(0xb4c373ee), STC(0xa57d8666), STC(0x7ddb4bfc), STC(0x777f903c),
STC(0x6d23501b), STC(0x5f1f5ea1), STC(0x4debe4fe), STC(0x3a1c5c57),
STC(0x245a9d65), STC(0x0d61304e), STC(0xf5f50d67), STC(0xdedf047d),
STC(0xc8e5032b), STC(0xb4c373ee), STC(0xa326eec0), STC(0x94a6715d),
STC(0x89be50c3), STC(0x7d33f0ca), STC(0x74ef0ebc), STC(0x678dde6e),
STC(0x55a6125c), STC(0x40000000), STC(0x278dde6e), STC(0x0d61304e),
STC(0xf29ecfb2), STC(0xd8722192), STC(0xc0000000), STC(0xaa59eda4),
STC(0x98722192), STC(0x8b10f144), STC(0x82cc0f36), STC(0x80000000),
STC(0x7c769e18), STC(0x720c8075), STC(0x6154fb91), STC(0x4b3c8c12),
STC(0x30fbc54d), STC(0x14060b68), STC(0xf5f50d67), STC(0xd8722192),
STC(0xbd1ec45c), STC(0xa57d8666), STC(0x92dcafe5), STC(0x8643c7b3),
STC(0x80650347), STC(0x81936daf), STC(0x89be50c3), STC(0x7ba3751d),
STC(0x6ed9eba1), STC(0x5a82799a), STC(0x40000000), STC(0x2120fb83),
STC(0x00000000), STC(0xdedf047d), STC(0xc0000000), STC(0xa57d8666),
STC(0x9126145f), STC(0x845c8ae3), STC(0x80000000), STC(0x845c8ae3),
STC(0x9126145f), STC(0xa57d8666), STC(0x7aba9ae6), STC(0x6b598ea3),
STC(0x53211d18), STC(0x340ff242), STC(0x10b5150f), STC(0xebf9f498),
STC(0xc8e5032b), STC(0xaa59eda4), STC(0x92dcafe5), STC(0x845c8ae3),
STC(0x800b3a91), STC(0x8643c7b3), STC(0x96830876), STC(0xaf726def),
STC(0xcf043ab3), STC(0x79bc384d), STC(0x678dde6e), STC(0x4b3c8c12),
STC(0x278dde6e), STC(0x00000000), STC(0xd8722192), STC(0xb4c373ee),
STC(0x98722192), STC(0x8643c7b3), STC(0x80000000), STC(0x8643c7b3),
STC(0x98722192), STC(0xb4c373ee), STC(0xd8722192), STC(0x00000000),
STC(0x78a879f4), STC(0x637984d4), STC(0x42e13ba4), STC(0x1a9cd9ac),
STC(0xef4aeaf1), STC(0xc5e3a3a9), STC(0xa326eec0), STC(0x8b10f144),
STC(0x80650347), STC(0x845c8ae3), STC(0x96830876), STC(0xb4c373ee),
STC(0xdba5629b), STC(0x06b2f1d2), STC(0x30fbc54d), STC(0x777f903c),
STC(0x5f1f5ea1), STC(0x3a1c5c57), STC(0x0d61304e), STC(0xdedf047d),
STC(0xb4c373ee), STC(0x94a6715d), STC(0x82cc0f36), STC(0x81936daf),
STC(0x9126145f), STC(0xaf726def), STC(0xd8722192), STC(0x06b2f1d2),
STC(0x340ff242), STC(0x5a82799a),
};
RAM_ALIGN
LNK_SECTION_CONSTDATA
const FIXP_STB RotVectorImag240[] = {
STC(0x0359c428), STC(0x06b2f1d2), STC(0x0a0af299), STC(0x0d61304e),
STC(0x10b5150f), STC(0x14060b68), STC(0x17537e63), STC(0x1a9cd9ac),
STC(0x1de189a6), STC(0x2120fb83), STC(0x245a9d65), STC(0x278dde6e),
STC(0x2aba2ee4), STC(0x2ddf0040), STC(0x30fbc54d), STC(0x06b2f1d2),
STC(0x0d61304e), STC(0x14060b68), STC(0x1a9cd9ac), STC(0x2120fb83),
STC(0x278dde6e), STC(0x2ddf0040), STC(0x340ff242), STC(0x3a1c5c57),
STC(0x40000000), STC(0x45b6bb5e), STC(0x4b3c8c12), STC(0x508d9211),
STC(0x55a6125c), STC(0x5a82799a), STC(0x0a0af299), STC(0x14060b68),
STC(0x1de189a6), STC(0x278dde6e), STC(0x30fbc54d), STC(0x3a1c5c57),
STC(0x42e13ba4), STC(0x4b3c8c12), STC(0x53211d18), STC(0x5a82799a),
STC(0x6154fb91), STC(0x678dde6e), STC(0x6d23501b), STC(0x720c8075),
STC(0x7641af3d), STC(0x0d61304e), STC(0x1a9cd9ac), STC(0x278dde6e),
STC(0x340ff242), STC(0x40000000), STC(0x4b3c8c12), STC(0x55a6125c),
STC(0x5f1f5ea1), STC(0x678dde6e), STC(0x6ed9eba1), STC(0x74ef0ebc),
STC(0x79bc384d), STC(0x7d33f0ca), STC(0x7f4c7e54), STC(0x7fffffff),
STC(0x10b5150f), STC(0x2120fb83), STC(0x30fbc54d), STC(0x40000000),
STC(0x4debe4fe), STC(0x5a82799a), STC(0x658c9a2d), STC(0x6ed9eba1),
STC(0x7641af3d), STC(0x7ba3751d), STC(0x7ee7aa4c), STC(0x7fffffff),
STC(0x7ee7aa4c), STC(0x7ba3751d), STC(0x7641af3d), STC(0x14060b68),
STC(0x278dde6e), STC(0x3a1c5c57), STC(0x4b3c8c12), STC(0x5a82799a),
STC(0x678dde6e), STC(0x720c8075), STC(0x79bc384d), STC(0x7e6c9251),
STC(0x7fffffff), STC(0x7e6c9251), STC(0x79bc384d), STC(0x720c8075),
STC(0x678dde6e), STC(0x5a82799a), STC(0x17537e63), STC(0x2ddf0040),
STC(0x42e13ba4), STC(0x55a6125c), STC(0x658c9a2d), STC(0x720c8075),
STC(0x7aba9ae6), STC(0x7f4c7e54), STC(0x7f9afcb9), STC(0x7ba3751d),
STC(0x7387ea23), STC(0x678dde6e), STC(0x581c00b3), STC(0x45b6bb5e),
STC(0x30fbc54d), STC(0x1a9cd9ac), STC(0x340ff242), STC(0x4b3c8c12),
STC(0x5f1f5ea1), STC(0x6ed9eba1), STC(0x79bc384d), STC(0x7f4c7e54),
STC(0x7f4c7e54), STC(0x79bc384d), STC(0x6ed9eba1), STC(0x5f1f5ea1),
STC(0x4b3c8c12), STC(0x340ff242), STC(0x1a9cd9ac), STC(0x00000000),
STC(0x1de189a6), STC(0x3a1c5c57), STC(0x53211d18), STC(0x678dde6e),
STC(0x7641af3d), STC(0x7e6c9251), STC(0x7f9afcb9), STC(0x79bc384d),
STC(0x6d23501b), STC(0x5a82799a), STC(0x42e13ba4), STC(0x278dde6e),
STC(0x0a0af299), STC(0xebf9f498), STC(0xcf043ab3), STC(0x2120fb83),
STC(0x40000000), STC(0x5a82799a), STC(0x6ed9eba1), STC(0x7ba3751d),
STC(0x7fffffff), STC(0x7ba3751d), STC(0x6ed9eba1), STC(0x5a82799a),
STC(0x40000000), STC(0x2120fb83), STC(0x00000000), STC(0xdedf047d),
STC(0xc0000000), STC(0xa57d8666), STC(0x245a9d65), STC(0x45b6bb5e),
STC(0x6154fb91), STC(0x74ef0ebc), STC(0x7ee7aa4c), STC(0x7e6c9251),
STC(0x7387ea23), STC(0x5f1f5ea1), STC(0x42e13ba4), STC(0x2120fb83),
STC(0xfca63bd8), STC(0xd8722192), STC(0xb780001c), STC(0x9c867b2c),
STC(0x89be50c3), STC(0x278dde6e), STC(0x4b3c8c12), STC(0x678dde6e),
STC(0x79bc384d), STC(0x7fffffff), STC(0x79bc384d), STC(0x678dde6e),
STC(0x4b3c8c12), STC(0x278dde6e), STC(0x00000000), STC(0xd8722192),
STC(0xb4c373ee), STC(0x98722192), STC(0x8643c7b3), STC(0x80000000),
STC(0x2aba2ee4), STC(0x508d9211), STC(0x6d23501b), STC(0x7d33f0ca),
STC(0x7ee7aa4c), STC(0x720c8075), STC(0x581c00b3), STC(0x340ff242),
STC(0x0a0af299), STC(0xdedf047d), STC(0xb780001c), STC(0x98722192),
STC(0x8545651a), STC(0x802ce84c), STC(0x89be50c3), STC(0x2ddf0040),
STC(0x55a6125c), STC(0x720c8075), STC(0x7f4c7e54), STC(0x7ba3751d),
STC(0x678dde6e), STC(0x45b6bb5e), STC(0x1a9cd9ac), STC(0xebf9f498),
STC(0xc0000000), STC(0x9c867b2c), STC(0x8643c7b3), STC(0x802ce84c),
STC(0x8b10f144), STC(0xa57d8666),
};
RAM_ALIGN
LNK_SECTION_CONSTDATA
const FIXP_STB RotVectorReal480[] = {
STC(0x7ffd3154), STC(0x7ff4c56f), STC(0x7fe6bcb0), STC(0x7fd317b4),
STC(0x7fb9d759), STC(0x7f9afcb9), STC(0x7f76892f), STC(0x7f4c7e54),
STC(0x7f1cde01), STC(0x7ee7aa4c), STC(0x7eace58a), STC(0x7e6c9251),
STC(0x7e26b371), STC(0x7ddb4bfc), STC(0x7d8a5f40), STC(0x7d33f0ca),
STC(0x7cd80464), STC(0x7c769e18), STC(0x7c0fc22a), STC(0x7ba3751d),
STC(0x7b31bbb2), STC(0x7aba9ae6), STC(0x7a3e17f2), STC(0x79bc384d),
STC(0x793501a9), STC(0x78a879f4), STC(0x7816a759), STC(0x777f903c),
STC(0x76e33b3f), STC(0x7641af3d), STC(0x759af34c), STC(0x7ff4c56f),
STC(0x7fd317b4), STC(0x7f9afcb9), STC(0x7f4c7e54), STC(0x7ee7aa4c),
STC(0x7e6c9251), STC(0x7ddb4bfc), STC(0x7d33f0ca), STC(0x7c769e18),
STC(0x7ba3751d), STC(0x7aba9ae6), STC(0x79bc384d), STC(0x78a879f4),
STC(0x777f903c), STC(0x7641af3d), STC(0x74ef0ebc), STC(0x7387ea23),
STC(0x720c8075), STC(0x707d1443), STC(0x6ed9eba1), STC(0x6d23501b),
STC(0x6b598ea3), STC(0x697cf78a), STC(0x678dde6e), STC(0x658c9a2d),
STC(0x637984d4), STC(0x6154fb91), STC(0x5f1f5ea1), STC(0x5cd91140),
STC(0x5a82799a), STC(0x581c00b3), STC(0x7fe6bcb0), STC(0x7f9afcb9),
STC(0x7f1cde01), STC(0x7e6c9251), STC(0x7d8a5f40), STC(0x7c769e18),
STC(0x7b31bbb2), STC(0x79bc384d), STC(0x7816a759), STC(0x7641af3d),
STC(0x743e0918), STC(0x720c8075), STC(0x6fadf2fc), STC(0x6d23501b),
STC(0x6a6d98a4), STC(0x678dde6e), STC(0x648543e4), STC(0x6154fb91),
STC(0x5dfe47ad), STC(0x5a82799a), STC(0x56e2f15d), STC(0x53211d18),
STC(0x4f3e7875), STC(0x4b3c8c12), STC(0x471cece7), STC(0x42e13ba4),
STC(0x3e8b240e), STC(0x3a1c5c57), STC(0x3596a46c), STC(0x30fbc54d),
STC(0x2c4d9050), STC(0x7fd317b4), STC(0x7f4c7e54), STC(0x7e6c9251),
STC(0x7d33f0ca), STC(0x7ba3751d), STC(0x79bc384d), STC(0x777f903c),
STC(0x74ef0ebc), STC(0x720c8075), STC(0x6ed9eba1), STC(0x6b598ea3),
STC(0x678dde6e), STC(0x637984d4), STC(0x5f1f5ea1), STC(0x5a82799a),
STC(0x55a6125c), STC(0x508d9211), STC(0x4b3c8c12), STC(0x45b6bb5e),
STC(0x40000000), STC(0x3a1c5c57), STC(0x340ff242), STC(0x2ddf0040),
STC(0x278dde6e), STC(0x2120fb83), STC(0x1a9cd9ac), STC(0x14060b68),
STC(0x0d61304e), STC(0x06b2f1d2), STC(0x00000000), STC(0xf94d0e2e),
STC(0x7fb9d759), STC(0x7ee7aa4c), STC(0x7d8a5f40), STC(0x7ba3751d),
STC(0x793501a9), STC(0x7641af3d), STC(0x72ccb9db), STC(0x6ed9eba1),
STC(0x6a6d98a4), STC(0x658c9a2d), STC(0x603c496c), STC(0x5a82799a),
STC(0x54657194), STC(0x4debe4fe), STC(0x471cece7), STC(0x40000000),
STC(0x389cea72), STC(0x30fbc54d), STC(0x2924edac), STC(0x2120fb83),
STC(0x18f8b83c), STC(0x10b5150f), STC(0x085f2137), STC(0x00000000),
STC(0xf7a0dec9), STC(0xef4aeaf1), STC(0xe70747c4), STC(0xdedf047d),
STC(0xd6db1254), STC(0xcf043ab3), STC(0xc763158e), STC(0x7f9afcb9),
STC(0x7e6c9251), STC(0x7c769e18), STC(0x79bc384d), STC(0x7641af3d),
STC(0x720c8075), STC(0x6d23501b), STC(0x678dde6e), STC(0x6154fb91),
STC(0x5a82799a), STC(0x53211d18), STC(0x4b3c8c12), STC(0x42e13ba4),
STC(0x3a1c5c57), STC(0x30fbc54d), STC(0x278dde6e), STC(0x1de189a6),
STC(0x14060b68), STC(0x0a0af299), STC(0x00000000), STC(0xf5f50d67),
STC(0xebf9f498), STC(0xe21e765a), STC(0xd8722192), STC(0xcf043ab3),
STC(0xc5e3a3a9), STC(0xbd1ec45c), STC(0xb4c373ee), STC(0xacdee2e8),
STC(0xa57d8666), STC(0x9eab046f), STC(0x7f76892f), STC(0x7ddb4bfc),
STC(0x7b31bbb2), STC(0x777f903c), STC(0x72ccb9db), STC(0x6d23501b),
STC(0x668f7c25), STC(0x5f1f5ea1), STC(0x56e2f15d), STC(0x4debe4fe),
STC(0x444d7aff), STC(0x3a1c5c57), STC(0x2f6e6d16), STC(0x245a9d65),
STC(0x18f8b83c), STC(0x0d61304e), STC(0x01aceb7c), STC(0xf5f50d67),
STC(0xea52c166), STC(0xdedf047d), STC(0xd3b26fb0), STC(0xc8e5032b),
STC(0xbe8df2ba), STC(0xb4c373ee), STC(0xab9a8e6c), STC(0xa326eec0),
STC(0x9b7abc1c), STC(0x94a6715d), STC(0x8eb8b9a0), STC(0x89be50c3),
STC(0x85c1e80e), STC(0x7f4c7e54), STC(0x7d33f0ca), STC(0x79bc384d),
STC(0x74ef0ebc), STC(0x6ed9eba1), STC(0x678dde6e), STC(0x5f1f5ea1),
STC(0x55a6125c), STC(0x4b3c8c12), STC(0x40000000), STC(0x340ff242),
STC(0x278dde6e), STC(0x1a9cd9ac), STC(0x0d61304e), STC(0x00000000),
STC(0xf29ecfb2), STC(0xe5632654), STC(0xd8722192), STC(0xcbf00dbe),
STC(0xc0000000), STC(0xb4c373ee), STC(0xaa59eda4), STC(0xa0e0a15f),
STC(0x98722192), STC(0x9126145f), STC(0x8b10f144), STC(0x8643c7b3),
STC(0x82cc0f36), STC(0x80b381ac), STC(0x80000000), STC(0x80b381ac),
STC(0x7f1cde01), STC(0x7c769e18), STC(0x7816a759), STC(0x720c8075),
STC(0x6a6d98a4), STC(0x6154fb91), STC(0x56e2f15d), STC(0x4b3c8c12),
STC(0x3e8b240e), STC(0x30fbc54d), STC(0x22be8f87), STC(0x14060b68),
STC(0x05067734), STC(0xf5f50d67), STC(0xe70747c4), STC(0xd8722192),
STC(0xca695b94), STC(0xbd1ec45c), STC(0xb0c1878b), STC(0xa57d8666),
STC(0x9b7abc1c), STC(0x92dcafe5), STC(0x8bc1f6e8), STC(0x8643c7b3),
STC(0x8275a0c0), STC(0x80650347), STC(0x80194350), STC(0x81936daf),
STC(0x84ce444e), STC(0x89be50c3), STC(0x90520d04), STC(0x7ee7aa4c),
STC(0x7ba3751d), STC(0x7641af3d), STC(0x6ed9eba1), STC(0x658c9a2d),
STC(0x5a82799a), STC(0x4debe4fe), STC(0x40000000), STC(0x30fbc54d),
STC(0x2120fb83), STC(0x10b5150f), STC(0x00000000), STC(0xef4aeaf1),
STC(0xdedf047d), STC(0xcf043ab3), STC(0xc0000000), STC(0xb2141b02),
STC(0xa57d8666), STC(0x9a7365d3), STC(0x9126145f), STC(0x89be50c3),
STC(0x845c8ae3), STC(0x811855b4), STC(0x80000000), STC(0x811855b4),
STC(0x845c8ae3), STC(0x89be50c3), STC(0x9126145f), STC(0x9a7365d3),
STC(0xa57d8666), STC(0xb2141b02), STC(0x7eace58a), STC(0x7aba9ae6),
STC(0x743e0918), STC(0x6b598ea3), STC(0x603c496c), STC(0x53211d18),
STC(0x444d7aff), STC(0x340ff242), STC(0x22be8f87), STC(0x10b5150f),
STC(0xfe531484), STC(0xebf9f498), STC(0xda0aecf9), STC(0xc8e5032b),
STC(0xb8e31319), STC(0xaa59eda4), STC(0x9d969742), STC(0x92dcafe5),
STC(0x8a650cb4), STC(0x845c8ae3), STC(0x80e321ff), STC(0x800b3a91),
STC(0x81d94c8f), STC(0x8643c7b3), STC(0x8d334625), STC(0x96830876),
STC(0xa201b853), STC(0xaf726def), STC(0xbe8df2ba), STC(0xcf043ab3),
STC(0xe07e0c84), STC(0x7e6c9251), STC(0x79bc384d), STC(0x720c8075),
STC(0x678dde6e), STC(0x5a82799a), STC(0x4b3c8c12), STC(0x3a1c5c57),
STC(0x278dde6e), STC(0x14060b68), STC(0x00000000), STC(0xebf9f498),
STC(0xd8722192), STC(0xc5e3a3a9), STC(0xb4c373ee), STC(0xa57d8666),
STC(0x98722192), STC(0x8df37f8b), STC(0x8643c7b3), STC(0x81936daf),
STC(0x80000000), STC(0x81936daf), STC(0x8643c7b3), STC(0x8df37f8b),
STC(0x98722192), STC(0xa57d8666), STC(0xb4c373ee), STC(0xc5e3a3a9),
STC(0xd8722192), STC(0xebf9f498), STC(0x00000000), STC(0x14060b68),
STC(0x7e26b371), STC(0x78a879f4), STC(0x6fadf2fc), STC(0x637984d4),
STC(0x54657194), STC(0x42e13ba4), STC(0x2f6e6d16), STC(0x1a9cd9ac),
STC(0x05067734), STC(0xef4aeaf1), STC(0xda0aecf9), STC(0xc5e3a3a9),
STC(0xb36a1978), STC(0xa326eec0), STC(0x9592675c), STC(0x8b10f144),
STC(0x83f03dd6), STC(0x80650347), STC(0x808976d1), STC(0x845c8ae3),
STC(0x8bc1f6e8), STC(0x96830876), STC(0xa45037c9), STC(0xb4c373ee),
STC(0xc763158e), STC(0xdba5629b), STC(0xf0f488d9), STC(0x06b2f1d2),
STC(0x1c3fd045), STC(0x30fbc54d), STC(0x444d7aff), STC(0x7ddb4bfc),
STC(0x777f903c), STC(0x6d23501b), STC(0x5f1f5ea1), STC(0x4debe4fe),
STC(0x3a1c5c57), STC(0x245a9d65), STC(0x0d61304e), STC(0xf5f50d67),
STC(0xdedf047d), STC(0xc8e5032b), STC(0xb4c373ee), STC(0xa326eec0),
STC(0x94a6715d), STC(0x89be50c3), STC(0x82cc0f36), STC(0x800b3a91),
STC(0x81936daf), STC(0x8757860c), STC(0x9126145f), STC(0x9eab046f),
STC(0xaf726def), STC(0xc2ec7635), STC(0xd8722192), STC(0xef4aeaf1),
STC(0x06b2f1d2), STC(0x1de189a6), STC(0x340ff242), STC(0x487fffe4),
STC(0x5a82799a), STC(0x697cf78a),
};
RAM_ALIGN
LNK_SECTION_CONSTDATA
const FIXP_STB RotVectorImag480[] = {
STC(0x01aceb7c), STC(0x0359c428), STC(0x05067734), STC(0x06b2f1d2),
STC(0x085f2137), STC(0x0a0af299), STC(0x0bb65336), STC(0x0d61304e),
STC(0x0f0b7727), STC(0x10b5150f), STC(0x125df75b), STC(0x14060b68),
STC(0x15ad3e9a), STC(0x17537e63), STC(0x18f8b83c), STC(0x1a9cd9ac),
STC(0x1c3fd045), STC(0x1de189a6), STC(0x1f81f37c), STC(0x2120fb83),
STC(0x22be8f87), STC(0x245a9d65), STC(0x25f51307), STC(0x278dde6e),
STC(0x2924edac), STC(0x2aba2ee4), STC(0x2c4d9050), STC(0x2ddf0040),
STC(0x2f6e6d16), STC(0x30fbc54d), STC(0x3286f779), STC(0x0359c428),
STC(0x06b2f1d2), STC(0x0a0af299), STC(0x0d61304e), STC(0x10b5150f),
STC(0x14060b68), STC(0x17537e63), STC(0x1a9cd9ac), STC(0x1de189a6),
STC(0x2120fb83), STC(0x245a9d65), STC(0x278dde6e), STC(0x2aba2ee4),
STC(0x2ddf0040), STC(0x30fbc54d), STC(0x340ff242), STC(0x371afcd5),
STC(0x3a1c5c57), STC(0x3d1389cb), STC(0x40000000), STC(0x42e13ba4),
STC(0x45b6bb5e), STC(0x487fffe4), STC(0x4b3c8c12), STC(0x4debe4fe),
STC(0x508d9211), STC(0x53211d18), STC(0x55a6125c), STC(0x581c00b3),
STC(0x5a82799a), STC(0x5cd91140), STC(0x05067734), STC(0x0a0af299),
STC(0x0f0b7727), STC(0x14060b68), STC(0x18f8b83c), STC(0x1de189a6),
STC(0x22be8f87), STC(0x278dde6e), STC(0x2c4d9050), STC(0x30fbc54d),
STC(0x3596a46c), STC(0x3a1c5c57), STC(0x3e8b240e), STC(0x42e13ba4),
STC(0x471cece7), STC(0x4b3c8c12), STC(0x4f3e7875), STC(0x53211d18),
STC(0x56e2f15d), STC(0x5a82799a), STC(0x5dfe47ad), STC(0x6154fb91),
STC(0x648543e4), STC(0x678dde6e), STC(0x6a6d98a4), STC(0x6d23501b),
STC(0x6fadf2fc), STC(0x720c8075), STC(0x743e0918), STC(0x7641af3d),
STC(0x7816a759), STC(0x06b2f1d2), STC(0x0d61304e), STC(0x14060b68),
STC(0x1a9cd9ac), STC(0x2120fb83), STC(0x278dde6e), STC(0x2ddf0040),
STC(0x340ff242), STC(0x3a1c5c57), STC(0x40000000), STC(0x45b6bb5e),
STC(0x4b3c8c12), STC(0x508d9211), STC(0x55a6125c), STC(0x5a82799a),
STC(0x5f1f5ea1), STC(0x637984d4), STC(0x678dde6e), STC(0x6b598ea3),
STC(0x6ed9eba1), STC(0x720c8075), STC(0x74ef0ebc), STC(0x777f903c),
STC(0x79bc384d), STC(0x7ba3751d), STC(0x7d33f0ca), STC(0x7e6c9251),
STC(0x7f4c7e54), STC(0x7fd317b4), STC(0x7fffffff), STC(0x7fd317b4),
STC(0x085f2137), STC(0x10b5150f), STC(0x18f8b83c), STC(0x2120fb83),
STC(0x2924edac), STC(0x30fbc54d), STC(0x389cea72), STC(0x40000000),
STC(0x471cece7), STC(0x4debe4fe), STC(0x54657194), STC(0x5a82799a),
STC(0x603c496c), STC(0x658c9a2d), STC(0x6a6d98a4), STC(0x6ed9eba1),
STC(0x72ccb9db), STC(0x7641af3d), STC(0x793501a9), STC(0x7ba3751d),
STC(0x7d8a5f40), STC(0x7ee7aa4c), STC(0x7fb9d759), STC(0x7fffffff),
STC(0x7fb9d759), STC(0x7ee7aa4c), STC(0x7d8a5f40), STC(0x7ba3751d),
STC(0x793501a9), STC(0x7641af3d), STC(0x72ccb9db), STC(0x0a0af299),
STC(0x14060b68), STC(0x1de189a6), STC(0x278dde6e), STC(0x30fbc54d),
STC(0x3a1c5c57), STC(0x42e13ba4), STC(0x4b3c8c12), STC(0x53211d18),
STC(0x5a82799a), STC(0x6154fb91), STC(0x678dde6e), STC(0x6d23501b),
STC(0x720c8075), STC(0x7641af3d), STC(0x79bc384d), STC(0x7c769e18),
STC(0x7e6c9251), STC(0x7f9afcb9), STC(0x7fffffff), STC(0x7f9afcb9),
STC(0x7e6c9251), STC(0x7c769e18), STC(0x79bc384d), STC(0x7641af3d),
STC(0x720c8075), STC(0x6d23501b), STC(0x678dde6e), STC(0x6154fb91),
STC(0x5a82799a), STC(0x53211d18), STC(0x0bb65336), STC(0x17537e63),
STC(0x22be8f87), STC(0x2ddf0040), STC(0x389cea72), STC(0x42e13ba4),
STC(0x4c95e688), STC(0x55a6125c), STC(0x5dfe47ad), STC(0x658c9a2d),
STC(0x6c40cf2c), STC(0x720c8075), STC(0x76e33b3f), STC(0x7aba9ae6),
STC(0x7d8a5f40), STC(0x7f4c7e54), STC(0x7ffd3154), STC(0x7f9afcb9),
STC(0x7e26b371), STC(0x7ba3751d), STC(0x7816a759), STC(0x7387ea23),
STC(0x6e010780), STC(0x678dde6e), STC(0x603c496c), STC(0x581c00b3),
STC(0x4f3e7875), STC(0x45b6bb5e), STC(0x3b9941b1), STC(0x30fbc54d),
STC(0x25f51307), STC(0x0d61304e), STC(0x1a9cd9ac), STC(0x278dde6e),
STC(0x340ff242), STC(0x40000000), STC(0x4b3c8c12), STC(0x55a6125c),
STC(0x5f1f5ea1), STC(0x678dde6e), STC(0x6ed9eba1), STC(0x74ef0ebc),
STC(0x79bc384d), STC(0x7d33f0ca), STC(0x7f4c7e54), STC(0x7fffffff),
STC(0x7f4c7e54), STC(0x7d33f0ca), STC(0x79bc384d), STC(0x74ef0ebc),
STC(0x6ed9eba1), STC(0x678dde6e), STC(0x5f1f5ea1), STC(0x55a6125c),
STC(0x4b3c8c12), STC(0x40000000), STC(0x340ff242), STC(0x278dde6e),
STC(0x1a9cd9ac), STC(0x0d61304e), STC(0x00000000), STC(0xf29ecfb2),
STC(0x0f0b7727), STC(0x1de189a6), STC(0x2c4d9050), STC(0x3a1c5c57),
STC(0x471cece7), STC(0x53211d18), STC(0x5dfe47ad), STC(0x678dde6e),
STC(0x6fadf2fc), STC(0x7641af3d), STC(0x7b31bbb2), STC(0x7e6c9251),
STC(0x7fe6bcb0), STC(0x7f9afcb9), STC(0x7d8a5f40), STC(0x79bc384d),
STC(0x743e0918), STC(0x6d23501b), STC(0x648543e4), STC(0x5a82799a),
STC(0x4f3e7875), STC(0x42e13ba4), STC(0x3596a46c), STC(0x278dde6e),
STC(0x18f8b83c), STC(0x0a0af299), STC(0xfaf988cc), STC(0xebf9f498),
STC(0xdd417079), STC(0xcf043ab3), STC(0xc174dbf2), STC(0x10b5150f),
STC(0x2120fb83), STC(0x30fbc54d), STC(0x40000000), STC(0x4debe4fe),
STC(0x5a82799a), STC(0x658c9a2d), STC(0x6ed9eba1), STC(0x7641af3d),
STC(0x7ba3751d), STC(0x7ee7aa4c), STC(0x7fffffff), STC(0x7ee7aa4c),
STC(0x7ba3751d), STC(0x7641af3d), STC(0x6ed9eba1), STC(0x658c9a2d),
STC(0x5a82799a), STC(0x4debe4fe), STC(0x40000000), STC(0x30fbc54d),
STC(0x2120fb83), STC(0x10b5150f), STC(0x00000000), STC(0xef4aeaf1),
STC(0xdedf047d), STC(0xcf043ab3), STC(0xc0000000), STC(0xb2141b02),
STC(0xa57d8666), STC(0x9a7365d3), STC(0x125df75b), STC(0x245a9d65),
STC(0x3596a46c), STC(0x45b6bb5e), STC(0x54657194), STC(0x6154fb91),
STC(0x6c40cf2c), STC(0x74ef0ebc), STC(0x7b31bbb2), STC(0x7ee7aa4c),
STC(0x7ffd3154), STC(0x7e6c9251), STC(0x7a3e17f2), STC(0x7387ea23),
STC(0x6a6d98a4), STC(0x5f1f5ea1), STC(0x51d92321), STC(0x42e13ba4),
STC(0x3286f779), STC(0x2120fb83), STC(0x0f0b7727), STC(0xfca63bd8),
STC(0xea52c166), STC(0xd8722192), STC(0xc763158e), STC(0xb780001c),
STC(0xa91d0ea3), STC(0x9c867b2c), STC(0x91fef880), STC(0x89be50c3),
STC(0x83f03dd6), STC(0x14060b68), STC(0x278dde6e), STC(0x3a1c5c57),
STC(0x4b3c8c12), STC(0x5a82799a), STC(0x678dde6e), STC(0x720c8075),
STC(0x79bc384d), STC(0x7e6c9251), STC(0x7fffffff), STC(0x7e6c9251),
STC(0x79bc384d), STC(0x720c8075), STC(0x678dde6e), STC(0x5a82799a),
STC(0x4b3c8c12), STC(0x3a1c5c57), STC(0x278dde6e), STC(0x14060b68),
STC(0x00000000), STC(0xebf9f498), STC(0xd8722192), STC(0xc5e3a3a9),
STC(0xb4c373ee), STC(0xa57d8666), STC(0x98722192), STC(0x8df37f8b),
STC(0x8643c7b3), STC(0x81936daf), STC(0x80000000), STC(0x81936daf),
STC(0x15ad3e9a), STC(0x2aba2ee4), STC(0x3e8b240e), STC(0x508d9211),
STC(0x603c496c), STC(0x6d23501b), STC(0x76e33b3f), STC(0x7d33f0ca),
STC(0x7fe6bcb0), STC(0x7ee7aa4c), STC(0x7a3e17f2), STC(0x720c8075),
STC(0x668f7c25), STC(0x581c00b3), STC(0x471cece7), STC(0x340ff242),
STC(0x1f81f37c), STC(0x0a0af299), STC(0xf449acca), STC(0xdedf047d),
STC(0xca695b94), STC(0xb780001c), STC(0xa6aecd5e), STC(0x98722192),
STC(0x8d334625), STC(0x8545651a), STC(0x80e321ff), STC(0x802ce84c),
STC(0x8327fb9c), STC(0x89be50c3), STC(0x93bf30d4), STC(0x17537e63),
STC(0x2ddf0040), STC(0x42e13ba4), STC(0x55a6125c), STC(0x658c9a2d),
STC(0x720c8075), STC(0x7aba9ae6), STC(0x7f4c7e54), STC(0x7f9afcb9),
STC(0x7ba3751d), STC(0x7387ea23), STC(0x678dde6e), STC(0x581c00b3),
STC(0x45b6bb5e), STC(0x30fbc54d), STC(0x1a9cd9ac), STC(0x0359c428),
STC(0xebf9f498), STC(0xd545d11c), STC(0xc0000000), STC(0xacdee2e8),
STC(0x9c867b2c), STC(0x8f82ebbd), STC(0x8643c7b3), STC(0x811855b4),
STC(0x802ce84c), STC(0x838961e8), STC(0x8b10f144), STC(0x96830876),
STC(0xa57d8666), STC(0xb780001c),
};
RAM_ALIGN
LNK_SECTION_CONSTDATA
const FIXP_STB RotVectorReal20[] = {
STC(0x79bc384d), STC(0x678dde6e), STC(0x4b3c8c12), STC(0x678dde6e),
STC(0x278dde6e), STC(0xd8722192), STC(0x4b3c8c12), STC(0xd8722192),
STC(0x8643c7b3), STC(0x278dde6e), STC(0x98722192), STC(0x98722192),
};
RAM_ALIGN
LNK_SECTION_CONSTDATA
const FIXP_STB RotVectorImag20[] = {
STC(0x278dde6e), STC(0x4b3c8c12), STC(0x678dde6e), STC(0x4b3c8c12),
STC(0x79bc384d), STC(0x79bc384d), STC(0x678dde6e), STC(0x79bc384d),
STC(0x278dde6e), STC(0x79bc384d), STC(0x4b3c8c12), STC(0xb4c373ee),
};
RAM_ALIGN
LNK_SECTION_CONSTDATA
const FIXP_WTP SineWindow8[] = {
WTCP(0x7f62368f, 0x0c8bd35e),
WTCP(0x7a7d055b, 0x25280c5e),
WTCP(0x70e2cbc6, 0x3c56ba70),
WTCP(0x62f201ac, 0x5133cc94),
};
RAM_ALIGN
LNK_SECTION_CONSTDATA
const FIXP_WTP SineWindow12[] = {
WTCP(0x7fb9d759, 0x085f2137), WTCP(0x7d8a5f40, 0x18f8b83c),
WTCP(0x793501a9, 0x2924edac), WTCP(0x72ccb9db, 0x389cea72),
WTCP(0x6a6d98a4, 0x471cece7), WTCP(0x603c496c, 0x54657194),
};
RAM_ALIGN
LNK_SECTION_CONSTDATA
const FIXP_WTP SineWindow16[] = {
WTCP(0x7fd8878e, 0x0647d97c), WTCP(0x7e9d55fc, 0x12c8106f),
WTCP(0x7c29fbee, 0x1f19f97b), WTCP(0x78848414, 0x2b1f34eb),
WTCP(0x73b5ebd1, 0x36ba2014), WTCP(0x6dca0d14, 0x41ce1e65),
WTCP(0x66cf8120, 0x4c3fdff4), WTCP(0x5ed77c8a, 0x55f5a4d2),
};
RAM_ALIGN
LNK_SECTION_CONSTDATA
const FIXP_WTP SineWindow20[] = {
WTCP(0x7fe6bcb0, 0x05067734), WTCP(0x7f1cde01, 0x0f0b7727),
WTCP(0x7d8a5f40, 0x18f8b83c), WTCP(0x7b31bbb2, 0x22be8f87),
WTCP(0x7816a759, 0x2c4d9050), WTCP(0x743e0918, 0x3596a46c),
WTCP(0x6fadf2fc, 0x3e8b240e), WTCP(0x6a6d98a4, 0x471cece7),
WTCP(0x648543e4, 0x4f3e7875), WTCP(0x5dfe47ad, 0x56e2f15d),
};
RAM_ALIGN
LNK_SECTION_CONSTDATA
const FIXP_WTP SineWindow24[] = {
WTCP(0x7fee74a2, 0x0430238f), WTCP(0x7f62368f, 0x0c8bd35e),
WTCP(0x7e4a5426, 0x14d9c245), WTCP(0x7ca80038, 0x1d10d5c2),
WTCP(0x7a7d055b, 0x25280c5e), WTCP(0x77cbc3f2, 0x2d168792),
WTCP(0x74972f92, 0x34d3957e), WTCP(0x70e2cbc6, 0x3c56ba70),
WTCP(0x6cb2a837, 0x4397ba32), WTCP(0x680b5c33, 0x4a8ea111),
WTCP(0x62f201ac, 0x5133cc94), WTCP(0x5d6c2f99, 0x577ff3da),
};
RAM_ALIGN
LNK_SECTION_CONSTDATA
const FIXP_WTP SineWindow32[] = {
WTCP(0x7ff62182, 0x03242abf), WTCP(0x7fa736b4, 0x096a9049),
WTCP(0x7f0991c4, 0x0fab272b), WTCP(0x7e1d93ea, 0x15e21445),
WTCP(0x7ce3ceb2, 0x1c0b826a), WTCP(0x7b5d039e, 0x2223a4c5),
WTCP(0x798a23b1, 0x2826b928), WTCP(0x776c4edb, 0x2e110a62),
WTCP(0x7504d345, 0x33def287), WTCP(0x72552c85, 0x398cdd32),
WTCP(0x6f5f02b2, 0x3f1749b8), WTCP(0x6c242960, 0x447acd50),
WTCP(0x68a69e81, 0x49b41533), WTCP(0x64e88926, 0x4ebfe8a5),
WTCP(0x60ec3830, 0x539b2af0), WTCP(0x5cb420e0, 0x5842dd54),
};
RAM_ALIGN
LNK_SECTION_CONSTDATA
const FIXP_WTP SineWindow40[] = {
WTCP(0x7ff9af04, 0x02835b5a), WTCP(0x7fc72ae2, 0x07891418),
WTCP(0x7f62368f, 0x0c8bd35e), WTCP(0x7ecaf9e5, 0x11899ed3),
WTCP(0x7e01b096, 0x16807e15), WTCP(0x7d06aa16, 0x1b6e7b7a),
WTCP(0x7bda497d, 0x2051a4dd), WTCP(0x7a7d055b, 0x25280c5e),
WTCP(0x78ef678f, 0x29efc925), WTCP(0x77320d0d, 0x2ea6f827),
WTCP(0x7545a5a0, 0x334bbcde), WTCP(0x732af3a7, 0x37dc420c),
WTCP(0x70e2cbc6, 0x3c56ba70), WTCP(0x6e6e1492, 0x40b9617d),
WTCP(0x6bcdc639, 0x45027c0c), WTCP(0x6902ea1d, 0x4930590f),
WTCP(0x660e9a6a, 0x4d415234), WTCP(0x62f201ac, 0x5133cc94),
WTCP(0x5fae5a55, 0x55063951), WTCP(0x5c44ee40, 0x58b71632),
};
RAM_ALIGN
LNK_SECTION_CONSTDATA
const FIXP_WTP SineWindow48[] = {
WTCP(0x7ffb9d15, 0x02182427), WTCP(0x7fd8878e, 0x0647d97c),
WTCP(0x7f92661d, 0x0a75d60e), WTCP(0x7f294bfd, 0x0ea0f48c),
WTCP(0x7e9d55fc, 0x12c8106f), WTCP(0x7deeaa7a, 0x16ea0646),
WTCP(0x7d1d7958, 0x1b05b40f), WTCP(0x7c29fbee, 0x1f19f97b),
WTCP(0x7b1474fd, 0x2325b847), WTCP(0x79dd3098, 0x2727d486),
WTCP(0x78848414, 0x2b1f34eb), WTCP(0x770acdec, 0x2f0ac320),
WTCP(0x757075ac, 0x32e96c09), WTCP(0x73b5ebd1, 0x36ba2014),
WTCP(0x71dba9ab, 0x3a7bd382), WTCP(0x6fe2313c, 0x3e2d7eb1),
WTCP(0x6dca0d14, 0x41ce1e65), WTCP(0x6b93d02e, 0x455cb40c),
WTCP(0x694015c3, 0x48d84609), WTCP(0x66cf8120, 0x4c3fdff4),
WTCP(0x6442bd7e, 0x4f9292dc), WTCP(0x619a7dce, 0x52cf758f),
WTCP(0x5ed77c8a, 0x55f5a4d2), WTCP(0x5bfa7b82, 0x590443a7),
};
RAM_ALIGN
LNK_SECTION_CONSTDATA
const FIXP_WTP SineWindow64[] = {
WTCP(0x7ffd885a, 0x01921d20), WTCP(0x7fe9cbc0, 0x04b6195d),
WTCP(0x7fc25596, 0x07d95b9e), WTCP(0x7f872bf3, 0x0afb6805),
WTCP(0x7f3857f6, 0x0e1bc2e4), WTCP(0x7ed5e5c6, 0x1139f0cf),
WTCP(0x7e5fe493, 0x145576b1), WTCP(0x7dd6668f, 0x176dd9de),
WTCP(0x7d3980ec, 0x1a82a026), WTCP(0x7c894bde, 0x1d934fe5),
WTCP(0x7bc5e290, 0x209f701c), WTCP(0x7aef6323, 0x23a6887f),
WTCP(0x7a05eead, 0x26a82186), WTCP(0x7909a92d, 0x29a3c485),
WTCP(0x77fab989, 0x2c98fbba), WTCP(0x76d94989, 0x2f875262),
WTCP(0x75a585cf, 0x326e54c7), WTCP(0x745f9dd1, 0x354d9057),
WTCP(0x7307c3d0, 0x382493b0), WTCP(0x719e2cd2, 0x3af2eeb7),
WTCP(0x7023109a, 0x3db832a6), WTCP(0x6e96a99d, 0x4073f21d),
WTCP(0x6cf934fc, 0x4325c135), WTCP(0x6b4af279, 0x45cd358f),
WTCP(0x698c246c, 0x4869e665), WTCP(0x67bd0fbd, 0x4afb6c98),
WTCP(0x65ddfbd3, 0x4d8162c4), WTCP(0x63ef3290, 0x4ffb654d),
WTCP(0x61f1003f, 0x5269126e), WTCP(0x5fe3b38d, 0x54ca0a4b),
WTCP(0x5dc79d7c, 0x571deefa), WTCP(0x5b9d1154, 0x59646498),
};
RAM_ALIGN
LNK_SECTION_CONSTDATA
const FIXP_WTP SineWindow96[] = {
WTCP(0x7ffee744, 0x010c1460), WTCP(0x7ff62182, 0x03242abf),
WTCP(0x7fe49698, 0x053c0a01), WTCP(0x7fca47b9, 0x07538d6b),
WTCP(0x7fa736b4, 0x096a9049), WTCP(0x7f7b65ef, 0x0b80edf1),
WTCP(0x7f46d86c, 0x0d9681c2), WTCP(0x7f0991c4, 0x0fab272b),
WTCP(0x7ec3962a, 0x11beb9aa), WTCP(0x7e74ea6a, 0x13d114d0),
WTCP(0x7e1d93ea, 0x15e21445), WTCP(0x7dbd98a4, 0x17f193c5),
WTCP(0x7d54ff2e, 0x19ff6f2a), WTCP(0x7ce3ceb2, 0x1c0b826a),
WTCP(0x7c6a0ef2, 0x1e15a99a), WTCP(0x7be7c847, 0x201dc0ef),
WTCP(0x7b5d039e, 0x2223a4c5), WTCP(0x7ac9ca7a, 0x2427319d),
WTCP(0x7a2e26f2, 0x26284422), WTCP(0x798a23b1, 0x2826b928),
WTCP(0x78ddcbf5, 0x2a226db5), WTCP(0x78292b8d, 0x2c1b3efb),
WTCP(0x776c4edb, 0x2e110a62), WTCP(0x76a742d1, 0x3003ad85),
WTCP(0x75da14ef, 0x31f30638), WTCP(0x7504d345, 0x33def287),
WTCP(0x74278c72, 0x35c750bc), WTCP(0x73424fa0, 0x37abff5d),
WTCP(0x72552c85, 0x398cdd32), WTCP(0x71603361, 0x3b69c947),
WTCP(0x706374ff, 0x3d42a2ec), WTCP(0x6f5f02b2, 0x3f1749b8),
WTCP(0x6e52ee52, 0x40e79d8c), WTCP(0x6d3f4a40, 0x42b37e96),
WTCP(0x6c242960, 0x447acd50), WTCP(0x6b019f1a, 0x463d6a87),
WTCP(0x69d7bf57, 0x47fb3757), WTCP(0x68a69e81, 0x49b41533),
WTCP(0x676e5183, 0x4b67e5e4), WTCP(0x662eedc3, 0x4d168b8b),
WTCP(0x64e88926, 0x4ebfe8a5), WTCP(0x639b3a0b, 0x5063e008),
WTCP(0x62471749, 0x520254ef), WTCP(0x60ec3830, 0x539b2af0),
WTCP(0x5f8ab487, 0x552e4605), WTCP(0x5e22a487, 0x56bb8a90),
WTCP(0x5cb420e0, 0x5842dd54), WTCP(0x5b3f42ae, 0x59c42381),
};
RAM_ALIGN
LNK_SECTION_CONSTDATA
const FIXP_WTP SineWindow120[] = {
WTCP(0x7fff4c54, 0x00d676eb), WTCP(0x7ff9af04, 0x02835b5a),
WTCP(0x7fee74a2, 0x0430238f), WTCP(0x7fdd9dad, 0x05dcbcbe),
WTCP(0x7fc72ae2, 0x07891418), WTCP(0x7fab1d3d, 0x093516d4),
WTCP(0x7f8975f9, 0x0ae0b22c), WTCP(0x7f62368f, 0x0c8bd35e),
WTCP(0x7f3560b9, 0x0e3667ad), WTCP(0x7f02f66f, 0x0fe05c64),
WTCP(0x7ecaf9e5, 0x11899ed3), WTCP(0x7e8d6d91, 0x13321c53),
WTCP(0x7e4a5426, 0x14d9c245), WTCP(0x7e01b096, 0x16807e15),
WTCP(0x7db3860f, 0x18263d36), WTCP(0x7d5fd801, 0x19caed29),
WTCP(0x7d06aa16, 0x1b6e7b7a), WTCP(0x7ca80038, 0x1d10d5c2),
WTCP(0x7c43de8e, 0x1eb1e9a7), WTCP(0x7bda497d, 0x2051a4dd),
WTCP(0x7b6b45a5, 0x21eff528), WTCP(0x7af6d7e6, 0x238cc85d),
WTCP(0x7a7d055b, 0x25280c5e), WTCP(0x79fdd35c, 0x26c1af22),
WTCP(0x7979477d, 0x28599eb0), WTCP(0x78ef678f, 0x29efc925),
WTCP(0x7860399e, 0x2b841caf), WTCP(0x77cbc3f2, 0x2d168792),
WTCP(0x77320d0d, 0x2ea6f827), WTCP(0x76931bae, 0x30355cdd),
WTCP(0x75eef6ce, 0x31c1a43b), WTCP(0x7545a5a0, 0x334bbcde),
WTCP(0x74972f92, 0x34d3957e), WTCP(0x73e39c49, 0x36591cea),
WTCP(0x732af3a7, 0x37dc420c), WTCP(0x726d3dc6, 0x395cf3e9),
WTCP(0x71aa82f7, 0x3adb21a1), WTCP(0x70e2cbc6, 0x3c56ba70),
WTCP(0x701620f5, 0x3dcfadb0), WTCP(0x6f448b7e, 0x3f45ead8),
WTCP(0x6e6e1492, 0x40b9617d), WTCP(0x6d92c59b, 0x422a0154),
WTCP(0x6cb2a837, 0x4397ba32), WTCP(0x6bcdc639, 0x45027c0c),
WTCP(0x6ae429ae, 0x466a36f9), WTCP(0x69f5dcd3, 0x47cedb31),
WTCP(0x6902ea1d, 0x4930590f), WTCP(0x680b5c33, 0x4a8ea111),
WTCP(0x670f3df3, 0x4be9a3db), WTCP(0x660e9a6a, 0x4d415234),
WTCP(0x65097cdb, 0x4e959d08), WTCP(0x63fff0ba, 0x4fe6756a),
WTCP(0x62f201ac, 0x5133cc94), WTCP(0x61dfbb8a, 0x527d93e6),
WTCP(0x60c92a5a, 0x53c3bcea), WTCP(0x5fae5a55, 0x55063951),
WTCP(0x5e8f57e2, 0x5644faf4), WTCP(0x5d6c2f99, 0x577ff3da),
WTCP(0x5c44ee40, 0x58b71632), WTCP(0x5b19a0c8, 0x59ea5454),
};
RAM_ALIGN
LNK_SECTION_CONSTDATA
const FIXP_WTP SineWindow128[] = {
WTCP(0x7fff6216, 0x00c90f88), WTCP(0x7ffa72d1, 0x025b26d7),
WTCP(0x7ff09478, 0x03ed26e6), WTCP(0x7fe1c76b, 0x057f0035),
WTCP(0x7fce0c3e, 0x0710a345), WTCP(0x7fb563b3, 0x08a2009a),
WTCP(0x7f97cebd, 0x0a3308bd), WTCP(0x7f754e80, 0x0bc3ac35),
WTCP(0x7f4de451, 0x0d53db92), WTCP(0x7f2191b4, 0x0ee38766),
WTCP(0x7ef05860, 0x1072a048), WTCP(0x7eba3a39, 0x120116d5),
WTCP(0x7e7f3957, 0x138edbb1), WTCP(0x7e3f57ff, 0x151bdf86),
WTCP(0x7dfa98a8, 0x16a81305), WTCP(0x7db0fdf8, 0x183366e9),
WTCP(0x7d628ac6, 0x19bdcbf3), WTCP(0x7d0f4218, 0x1b4732ef),
WTCP(0x7cb72724, 0x1ccf8cb3), WTCP(0x7c5a3d50, 0x1e56ca1e),
WTCP(0x7bf88830, 0x1fdcdc1b), WTCP(0x7b920b89, 0x2161b3a0),
WTCP(0x7b26cb4f, 0x22e541af), WTCP(0x7ab6cba4, 0x24677758),
WTCP(0x7a4210d8, 0x25e845b6), WTCP(0x79c89f6e, 0x27679df4),
WTCP(0x794a7c12, 0x28e5714b), WTCP(0x78c7aba2, 0x2a61b101),
WTCP(0x78403329, 0x2bdc4e6f), WTCP(0x77b417df, 0x2d553afc),
WTCP(0x77235f2d, 0x2ecc681e), WTCP(0x768e0ea6, 0x3041c761),
WTCP(0x75f42c0b, 0x31b54a5e), WTCP(0x7555bd4c, 0x3326e2c3),
WTCP(0x74b2c884, 0x34968250), WTCP(0x740b53fb, 0x36041ad9),
WTCP(0x735f6626, 0x376f9e46), WTCP(0x72af05a7, 0x38d8fe93),
WTCP(0x71fa3949, 0x3a402dd2), WTCP(0x71410805, 0x3ba51e29),
WTCP(0x708378ff, 0x3d07c1d6), WTCP(0x6fc19385, 0x3e680b2c),
WTCP(0x6efb5f12, 0x3fc5ec98), WTCP(0x6e30e34a, 0x4121589b),
WTCP(0x6d6227fa, 0x427a41d0), WTCP(0x6c8f351c, 0x43d09aed),
WTCP(0x6bb812d1, 0x452456bd), WTCP(0x6adcc964, 0x46756828),
WTCP(0x69fd614a, 0x47c3c22f), WTCP(0x6919e320, 0x490f57ee),
WTCP(0x683257ab, 0x4a581c9e), WTCP(0x6746c7d8, 0x4b9e0390),
WTCP(0x66573cbb, 0x4ce10034), WTCP(0x6563bf92, 0x4e210617),
WTCP(0x646c59bf, 0x4f5e08e3), WTCP(0x637114cc, 0x5097fc5e),
WTCP(0x6271fa69, 0x51ced46e), WTCP(0x616f146c, 0x53028518),
WTCP(0x60686ccf, 0x5433027d), WTCP(0x5f5e0db3, 0x556040e2),
WTCP(0x5e50015d, 0x568a34a9), WTCP(0x5d3e5237, 0x57b0d256),
WTCP(0x5c290acc, 0x58d40e8c), WTCP(0x5b1035cf, 0x59f3de12),
};
RAM_ALIGN
LNK_SECTION_CONSTDATA
const FIXP_WTP SineWindow160[] = {
WTCP(0x7fff9aef, 0x00a0d951), WTCP(0x7ffc726f, 0x01e287fc),
WTCP(0x7ff62182, 0x03242abf), WTCP(0x7feca851, 0x0465b9aa),
WTCP(0x7fe00716, 0x05a72ccf), WTCP(0x7fd03e23, 0x06e87c3f),
WTCP(0x7fbd4dda, 0x0829a00c), WTCP(0x7fa736b4, 0x096a9049),
WTCP(0x7f8df93c, 0x0aab450d), WTCP(0x7f719611, 0x0bebb66c),
WTCP(0x7f520de6, 0x0d2bdc80), WTCP(0x7f2f6183, 0x0e6baf61),
WTCP(0x7f0991c4, 0x0fab272b), WTCP(0x7ee09f95, 0x10ea3bfd),
WTCP(0x7eb48bfb, 0x1228e5f8), WTCP(0x7e85580c, 0x13671d3d),
WTCP(0x7e5304f2, 0x14a4d9f4), WTCP(0x7e1d93ea, 0x15e21445),
WTCP(0x7de50646, 0x171ec45c), WTCP(0x7da95d6c, 0x185ae269),
WTCP(0x7d6a9ad5, 0x199666a0), WTCP(0x7d28c00c, 0x1ad14938),
WTCP(0x7ce3ceb2, 0x1c0b826a), WTCP(0x7c9bc87a, 0x1d450a78),
WTCP(0x7c50af2b, 0x1e7dd9a4), WTCP(0x7c02849f, 0x1fb5e836),
WTCP(0x7bb14ac5, 0x20ed2e7b), WTCP(0x7b5d039e, 0x2223a4c5),
WTCP(0x7b05b13d, 0x2359436c), WTCP(0x7aab55ca, 0x248e02cb),
WTCP(0x7a4df380, 0x25c1db44), WTCP(0x79ed8cad, 0x26f4c53e),
WTCP(0x798a23b1, 0x2826b928), WTCP(0x7923bb01, 0x2957af74),
WTCP(0x78ba5524, 0x2a87a09d), WTCP(0x784df4b3, 0x2bb68522),
WTCP(0x77de9c5b, 0x2ce45589), WTCP(0x776c4edb, 0x2e110a62),
WTCP(0x76f70f05, 0x2f3c9c40), WTCP(0x767edfbe, 0x306703bf),
WTCP(0x7603c3fd, 0x31903982), WTCP(0x7585becb, 0x32b83634),
WTCP(0x7504d345, 0x33def287), WTCP(0x74810499, 0x35046736),
WTCP(0x73fa5607, 0x36288d03), WTCP(0x7370cae2, 0x374b5cb9),
WTCP(0x72e4668f, 0x386ccf2a), WTCP(0x72552c85, 0x398cdd32),
WTCP(0x71c3204c, 0x3aab7fb7), WTCP(0x712e457f, 0x3bc8afa5),
WTCP(0x70969fca, 0x3ce465f3), WTCP(0x6ffc32eb, 0x3dfe9ba1),
WTCP(0x6f5f02b2, 0x3f1749b8), WTCP(0x6ebf12ff, 0x402e694c),
WTCP(0x6e1c67c4, 0x4143f379), WTCP(0x6d770506, 0x4257e166),
WTCP(0x6cceeed8, 0x436a2c45), WTCP(0x6c242960, 0x447acd50),
WTCP(0x6b76b8d6, 0x4589bdcf), WTCP(0x6ac6a180, 0x4696f710),
WTCP(0x6a13e7b8, 0x47a27271), WTCP(0x695e8fe5, 0x48ac2957),
WTCP(0x68a69e81, 0x49b41533), WTCP(0x67ec1817, 0x4aba2f84),
WTCP(0x672f013f, 0x4bbe71d1), WTCP(0x666f5ea6, 0x4cc0d5ae),
WTCP(0x65ad3505, 0x4dc154bb), WTCP(0x64e88926, 0x4ebfe8a5),
WTCP(0x64215fe5, 0x4fbc8b22), WTCP(0x6357be2a, 0x50b735f8),
WTCP(0x628ba8ef, 0x51afe2f6), WTCP(0x61bd253f, 0x52a68bfb),
WTCP(0x60ec3830, 0x539b2af0), WTCP(0x6018e6eb, 0x548db9cb),
WTCP(0x5f4336a7, 0x557e3292), WTCP(0x5e6b2ca8, 0x566c8f55),
WTCP(0x5d90ce45, 0x5758ca31), WTCP(0x5cb420e0, 0x5842dd54),
WTCP(0x5bd529eb, 0x592ac2f7), WTCP(0x5af3eee6, 0x5a107561),
};
RAM_ALIGN
LNK_SECTION_CONSTDATA
const FIXP_WTP SineWindow192[] = {
WTCP(0x7fffb9d1, 0x00860a79), WTCP(0x7ffd885a, 0x01921d20),
WTCP(0x7ff92577, 0x029e28e2), WTCP(0x7ff2913a, 0x03aa292a),
WTCP(0x7fe9cbc0, 0x04b6195d), WTCP(0x7fded530, 0x05c1f4e7),
WTCP(0x7fd1adb9, 0x06cdb72f), WTCP(0x7fc25596, 0x07d95b9e),
WTCP(0x7fb0cd0a, 0x08e4dda0), WTCP(0x7f9d1461, 0x09f0389f),
WTCP(0x7f872bf3, 0x0afb6805), WTCP(0x7f6f141f, 0x0c066740),
WTCP(0x7f54cd4f, 0x0d1131ba), WTCP(0x7f3857f6, 0x0e1bc2e4),
WTCP(0x7f19b491, 0x0f26162a), WTCP(0x7ef8e3a6, 0x103026fe),
WTCP(0x7ed5e5c6, 0x1139f0cf), WTCP(0x7eb0bb8a, 0x12436f10),
WTCP(0x7e896595, 0x134c9d34), WTCP(0x7e5fe493, 0x145576b1),
WTCP(0x7e34393b, 0x155df6fc), WTCP(0x7e06644c, 0x1666198d),
WTCP(0x7dd6668f, 0x176dd9de), WTCP(0x7da440d6, 0x1875336a),
WTCP(0x7d6ff3fe, 0x197c21ad), WTCP(0x7d3980ec, 0x1a82a026),
WTCP(0x7d00e88f, 0x1b88aa55), WTCP(0x7cc62bdf, 0x1c8e3bbe),
WTCP(0x7c894bde, 0x1d934fe5), WTCP(0x7c4a4996, 0x1e97e251),
WTCP(0x7c09261d, 0x1f9bee8a), WTCP(0x7bc5e290, 0x209f701c),
WTCP(0x7b808015, 0x21a26295), WTCP(0x7b38ffde, 0x22a4c185),
WTCP(0x7aef6323, 0x23a6887f), WTCP(0x7aa3ab29, 0x24a7b317),
WTCP(0x7a55d93a, 0x25a83ce6), WTCP(0x7a05eead, 0x26a82186),
WTCP(0x79b3ece0, 0x27a75c95), WTCP(0x795fd53a, 0x28a5e9b4),
WTCP(0x7909a92d, 0x29a3c485), WTCP(0x78b16a32, 0x2aa0e8b0),
WTCP(0x785719cc, 0x2b9d51dd), WTCP(0x77fab989, 0x2c98fbba),
WTCP(0x779c4afc, 0x2d93e1f8), WTCP(0x773bcfc4, 0x2e8e0048),
WTCP(0x76d94989, 0x2f875262), WTCP(0x7674b9fa, 0x307fd401),
WTCP(0x760e22d1, 0x317780e2), WTCP(0x75a585cf, 0x326e54c7),
WTCP(0x753ae4c0, 0x33644b76), WTCP(0x74ce4177, 0x345960b7),
WTCP(0x745f9dd1, 0x354d9057), WTCP(0x73eefbb3, 0x3640d627),
WTCP(0x737c5d0b, 0x37332dfd), WTCP(0x7307c3d0, 0x382493b0),
WTCP(0x72913201, 0x3915031f), WTCP(0x7218a9a7, 0x3a04782a),
WTCP(0x719e2cd2, 0x3af2eeb7), WTCP(0x7121bd9c, 0x3be062b0),
WTCP(0x70a35e25, 0x3cccd004), WTCP(0x7023109a, 0x3db832a6),
WTCP(0x6fa0d72c, 0x3ea2868c), WTCP(0x6f1cb416, 0x3f8bc7b4),
WTCP(0x6e96a99d, 0x4073f21d), WTCP(0x6e0eba0c, 0x415b01ce),
WTCP(0x6d84e7b7, 0x4240f2d1), WTCP(0x6cf934fc, 0x4325c135),
WTCP(0x6c6ba43e, 0x44096910), WTCP(0x6bdc37eb, 0x44ebe679),
WTCP(0x6b4af279, 0x45cd358f), WTCP(0x6ab7d663, 0x46ad5278),
WTCP(0x6a22e630, 0x478c395a), WTCP(0x698c246c, 0x4869e665),
WTCP(0x68f393ae, 0x494655cc), WTCP(0x68593691, 0x4a2183c8),
WTCP(0x67bd0fbd, 0x4afb6c98), WTCP(0x671f21dc, 0x4bd40c80),
WTCP(0x667f6fa5, 0x4cab5fc9), WTCP(0x65ddfbd3, 0x4d8162c4),
WTCP(0x653ac92b, 0x4e5611c5), WTCP(0x6495da79, 0x4f296928),
WTCP(0x63ef3290, 0x4ffb654d), WTCP(0x6346d44b, 0x50cc029c),
WTCP(0x629cc28c, 0x519b3d80), WTCP(0x61f1003f, 0x5269126e),
WTCP(0x61439053, 0x53357ddf), WTCP(0x609475c3, 0x54007c51),
WTCP(0x5fe3b38d, 0x54ca0a4b), WTCP(0x5f314cba, 0x55922457),
WTCP(0x5e7d4458, 0x5658c709), WTCP(0x5dc79d7c, 0x571deefa),
WTCP(0x5d105b44, 0x57e198c7), WTCP(0x5c5780d3, 0x58a3c118),
WTCP(0x5b9d1154, 0x59646498), WTCP(0x5ae10ff9, 0x5a237ffa),
};
RAM_ALIGN
LNK_SECTION_CONSTDATA
const FIXP_WTP SineWindow240[] = {
WTCP(0x7fffd315, 0x006b3b9b), WTCP(0x7ffe6bbf, 0x0141b1a5),
WTCP(0x7ffb9d15, 0x02182427), WTCP(0x7ff76721, 0x02ee90c8),
WTCP(0x7ff1c9ef, 0x03c4f52f), WTCP(0x7feac58d, 0x049b4f00),
WTCP(0x7fe25a0f, 0x05719be2), WTCP(0x7fd8878e, 0x0647d97c),
WTCP(0x7fcd4e24, 0x071e0575), WTCP(0x7fc0adf2, 0x07f41d72),
WTCP(0x7fb2a71b, 0x08ca1f1b), WTCP(0x7fa339c5, 0x09a00817),
WTCP(0x7f92661d, 0x0a75d60e), WTCP(0x7f802c52, 0x0b4b86a8),
WTCP(0x7f6c8c96, 0x0c21178c), WTCP(0x7f578721, 0x0cf68662),
WTCP(0x7f411c2f, 0x0dcbd0d5), WTCP(0x7f294bfd, 0x0ea0f48c),
WTCP(0x7f1016ce, 0x0f75ef33), WTCP(0x7ef57cea, 0x104abe71),
WTCP(0x7ed97e9c, 0x111f5ff4), WTCP(0x7ebc1c31, 0x11f3d164),
WTCP(0x7e9d55fc, 0x12c8106f), WTCP(0x7e7d2c54, 0x139c1abf),
WTCP(0x7e5b9f93, 0x146fee03), WTCP(0x7e38b017, 0x154387e6),
WTCP(0x7e145e42, 0x1616e618), WTCP(0x7deeaa7a, 0x16ea0646),
WTCP(0x7dc79529, 0x17bce621), WTCP(0x7d9f1ebd, 0x188f8357),
WTCP(0x7d7547a7, 0x1961db9b), WTCP(0x7d4a105d, 0x1a33ec9c),
WTCP(0x7d1d7958, 0x1b05b40f), WTCP(0x7cef8315, 0x1bd72fa4),
WTCP(0x7cc02e15, 0x1ca85d12), WTCP(0x7c8f7ade, 0x1d793a0b),
WTCP(0x7c5d69f7, 0x1e49c447), WTCP(0x7c29fbee, 0x1f19f97b),
WTCP(0x7bf53153, 0x1fe9d75f), WTCP(0x7bbf0aba, 0x20b95bac),
WTCP(0x7b8788ba, 0x2188841a), WTCP(0x7b4eabf1, 0x22574e65),
WTCP(0x7b1474fd, 0x2325b847), WTCP(0x7ad8e482, 0x23f3bf7e),
WTCP(0x7a9bfb27, 0x24c161c7), WTCP(0x7a5db997, 0x258e9ce0),
WTCP(0x7a1e2082, 0x265b6e8a), WTCP(0x79dd3098, 0x2727d486),
WTCP(0x799aea92, 0x27f3cc94), WTCP(0x79574f28, 0x28bf547b),
WTCP(0x79125f19, 0x298a69fc), WTCP(0x78cc1b26, 0x2a550adf),
WTCP(0x78848414, 0x2b1f34eb), WTCP(0x783b9aad, 0x2be8e5e8),
WTCP(0x77f15fbc, 0x2cb21ba0), WTCP(0x77a5d413, 0x2d7ad3de),
WTCP(0x7758f886, 0x2e430c6f), WTCP(0x770acdec, 0x2f0ac320),
WTCP(0x76bb5521, 0x2fd1f5c1), WTCP(0x766a8f04, 0x3098a223),
WTCP(0x76187c77, 0x315ec617), WTCP(0x75c51e61, 0x32245f72),
WTCP(0x757075ac, 0x32e96c09), WTCP(0x751a8346, 0x33ade9b3),
WTCP(0x74c34820, 0x3471d647), WTCP(0x746ac52f, 0x35352fa1),
WTCP(0x7410fb6b, 0x35f7f39c), WTCP(0x73b5ebd1, 0x36ba2014),
WTCP(0x73599760, 0x377bb2e9), WTCP(0x72fbff1b, 0x383ca9fb),
WTCP(0x729d2409, 0x38fd032d), WTCP(0x723d0734, 0x39bcbc63),
WTCP(0x71dba9ab, 0x3a7bd382), WTCP(0x71790c7e, 0x3b3a4672),
WTCP(0x711530c2, 0x3bf8131c), WTCP(0x70b01790, 0x3cb5376b),
WTCP(0x7049c203, 0x3d71b14d), WTCP(0x6fe2313c, 0x3e2d7eb1),
WTCP(0x6f79665b, 0x3ee89d86), WTCP(0x6f0f6289, 0x3fa30bc1),
WTCP(0x6ea426ed, 0x405cc754), WTCP(0x6e37b4b6, 0x4115ce38),
WTCP(0x6dca0d14, 0x41ce1e65), WTCP(0x6d5b313b, 0x4285b5d4),
WTCP(0x6ceb2261, 0x433c9283), WTCP(0x6c79e1c2, 0x43f2b271),
WTCP(0x6c07709b, 0x44a8139e), WTCP(0x6b93d02e, 0x455cb40c),
WTCP(0x6b1f01c0, 0x461091c2), WTCP(0x6aa90697, 0x46c3aac5),
WTCP(0x6a31e000, 0x4775fd1f), WTCP(0x69b98f48, 0x482786dc),
WTCP(0x694015c3, 0x48d84609), WTCP(0x68c574c4, 0x498838b6),
WTCP(0x6849ada3, 0x4a375cf5), WTCP(0x67ccc1be, 0x4ae5b0da),
WTCP(0x674eb271, 0x4b93327c), WTCP(0x66cf8120, 0x4c3fdff4),
WTCP(0x664f2f2e, 0x4cebb75c), WTCP(0x65cdbe05, 0x4d96b6d3),
WTCP(0x654b2f10, 0x4e40dc79), WTCP(0x64c783bd, 0x4eea2670),
WTCP(0x6442bd7e, 0x4f9292dc), WTCP(0x63bcddc7, 0x503a1fe5),
WTCP(0x6335e611, 0x50e0cbb4), WTCP(0x62add7d6, 0x51869476),
WTCP(0x6224b495, 0x522b7859), WTCP(0x619a7dce, 0x52cf758f),
WTCP(0x610f3505, 0x53728a4a), WTCP(0x6082dbc1, 0x5414b4c1),
WTCP(0x5ff5738d, 0x54b5f32c), WTCP(0x5f66fdf5, 0x555643c8),
WTCP(0x5ed77c8a, 0x55f5a4d2), WTCP(0x5e46f0dd, 0x5694148b),
WTCP(0x5db55c86, 0x57319135), WTCP(0x5d22c11c, 0x57ce1917),
WTCP(0x5c8f203b, 0x5869aa79), WTCP(0x5bfa7b82, 0x590443a7),
WTCP(0x5b64d492, 0x599de2ee), WTCP(0x5ace2d0f, 0x5a36869f),
};
RAM_ALIGN
LNK_SECTION_CONSTDATA
const FIXP_WTP SineWindow256[] = {
WTCP(0x7fffd886, 0x006487e3), WTCP(0x7ffe9cb2, 0x012d96b1),
WTCP(0x7ffc250f, 0x01f6a297), WTCP(0x7ff871a2, 0x02bfa9a4),
WTCP(0x7ff38274, 0x0388a9ea), WTCP(0x7fed5791, 0x0451a177),
WTCP(0x7fe5f108, 0x051a8e5c), WTCP(0x7fdd4eec, 0x05e36ea9),
WTCP(0x7fd37153, 0x06ac406f), WTCP(0x7fc85854, 0x077501be),
WTCP(0x7fbc040a, 0x083db0a7), WTCP(0x7fae7495, 0x09064b3a),
WTCP(0x7f9faa15, 0x09cecf89), WTCP(0x7f8fa4b0, 0x0a973ba5),
WTCP(0x7f7e648c, 0x0b5f8d9f), WTCP(0x7f6be9d4, 0x0c27c389),
WTCP(0x7f5834b7, 0x0cefdb76), WTCP(0x7f434563, 0x0db7d376),
WTCP(0x7f2d1c0e, 0x0e7fa99e), WTCP(0x7f15b8ee, 0x0f475bff),
WTCP(0x7efd1c3c, 0x100ee8ad), WTCP(0x7ee34636, 0x10d64dbd),
WTCP(0x7ec8371a, 0x119d8941), WTCP(0x7eabef2c, 0x1264994e),
WTCP(0x7e8e6eb2, 0x132b7bf9), WTCP(0x7e6fb5f4, 0x13f22f58),
WTCP(0x7e4fc53e, 0x14b8b17f), WTCP(0x7e2e9cdf, 0x157f0086),
WTCP(0x7e0c3d29, 0x16451a83), WTCP(0x7de8a670, 0x170afd8d),
WTCP(0x7dc3d90d, 0x17d0a7bc), WTCP(0x7d9dd55a, 0x18961728),
WTCP(0x7d769bb5, 0x195b49ea), WTCP(0x7d4e2c7f, 0x1a203e1b),
WTCP(0x7d24881b, 0x1ae4f1d6), WTCP(0x7cf9aef0, 0x1ba96335),
WTCP(0x7ccda169, 0x1c6d9053), WTCP(0x7ca05ff1, 0x1d31774d),
WTCP(0x7c71eaf9, 0x1df5163f), WTCP(0x7c4242f2, 0x1eb86b46),
WTCP(0x7c116853, 0x1f7b7481), WTCP(0x7bdf5b94, 0x203e300d),
WTCP(0x7bac1d31, 0x21009c0c), WTCP(0x7b77ada8, 0x21c2b69c),
WTCP(0x7b420d7a, 0x22847de0), WTCP(0x7b0b3d2c, 0x2345eff8),
WTCP(0x7ad33d45, 0x24070b08), WTCP(0x7a9a0e50, 0x24c7cd33),
WTCP(0x7a5fb0d8, 0x2588349d), WTCP(0x7a24256f, 0x26483f6c),
WTCP(0x79e76ca7, 0x2707ebc7), WTCP(0x79a98715, 0x27c737d3),
WTCP(0x796a7554, 0x288621b9), WTCP(0x792a37fe, 0x2944a7a2),
WTCP(0x78e8cfb2, 0x2a02c7b8), WTCP(0x78a63d11, 0x2ac08026),
WTCP(0x786280bf, 0x2b7dcf17), WTCP(0x781d9b65, 0x2c3ab2b9),
WTCP(0x77d78daa, 0x2cf72939), WTCP(0x7790583e, 0x2db330c7),
WTCP(0x7747fbce, 0x2e6ec792), WTCP(0x76fe790e, 0x2f29ebcc),
WTCP(0x76b3d0b4, 0x2fe49ba7), WTCP(0x76680376, 0x309ed556),
WTCP(0x761b1211, 0x3158970e), WTCP(0x75ccfd42, 0x3211df04),
WTCP(0x757dc5ca, 0x32caab6f), WTCP(0x752d6c6c, 0x3382fa88),
WTCP(0x74dbf1ef, 0x343aca87), WTCP(0x7489571c, 0x34f219a8),
WTCP(0x74359cbd, 0x35a8e625), WTCP(0x73e0c3a3, 0x365f2e3b),
WTCP(0x738acc9e, 0x3714f02a), WTCP(0x7333b883, 0x37ca2a30),
WTCP(0x72db8828, 0x387eda8e), WTCP(0x72823c67, 0x3932ff87),
WTCP(0x7227d61c, 0x39e6975e), WTCP(0x71cc5626, 0x3a99a057),
WTCP(0x716fbd68, 0x3b4c18ba), WTCP(0x71120cc5, 0x3bfdfecd),
WTCP(0x70b34525, 0x3caf50da), WTCP(0x70536771, 0x3d600d2c),
WTCP(0x6ff27497, 0x3e10320d), WTCP(0x6f906d84, 0x3ebfbdcd),
WTCP(0x6f2d532c, 0x3f6eaeb8), WTCP(0x6ec92683, 0x401d0321),
WTCP(0x6e63e87f, 0x40cab958), WTCP(0x6dfd9a1c, 0x4177cfb1),
WTCP(0x6d963c54, 0x42244481), WTCP(0x6d2dd027, 0x42d0161e),
WTCP(0x6cc45698, 0x437b42e1), WTCP(0x6c59d0a9, 0x4425c923),
WTCP(0x6bee3f62, 0x44cfa740), WTCP(0x6b81a3cd, 0x4578db93),
WTCP(0x6b13fef5, 0x4621647d), WTCP(0x6aa551e9, 0x46c9405c),
WTCP(0x6a359db9, 0x47706d93), WTCP(0x69c4e37a, 0x4816ea86),
WTCP(0x69532442, 0x48bcb599), WTCP(0x68e06129, 0x4961cd33),
WTCP(0x686c9b4b, 0x4a062fbd), WTCP(0x67f7d3c5, 0x4aa9dba2),
WTCP(0x67820bb7, 0x4b4ccf4d), WTCP(0x670b4444, 0x4bef092d),
WTCP(0x66937e91, 0x4c9087b1), WTCP(0x661abbc5, 0x4d31494b),
WTCP(0x65a0fd0b, 0x4dd14c6e), WTCP(0x6526438f, 0x4e708f8f),
WTCP(0x64aa907f, 0x4f0f1126), WTCP(0x642de50d, 0x4faccfab),
WTCP(0x63b0426d, 0x5049c999), WTCP(0x6331a9d4, 0x50e5fd6d),
WTCP(0x62b21c7b, 0x518169a5), WTCP(0x62319b9d, 0x521c0cc2),
WTCP(0x61b02876, 0x52b5e546), WTCP(0x612dc447, 0x534ef1b5),
WTCP(0x60aa7050, 0x53e73097), WTCP(0x60262dd6, 0x547ea073),
WTCP(0x5fa0fe1f, 0x55153fd4), WTCP(0x5f1ae274, 0x55ab0d46),
WTCP(0x5e93dc1f, 0x56400758), WTCP(0x5e0bec6e, 0x56d42c99),
WTCP(0x5d8314b1, 0x57677b9d), WTCP(0x5cf95638, 0x57f9f2f8),
WTCP(0x5c6eb258, 0x588b9140), WTCP(0x5be32a67, 0x591c550e),
WTCP(0x5b56bfbd, 0x59ac3cfd), WTCP(0x5ac973b5, 0x5a3b47ab),
};
RAM_ALIGN
LNK_SECTION_CONSTDATA
const FIXP_WTP SineWindow384[] = {
WTCP(0x7fffee74, 0x00430546), WTCP(0x7fff6216, 0x00c90f88),
WTCP(0x7ffe495b, 0x014f18ee), WTCP(0x7ffca443, 0x01d520e4),
WTCP(0x7ffa72d1, 0x025b26d7), WTCP(0x7ff7b507, 0x02e12a36),
WTCP(0x7ff46ae8, 0x03672a6c), WTCP(0x7ff09478, 0x03ed26e6),
WTCP(0x7fec31ba, 0x04731f13), WTCP(0x7fe742b4, 0x04f9125e),
WTCP(0x7fe1c76b, 0x057f0035), WTCP(0x7fdbbfe6, 0x0604e805),
WTCP(0x7fd52c29, 0x068ac93b), WTCP(0x7fce0c3e, 0x0710a345),
WTCP(0x7fc6602c, 0x0796758f), WTCP(0x7fbe27fa, 0x081c3f87),
WTCP(0x7fb563b3, 0x08a2009a), WTCP(0x7fac135f, 0x0927b836),
WTCP(0x7fa2370a, 0x09ad65c8), WTCP(0x7f97cebd, 0x0a3308bd),
WTCP(0x7f8cda84, 0x0ab8a082), WTCP(0x7f815a6b, 0x0b3e2c86),
WTCP(0x7f754e80, 0x0bc3ac35), WTCP(0x7f68b6ce, 0x0c491efe),
WTCP(0x7f5b9364, 0x0cce844e), WTCP(0x7f4de451, 0x0d53db92),
WTCP(0x7f3fa9a2, 0x0dd92439), WTCP(0x7f30e369, 0x0e5e5db0),
WTCP(0x7f2191b4, 0x0ee38766), WTCP(0x7f11b495, 0x0f68a0c8),
WTCP(0x7f014c1e, 0x0feda943), WTCP(0x7ef05860, 0x1072a048),
WTCP(0x7eded96d, 0x10f78543), WTCP(0x7ecccf5a, 0x117c57a2),
WTCP(0x7eba3a39, 0x120116d5), WTCP(0x7ea71a20, 0x1285c249),
WTCP(0x7e936f22, 0x130a596e), WTCP(0x7e7f3957, 0x138edbb1),
WTCP(0x7e6a78d3, 0x14134881), WTCP(0x7e552dae, 0x14979f4e),
WTCP(0x7e3f57ff, 0x151bdf86), WTCP(0x7e28f7de, 0x15a00897),
WTCP(0x7e120d63, 0x162419f2), WTCP(0x7dfa98a8, 0x16a81305),
WTCP(0x7de299c6, 0x172bf33f), WTCP(0x7dca10d8, 0x17afba11),
WTCP(0x7db0fdf8, 0x183366e9), WTCP(0x7d976142, 0x18b6f936),
WTCP(0x7d7d3ad3, 0x193a706a), WTCP(0x7d628ac6, 0x19bdcbf3),
WTCP(0x7d475139, 0x1a410b41), WTCP(0x7d2b8e4a, 0x1ac42dc5),
WTCP(0x7d0f4218, 0x1b4732ef), WTCP(0x7cf26cc1, 0x1bca1a2f),
WTCP(0x7cd50e65, 0x1c4ce2f6), WTCP(0x7cb72724, 0x1ccf8cb3),
WTCP(0x7c98b71f, 0x1d5216d8), WTCP(0x7c79be78, 0x1dd480d6),
WTCP(0x7c5a3d50, 0x1e56ca1e), WTCP(0x7c3a33ca, 0x1ed8f220),
WTCP(0x7c19a209, 0x1f5af84f), WTCP(0x7bf88830, 0x1fdcdc1b),
WTCP(0x7bd6e665, 0x205e9cf6), WTCP(0x7bb4bccb, 0x20e03a51),
WTCP(0x7b920b89, 0x2161b3a0), WTCP(0x7b6ed2c5, 0x21e30853),
WTCP(0x7b4b12a4, 0x226437dc), WTCP(0x7b26cb4f, 0x22e541af),
WTCP(0x7b01fced, 0x2366253d), WTCP(0x7adca7a6, 0x23e6e1fa),
WTCP(0x7ab6cba4, 0x24677758), WTCP(0x7a90690f, 0x24e7e4c9),
WTCP(0x7a698012, 0x256829c2), WTCP(0x7a4210d8, 0x25e845b6),
WTCP(0x7a1a1b8c, 0x26683818), WTCP(0x79f1a05a, 0x26e8005b),
WTCP(0x79c89f6e, 0x27679df4), WTCP(0x799f18f4, 0x27e71057),
WTCP(0x79750d1c, 0x286656f8), WTCP(0x794a7c12, 0x28e5714b),
WTCP(0x791f6605, 0x29645ec5), WTCP(0x78f3cb25, 0x29e31edb),
WTCP(0x78c7aba2, 0x2a61b101), WTCP(0x789b07ab, 0x2ae014ae),
WTCP(0x786ddf72, 0x2b5e4956), WTCP(0x78403329, 0x2bdc4e6f),
WTCP(0x78120300, 0x2c5a236f), WTCP(0x77e34f2c, 0x2cd7c7cc),
WTCP(0x77b417df, 0x2d553afc), WTCP(0x77845d4e, 0x2dd27c75),
WTCP(0x77541fab, 0x2e4f8bae), WTCP(0x77235f2d, 0x2ecc681e),
WTCP(0x76f21c09, 0x2f49113d), WTCP(0x76c05674, 0x2fc58680),
WTCP(0x768e0ea6, 0x3041c761), WTCP(0x765b44d5, 0x30bdd356),
WTCP(0x7627f939, 0x3139a9d7), WTCP(0x75f42c0b, 0x31b54a5e),
WTCP(0x75bfdd83, 0x3230b461), WTCP(0x758b0ddb, 0x32abe75a),
WTCP(0x7555bd4c, 0x3326e2c3), WTCP(0x751fec11, 0x33a1a612),
WTCP(0x74e99a65, 0x341c30c4), WTCP(0x74b2c884, 0x34968250),
WTCP(0x747b76a9, 0x35109a31), WTCP(0x7443a512, 0x358a77e0),
WTCP(0x740b53fb, 0x36041ad9), WTCP(0x73d283a2, 0x367d8296),
WTCP(0x73993447, 0x36f6ae91), WTCP(0x735f6626, 0x376f9e46),
WTCP(0x73251981, 0x37e85130), WTCP(0x72ea4e96, 0x3860c6cb),
WTCP(0x72af05a7, 0x38d8fe93), WTCP(0x72733ef3, 0x3950f804),
WTCP(0x7236fabe, 0x39c8b29a), WTCP(0x71fa3949, 0x3a402dd2),
WTCP(0x71bcfad6, 0x3ab76929), WTCP(0x717f3fa8, 0x3b2e641c),
WTCP(0x71410805, 0x3ba51e29), WTCP(0x7102542f, 0x3c1b96ce),
WTCP(0x70c3246b, 0x3c91cd88), WTCP(0x708378ff, 0x3d07c1d6),
WTCP(0x70435230, 0x3d7d7337), WTCP(0x7002b045, 0x3df2e129),
WTCP(0x6fc19385, 0x3e680b2c), WTCP(0x6f7ffc37, 0x3edcf0c0),
WTCP(0x6f3deaa4, 0x3f519164), WTCP(0x6efb5f12, 0x3fc5ec98),
WTCP(0x6eb859cc, 0x403a01dc), WTCP(0x6e74db1c, 0x40add0b2),
WTCP(0x6e30e34a, 0x4121589b), WTCP(0x6dec72a2, 0x41949917),
WTCP(0x6da7896e, 0x420791a8), WTCP(0x6d6227fa, 0x427a41d0),
WTCP(0x6d1c4e93, 0x42eca912), WTCP(0x6cd5fd85, 0x435ec6f0),
WTCP(0x6c8f351c, 0x43d09aed), WTCP(0x6c47f5a7, 0x4442248b),
WTCP(0x6c003f74, 0x44b3634f), WTCP(0x6bb812d1, 0x452456bd),
WTCP(0x6b6f700e, 0x4594fe58), WTCP(0x6b265779, 0x460559a4),
WTCP(0x6adcc964, 0x46756828), WTCP(0x6a92c61f, 0x46e52967),
WTCP(0x6a484dfc, 0x47549ce7), WTCP(0x69fd614a, 0x47c3c22f),
WTCP(0x69b2005e, 0x483298c4), WTCP(0x69662b8a, 0x48a1202c),
WTCP(0x6919e320, 0x490f57ee), WTCP(0x68cd2775, 0x497d3f93),
WTCP(0x687ff8dc, 0x49ead6a0), WTCP(0x683257ab, 0x4a581c9e),
WTCP(0x67e44436, 0x4ac51114), WTCP(0x6795bed3, 0x4b31b38d),
WTCP(0x6746c7d8, 0x4b9e0390), WTCP(0x66f75f9b, 0x4c0a00a6),
WTCP(0x66a78675, 0x4c75aa5a), WTCP(0x66573cbb, 0x4ce10034),
WTCP(0x660682c7, 0x4d4c01c0), WTCP(0x65b558f1, 0x4db6ae88),
WTCP(0x6563bf92, 0x4e210617), WTCP(0x6511b703, 0x4e8b07f9),
WTCP(0x64bf3f9f, 0x4ef4b3b9), WTCP(0x646c59bf, 0x4f5e08e3),
WTCP(0x641905bf, 0x4fc70704), WTCP(0x63c543fa, 0x502fada9),
WTCP(0x637114cc, 0x5097fc5e), WTCP(0x631c7892, 0x50fff2b2),
WTCP(0x62c76fa7, 0x51679033), WTCP(0x6271fa69, 0x51ced46e),
WTCP(0x621c1937, 0x5235bef4), WTCP(0x61c5cc6d, 0x529c4f51),
WTCP(0x616f146c, 0x53028518), WTCP(0x6117f191, 0x53685fd6),
WTCP(0x60c0643d, 0x53cddf1d), WTCP(0x60686ccf, 0x5433027d),
WTCP(0x60100ba8, 0x5497c988), WTCP(0x5fb74129, 0x54fc33ce),
WTCP(0x5f5e0db3, 0x556040e2), WTCP(0x5f0471a8, 0x55c3f056),
WTCP(0x5eaa6d6b, 0x562741bd), WTCP(0x5e50015d, 0x568a34a9),
WTCP(0x5df52de3, 0x56ecc8af), WTCP(0x5d99f35f, 0x574efd62),
WTCP(0x5d3e5237, 0x57b0d256), WTCP(0x5ce24acd, 0x58124720),
WTCP(0x5c85dd88, 0x58735b56), WTCP(0x5c290acc, 0x58d40e8c),
WTCP(0x5bcbd300, 0x5934605a), WTCP(0x5b6e3689, 0x59945054),
WTCP(0x5b1035cf, 0x59f3de12), WTCP(0x5ab1d138, 0x5a53092c),
};
RAM_ALIGN
LNK_SECTION_CONSTDATA
const FIXP_WTP SineWindow480[] = {
WTCP(0x7ffff4c5, 0x00359dd2), WTCP(0x7fff9aef, 0x00a0d951),
WTCP(0x7ffee744, 0x010c1460), WTCP(0x7ffdd9c4, 0x01774eb2),
WTCP(0x7ffc726f, 0x01e287fc), WTCP(0x7ffab147, 0x024dbff4),
WTCP(0x7ff8964d, 0x02b8f64e), WTCP(0x7ff62182, 0x03242abf),
WTCP(0x7ff352e8, 0x038f5cfb), WTCP(0x7ff02a82, 0x03fa8cb8),
WTCP(0x7feca851, 0x0465b9aa), WTCP(0x7fe8cc57, 0x04d0e386),
WTCP(0x7fe49698, 0x053c0a01), WTCP(0x7fe00716, 0x05a72ccf),
WTCP(0x7fdb1dd5, 0x06124ba5), WTCP(0x7fd5dad8, 0x067d6639),
WTCP(0x7fd03e23, 0x06e87c3f), WTCP(0x7fca47b9, 0x07538d6b),
WTCP(0x7fc3f7a0, 0x07be9973), WTCP(0x7fbd4dda, 0x0829a00c),
WTCP(0x7fb64a6e, 0x0894a0ea), WTCP(0x7faeed5f, 0x08ff9bc2),
WTCP(0x7fa736b4, 0x096a9049), WTCP(0x7f9f2671, 0x09d57e35),
WTCP(0x7f96bc9c, 0x0a40653a), WTCP(0x7f8df93c, 0x0aab450d),
WTCP(0x7f84dc55, 0x0b161d63), WTCP(0x7f7b65ef, 0x0b80edf1),
WTCP(0x7f719611, 0x0bebb66c), WTCP(0x7f676cc0, 0x0c56768a),
WTCP(0x7f5cea05, 0x0cc12dff), WTCP(0x7f520de6, 0x0d2bdc80),
WTCP(0x7f46d86c, 0x0d9681c2), WTCP(0x7f3b499d, 0x0e011d7c),
WTCP(0x7f2f6183, 0x0e6baf61), WTCP(0x7f232026, 0x0ed63727),
WTCP(0x7f16858e, 0x0f40b483), WTCP(0x7f0991c4, 0x0fab272b),
WTCP(0x7efc44d0, 0x10158ed4), WTCP(0x7eee9ebe, 0x107feb33),
WTCP(0x7ee09f95, 0x10ea3bfd), WTCP(0x7ed24761, 0x115480e9),
WTCP(0x7ec3962a, 0x11beb9aa), WTCP(0x7eb48bfb, 0x1228e5f8),
WTCP(0x7ea528e0, 0x12930586), WTCP(0x7e956ce1, 0x12fd180b),
WTCP(0x7e85580c, 0x13671d3d), WTCP(0x7e74ea6a, 0x13d114d0),
WTCP(0x7e642408, 0x143afe7b), WTCP(0x7e5304f2, 0x14a4d9f4),
WTCP(0x7e418d32, 0x150ea6ef), WTCP(0x7e2fbcd6, 0x15786522),
WTCP(0x7e1d93ea, 0x15e21445), WTCP(0x7e0b127a, 0x164bb40b),
WTCP(0x7df83895, 0x16b5442b), WTCP(0x7de50646, 0x171ec45c),
WTCP(0x7dd17b9c, 0x17883452), WTCP(0x7dbd98a4, 0x17f193c5),
WTCP(0x7da95d6c, 0x185ae269), WTCP(0x7d94ca03, 0x18c41ff6),
WTCP(0x7d7fde76, 0x192d4c21), WTCP(0x7d6a9ad5, 0x199666a0),
WTCP(0x7d54ff2e, 0x19ff6f2a), WTCP(0x7d3f0b90, 0x1a686575),
WTCP(0x7d28c00c, 0x1ad14938), WTCP(0x7d121cb0, 0x1b3a1a28),
WTCP(0x7cfb218c, 0x1ba2d7fc), WTCP(0x7ce3ceb2, 0x1c0b826a),
WTCP(0x7ccc2430, 0x1c74192a), WTCP(0x7cb42217, 0x1cdc9bf2),
WTCP(0x7c9bc87a, 0x1d450a78), WTCP(0x7c831767, 0x1dad6473),
WTCP(0x7c6a0ef2, 0x1e15a99a), WTCP(0x7c50af2b, 0x1e7dd9a4),
WTCP(0x7c36f824, 0x1ee5f447), WTCP(0x7c1ce9ef, 0x1f4df93a),
WTCP(0x7c02849f, 0x1fb5e836), WTCP(0x7be7c847, 0x201dc0ef),
WTCP(0x7bccb4f8, 0x2085831f), WTCP(0x7bb14ac5, 0x20ed2e7b),
WTCP(0x7b9589c3, 0x2154c2bb), WTCP(0x7b797205, 0x21bc3f97),
WTCP(0x7b5d039e, 0x2223a4c5), WTCP(0x7b403ea2, 0x228af1fe),
WTCP(0x7b232325, 0x22f226f8), WTCP(0x7b05b13d, 0x2359436c),
WTCP(0x7ae7e8fc, 0x23c04710), WTCP(0x7ac9ca7a, 0x2427319d),
WTCP(0x7aab55ca, 0x248e02cb), WTCP(0x7a8c8b01, 0x24f4ba50),
WTCP(0x7a6d6a37, 0x255b57e6), WTCP(0x7a4df380, 0x25c1db44),
WTCP(0x7a2e26f2, 0x26284422), WTCP(0x7a0e04a4, 0x268e9238),
WTCP(0x79ed8cad, 0x26f4c53e), WTCP(0x79ccbf22, 0x275adcee),
WTCP(0x79ab9c1c, 0x27c0d8fe), WTCP(0x798a23b1, 0x2826b928),
WTCP(0x796855f9, 0x288c7d24), WTCP(0x7946330c, 0x28f224ab),
WTCP(0x7923bb01, 0x2957af74), WTCP(0x7900edf2, 0x29bd1d3a),
WTCP(0x78ddcbf5, 0x2a226db5), WTCP(0x78ba5524, 0x2a87a09d),
WTCP(0x78968998, 0x2aecb5ac), WTCP(0x7872696a, 0x2b51ac9a),
WTCP(0x784df4b3, 0x2bb68522), WTCP(0x78292b8d, 0x2c1b3efb),
WTCP(0x78040e12, 0x2c7fd9e0), WTCP(0x77de9c5b, 0x2ce45589),
WTCP(0x77b8d683, 0x2d48b1b1), WTCP(0x7792bca5, 0x2dacee11),
WTCP(0x776c4edb, 0x2e110a62), WTCP(0x77458d40, 0x2e75065e),
WTCP(0x771e77f0, 0x2ed8e1c0), WTCP(0x76f70f05, 0x2f3c9c40),
WTCP(0x76cf529c, 0x2fa03599), WTCP(0x76a742d1, 0x3003ad85),
WTCP(0x767edfbe, 0x306703bf), WTCP(0x76562982, 0x30ca3800),
WTCP(0x762d2038, 0x312d4a03), WTCP(0x7603c3fd, 0x31903982),
WTCP(0x75da14ef, 0x31f30638), WTCP(0x75b01329, 0x3255afe0),
WTCP(0x7585becb, 0x32b83634), WTCP(0x755b17f2, 0x331a98ef),
WTCP(0x75301ebb, 0x337cd7cd), WTCP(0x7504d345, 0x33def287),
WTCP(0x74d935ae, 0x3440e8da), WTCP(0x74ad4615, 0x34a2ba81),
WTCP(0x74810499, 0x35046736), WTCP(0x74547158, 0x3565eeb6),
WTCP(0x74278c72, 0x35c750bc), WTCP(0x73fa5607, 0x36288d03),
WTCP(0x73ccce36, 0x3689a348), WTCP(0x739ef51f, 0x36ea9346),
WTCP(0x7370cae2, 0x374b5cb9), WTCP(0x73424fa0, 0x37abff5d),
WTCP(0x73138379, 0x380c7aee), WTCP(0x72e4668f, 0x386ccf2a),
WTCP(0x72b4f902, 0x38ccfbcb), WTCP(0x72853af3, 0x392d008f),
WTCP(0x72552c85, 0x398cdd32), WTCP(0x7224cdd8, 0x39ec9172),
WTCP(0x71f41f0f, 0x3a4c1d09), WTCP(0x71c3204c, 0x3aab7fb7),
WTCP(0x7191d1b1, 0x3b0ab937), WTCP(0x71603361, 0x3b69c947),
WTCP(0x712e457f, 0x3bc8afa5), WTCP(0x70fc082d, 0x3c276c0d),
WTCP(0x70c97b90, 0x3c85fe3d), WTCP(0x70969fca, 0x3ce465f3),
WTCP(0x706374ff, 0x3d42a2ec), WTCP(0x702ffb54, 0x3da0b4e7),
WTCP(0x6ffc32eb, 0x3dfe9ba1), WTCP(0x6fc81bea, 0x3e5c56d8),
WTCP(0x6f93b676, 0x3eb9e64b), WTCP(0x6f5f02b2, 0x3f1749b8),
WTCP(0x6f2a00c4, 0x3f7480dd), WTCP(0x6ef4b0d1, 0x3fd18b7a),
WTCP(0x6ebf12ff, 0x402e694c), WTCP(0x6e892772, 0x408b1a12),
WTCP(0x6e52ee52, 0x40e79d8c), WTCP(0x6e1c67c4, 0x4143f379),
WTCP(0x6de593ee, 0x41a01b97), WTCP(0x6dae72f7, 0x41fc15a6),
WTCP(0x6d770506, 0x4257e166), WTCP(0x6d3f4a40, 0x42b37e96),
WTCP(0x6d0742cf, 0x430eecf6), WTCP(0x6cceeed8, 0x436a2c45),
WTCP(0x6c964e83, 0x43c53c44), WTCP(0x6c5d61f9, 0x44201cb2),
WTCP(0x6c242960, 0x447acd50), WTCP(0x6beaa4e2, 0x44d54ddf),
WTCP(0x6bb0d4a7, 0x452f9e1e), WTCP(0x6b76b8d6, 0x4589bdcf),
WTCP(0x6b3c519a, 0x45e3acb1), WTCP(0x6b019f1a, 0x463d6a87),
WTCP(0x6ac6a180, 0x4696f710), WTCP(0x6a8b58f6, 0x46f0520f),
WTCP(0x6a4fc5a6, 0x47497b44), WTCP(0x6a13e7b8, 0x47a27271),
WTCP(0x69d7bf57, 0x47fb3757), WTCP(0x699b4cad, 0x4853c9b9),
WTCP(0x695e8fe5, 0x48ac2957), WTCP(0x69218929, 0x490455f4),
WTCP(0x68e438a4, 0x495c4f52), WTCP(0x68a69e81, 0x49b41533),
WTCP(0x6868baec, 0x4a0ba75b), WTCP(0x682a8e0f, 0x4a63058a),
WTCP(0x67ec1817, 0x4aba2f84), WTCP(0x67ad592f, 0x4b11250c),
WTCP(0x676e5183, 0x4b67e5e4), WTCP(0x672f013f, 0x4bbe71d1),
WTCP(0x66ef6891, 0x4c14c894), WTCP(0x66af87a4, 0x4c6ae9f2),
WTCP(0x666f5ea6, 0x4cc0d5ae), WTCP(0x662eedc3, 0x4d168b8b),
WTCP(0x65ee3529, 0x4d6c0b4e), WTCP(0x65ad3505, 0x4dc154bb),
WTCP(0x656bed84, 0x4e166795), WTCP(0x652a5ed6, 0x4e6b43a2),
WTCP(0x64e88926, 0x4ebfe8a5), WTCP(0x64a66ca5, 0x4f145662),
WTCP(0x6464097f, 0x4f688ca0), WTCP(0x64215fe5, 0x4fbc8b22),
WTCP(0x63de7003, 0x501051ae), WTCP(0x639b3a0b, 0x5063e008),
WTCP(0x6357be2a, 0x50b735f8), WTCP(0x6313fc90, 0x510a5340),
WTCP(0x62cff56c, 0x515d37a9), WTCP(0x628ba8ef, 0x51afe2f6),
WTCP(0x62471749, 0x520254ef), WTCP(0x620240a8, 0x52548d59),
WTCP(0x61bd253f, 0x52a68bfb), WTCP(0x6177c53c, 0x52f8509b),
WTCP(0x613220d2, 0x5349daff), WTCP(0x60ec3830, 0x539b2af0),
WTCP(0x60a60b88, 0x53ec4032), WTCP(0x605f9b0b, 0x543d1a8e),
WTCP(0x6018e6eb, 0x548db9cb), WTCP(0x5fd1ef59, 0x54de1db1),
WTCP(0x5f8ab487, 0x552e4605), WTCP(0x5f4336a7, 0x557e3292),
WTCP(0x5efb75ea, 0x55cde31e), WTCP(0x5eb37285, 0x561d5771),
WTCP(0x5e6b2ca8, 0x566c8f55), WTCP(0x5e22a487, 0x56bb8a90),
WTCP(0x5dd9da55, 0x570a48ec), WTCP(0x5d90ce45, 0x5758ca31),
WTCP(0x5d47808a, 0x57a70e29), WTCP(0x5cfdf157, 0x57f5149d),
WTCP(0x5cb420e0, 0x5842dd54), WTCP(0x5c6a0f59, 0x5890681a),
WTCP(0x5c1fbcf6, 0x58ddb4b8), WTCP(0x5bd529eb, 0x592ac2f7),
WTCP(0x5b8a566c, 0x597792a1), WTCP(0x5b3f42ae, 0x59c42381),
WTCP(0x5af3eee6, 0x5a107561), WTCP(0x5aa85b48, 0x5a5c880a),
};
RAM_ALIGN
LNK_SECTION_CONSTDATA
const FIXP_WTP SineWindow512[] = {
WTCP(0x7ffff621, 0x003243f5), WTCP(0x7fffa72c, 0x0096cbc1),
WTCP(0x7fff0943, 0x00fb5330), WTCP(0x7ffe1c65, 0x015fda03),
WTCP(0x7ffce093, 0x01c45ffe), WTCP(0x7ffb55ce, 0x0228e4e2),
WTCP(0x7ff97c18, 0x028d6870), WTCP(0x7ff75370, 0x02f1ea6c),
WTCP(0x7ff4dbd9, 0x03566a96), WTCP(0x7ff21553, 0x03bae8b2),
WTCP(0x7feeffe1, 0x041f6480), WTCP(0x7feb9b85, 0x0483ddc3),
WTCP(0x7fe7e841, 0x04e8543e), WTCP(0x7fe3e616, 0x054cc7b1),
WTCP(0x7fdf9508, 0x05b137df), WTCP(0x7fdaf519, 0x0615a48b),
WTCP(0x7fd6064c, 0x067a0d76), WTCP(0x7fd0c8a3, 0x06de7262),
WTCP(0x7fcb3c23, 0x0742d311), WTCP(0x7fc560cf, 0x07a72f45),
WTCP(0x7fbf36aa, 0x080b86c2), WTCP(0x7fb8bdb8, 0x086fd947),
WTCP(0x7fb1f5fc, 0x08d42699), WTCP(0x7faadf7c, 0x09386e78),
WTCP(0x7fa37a3c, 0x099cb0a7), WTCP(0x7f9bc640, 0x0a00ece8),
WTCP(0x7f93c38c, 0x0a6522fe), WTCP(0x7f8b7227, 0x0ac952aa),
WTCP(0x7f82d214, 0x0b2d7baf), WTCP(0x7f79e35a, 0x0b919dcf),
WTCP(0x7f70a5fe, 0x0bf5b8cb), WTCP(0x7f671a05, 0x0c59cc68),
WTCP(0x7f5d3f75, 0x0cbdd865), WTCP(0x7f531655, 0x0d21dc87),
WTCP(0x7f489eaa, 0x0d85d88f), WTCP(0x7f3dd87c, 0x0de9cc40),
WTCP(0x7f32c3d1, 0x0e4db75b), WTCP(0x7f2760af, 0x0eb199a4),
WTCP(0x7f1baf1e, 0x0f1572dc), WTCP(0x7f0faf25, 0x0f7942c7),
WTCP(0x7f0360cb, 0x0fdd0926), WTCP(0x7ef6c418, 0x1040c5bb),
WTCP(0x7ee9d914, 0x10a4784b), WTCP(0x7edc9fc6, 0x11082096),
WTCP(0x7ecf1837, 0x116bbe60), WTCP(0x7ec14270, 0x11cf516a),
WTCP(0x7eb31e78, 0x1232d979), WTCP(0x7ea4ac58, 0x1296564d),
WTCP(0x7e95ec1a, 0x12f9c7aa), WTCP(0x7e86ddc6, 0x135d2d53),
WTCP(0x7e778166, 0x13c0870a), WTCP(0x7e67d703, 0x1423d492),
WTCP(0x7e57dea7, 0x148715ae), WTCP(0x7e47985b, 0x14ea4a1f),
WTCP(0x7e37042a, 0x154d71aa), WTCP(0x7e26221f, 0x15b08c12),
WTCP(0x7e14f242, 0x16139918), WTCP(0x7e0374a0, 0x1676987f),
WTCP(0x7df1a942, 0x16d98a0c), WTCP(0x7ddf9034, 0x173c6d80),
WTCP(0x7dcd2981, 0x179f429f), WTCP(0x7dba7534, 0x1802092c),
WTCP(0x7da77359, 0x1864c0ea), WTCP(0x7d9423fc, 0x18c7699b),
WTCP(0x7d808728, 0x192a0304), WTCP(0x7d6c9ce9, 0x198c8ce7),
WTCP(0x7d58654d, 0x19ef0707), WTCP(0x7d43e05e, 0x1a517128),
WTCP(0x7d2f0e2b, 0x1ab3cb0d), WTCP(0x7d19eebf, 0x1b161479),
WTCP(0x7d048228, 0x1b784d30), WTCP(0x7ceec873, 0x1bda74f6),
WTCP(0x7cd8c1ae, 0x1c3c8b8c), WTCP(0x7cc26de5, 0x1c9e90b8),
WTCP(0x7cabcd28, 0x1d00843d), WTCP(0x7c94df83, 0x1d6265dd),
WTCP(0x7c7da505, 0x1dc4355e), WTCP(0x7c661dbc, 0x1e25f282),
WTCP(0x7c4e49b7, 0x1e879d0d), WTCP(0x7c362904, 0x1ee934c3),
WTCP(0x7c1dbbb3, 0x1f4ab968), WTCP(0x7c0501d2, 0x1fac2abf),
WTCP(0x7bebfb70, 0x200d888d), WTCP(0x7bd2a89e, 0x206ed295),
WTCP(0x7bb9096b, 0x20d0089c), WTCP(0x7b9f1de6, 0x21312a65),
WTCP(0x7b84e61f, 0x219237b5), WTCP(0x7b6a6227, 0x21f3304f),
WTCP(0x7b4f920e, 0x225413f8), WTCP(0x7b3475e5, 0x22b4e274),
WTCP(0x7b190dbc, 0x23159b88), WTCP(0x7afd59a4, 0x23763ef7),
WTCP(0x7ae159ae, 0x23d6cc87), WTCP(0x7ac50dec, 0x243743fa),
WTCP(0x7aa8766f, 0x2497a517), WTCP(0x7a8b9348, 0x24f7efa2),
WTCP(0x7a6e648a, 0x2558235f), WTCP(0x7a50ea47, 0x25b84012),
WTCP(0x7a332490, 0x26184581), WTCP(0x7a151378, 0x26783370),
WTCP(0x79f6b711, 0x26d809a5), WTCP(0x79d80f6f, 0x2737c7e3),
WTCP(0x79b91ca4, 0x27976df1), WTCP(0x7999dec4, 0x27f6fb92),
WTCP(0x797a55e0, 0x2856708d), WTCP(0x795a820e, 0x28b5cca5),
WTCP(0x793a6361, 0x29150fa1), WTCP(0x7919f9ec, 0x29743946),
WTCP(0x78f945c3, 0x29d34958), WTCP(0x78d846fb, 0x2a323f9e),
WTCP(0x78b6fda8, 0x2a911bdc), WTCP(0x789569df, 0x2aefddd8),
WTCP(0x78738bb3, 0x2b4e8558), WTCP(0x7851633b, 0x2bad1221),
WTCP(0x782ef08b, 0x2c0b83fa), WTCP(0x780c33b8, 0x2c69daa6),
WTCP(0x77e92cd9, 0x2cc815ee), WTCP(0x77c5dc01, 0x2d263596),
WTCP(0x77a24148, 0x2d843964), WTCP(0x777e5cc3, 0x2de2211e),
WTCP(0x775a2e89, 0x2e3fec8b), WTCP(0x7735b6af, 0x2e9d9b70),
WTCP(0x7710f54c, 0x2efb2d95), WTCP(0x76ebea77, 0x2f58a2be),
WTCP(0x76c69647, 0x2fb5fab2), WTCP(0x76a0f8d2, 0x30133539),
WTCP(0x767b1231, 0x30705217), WTCP(0x7654e279, 0x30cd5115),
WTCP(0x762e69c4, 0x312a31f8), WTCP(0x7607a828, 0x3186f487),
WTCP(0x75e09dbd, 0x31e39889), WTCP(0x75b94a9c, 0x32401dc6),
WTCP(0x7591aedd, 0x329c8402), WTCP(0x7569ca99, 0x32f8cb07),
WTCP(0x75419de7, 0x3354f29b), WTCP(0x751928e0, 0x33b0fa84),
WTCP(0x74f06b9e, 0x340ce28b), WTCP(0x74c7663a, 0x3468aa76),
WTCP(0x749e18cd, 0x34c4520d), WTCP(0x74748371, 0x351fd918),
WTCP(0x744aa63f, 0x357b3f5d), WTCP(0x74208150, 0x35d684a6),
WTCP(0x73f614c0, 0x3631a8b8), WTCP(0x73cb60a8, 0x368cab5c),
WTCP(0x73a06522, 0x36e78c5b), WTCP(0x73752249, 0x37424b7b),
WTCP(0x73499838, 0x379ce885), WTCP(0x731dc70a, 0x37f76341),
WTCP(0x72f1aed9, 0x3851bb77), WTCP(0x72c54fc1, 0x38abf0ef),
WTCP(0x7298a9dd, 0x39060373), WTCP(0x726bbd48, 0x395ff2c9),
WTCP(0x723e8a20, 0x39b9bebc), WTCP(0x7211107e, 0x3a136712),
WTCP(0x71e35080, 0x3a6ceb96), WTCP(0x71b54a41, 0x3ac64c0f),
WTCP(0x7186fdde, 0x3b1f8848), WTCP(0x71586b74, 0x3b78a007),
WTCP(0x7129931f, 0x3bd19318), WTCP(0x70fa74fc, 0x3c2a6142),
WTCP(0x70cb1128, 0x3c830a50), WTCP(0x709b67c0, 0x3cdb8e09),
WTCP(0x706b78e3, 0x3d33ec39), WTCP(0x703b44ad, 0x3d8c24a8),
WTCP(0x700acb3c, 0x3de4371f), WTCP(0x6fda0cae, 0x3e3c2369),
WTCP(0x6fa90921, 0x3e93e950), WTCP(0x6f77c0b3, 0x3eeb889c),
WTCP(0x6f463383, 0x3f430119), WTCP(0x6f1461b0, 0x3f9a5290),
WTCP(0x6ee24b57, 0x3ff17cca), WTCP(0x6eaff099, 0x40487f94),
WTCP(0x6e7d5193, 0x409f5ab6), WTCP(0x6e4a6e66, 0x40f60dfb),
WTCP(0x6e174730, 0x414c992f), WTCP(0x6de3dc11, 0x41a2fc1a),
WTCP(0x6db02d29, 0x41f93689), WTCP(0x6d7c3a98, 0x424f4845),
WTCP(0x6d48047e, 0x42a5311b), WTCP(0x6d138afb, 0x42faf0d4),
WTCP(0x6cdece2f, 0x4350873c), WTCP(0x6ca9ce3b, 0x43a5f41e),
WTCP(0x6c748b3f, 0x43fb3746), WTCP(0x6c3f055d, 0x4450507e),
WTCP(0x6c093cb6, 0x44a53f93), WTCP(0x6bd3316a, 0x44fa0450),
WTCP(0x6b9ce39b, 0x454e9e80), WTCP(0x6b66536b, 0x45a30df0),
WTCP(0x6b2f80fb, 0x45f7526b), WTCP(0x6af86c6c, 0x464b6bbe),
WTCP(0x6ac115e2, 0x469f59b4), WTCP(0x6a897d7d, 0x46f31c1a),
WTCP(0x6a51a361, 0x4746b2bc), WTCP(0x6a1987b0, 0x479a1d67),
WTCP(0x69e12a8c, 0x47ed5be6), WTCP(0x69a88c19, 0x48406e08),
WTCP(0x696fac78, 0x48935397), WTCP(0x69368bce, 0x48e60c62),
WTCP(0x68fd2a3d, 0x49389836), WTCP(0x68c387e9, 0x498af6df),
WTCP(0x6889a4f6, 0x49dd282a), WTCP(0x684f8186, 0x4a2f2be6),
WTCP(0x68151dbe, 0x4a8101de), WTCP(0x67da79c3, 0x4ad2a9e2),
WTCP(0x679f95b7, 0x4b2423be), WTCP(0x676471c0, 0x4b756f40),
WTCP(0x67290e02, 0x4bc68c36), WTCP(0x66ed6aa1, 0x4c177a6e),
WTCP(0x66b187c3, 0x4c6839b7), WTCP(0x6675658c, 0x4cb8c9dd),
WTCP(0x66390422, 0x4d092ab0), WTCP(0x65fc63a9, 0x4d595bfe),
WTCP(0x65bf8447, 0x4da95d96), WTCP(0x65826622, 0x4df92f46),
WTCP(0x6545095f, 0x4e48d0dd), WTCP(0x65076e25, 0x4e984229),
WTCP(0x64c99498, 0x4ee782fb), WTCP(0x648b7ce0, 0x4f369320),
WTCP(0x644d2722, 0x4f857269), WTCP(0x640e9386, 0x4fd420a4),
WTCP(0x63cfc231, 0x50229da1), WTCP(0x6390b34a, 0x5070e92f),
WTCP(0x635166f9, 0x50bf031f), WTCP(0x6311dd64, 0x510ceb40),
WTCP(0x62d216b3, 0x515aa162), WTCP(0x6292130c, 0x51a82555),
WTCP(0x6251d298, 0x51f576ea), WTCP(0x6211557e, 0x524295f0),
WTCP(0x61d09be5, 0x528f8238), WTCP(0x618fa5f7, 0x52dc3b92),
WTCP(0x614e73da, 0x5328c1d0), WTCP(0x610d05b7, 0x537514c2),
WTCP(0x60cb5bb7, 0x53c13439), WTCP(0x60897601, 0x540d2005),
WTCP(0x604754bf, 0x5458d7f9), WTCP(0x6004f819, 0x54a45be6),
WTCP(0x5fc26038, 0x54efab9c), WTCP(0x5f7f8d46, 0x553ac6ee),
WTCP(0x5f3c7f6b, 0x5585adad), WTCP(0x5ef936d1, 0x55d05faa),
WTCP(0x5eb5b3a2, 0x561adcb9), WTCP(0x5e71f606, 0x566524aa),
WTCP(0x5e2dfe29, 0x56af3750), WTCP(0x5de9cc33, 0x56f9147e),
WTCP(0x5da5604f, 0x5742bc06), WTCP(0x5d60baa7, 0x578c2dba),
WTCP(0x5d1bdb65, 0x57d5696d), WTCP(0x5cd6c2b5, 0x581e6ef1),
WTCP(0x5c9170bf, 0x58673e1b), WTCP(0x5c4be5b0, 0x58afd6bd),
WTCP(0x5c0621b2, 0x58f838a9), WTCP(0x5bc024f0, 0x594063b5),
WTCP(0x5b79ef96, 0x598857b2), WTCP(0x5b3381ce, 0x59d01475),
WTCP(0x5aecdbc5, 0x5a1799d1), WTCP(0x5aa5fda5, 0x5a5ee79a),
};
RAM_ALIGN
LNK_SECTION_CONSTDATA
const FIXP_WTP SineWindow768[] = {
WTCP(0x7ffffb9d, 0x002182a4), WTCP(0x7fffd886, 0x006487e3),
WTCP(0x7fff9257, 0x00a78d06), WTCP(0x7fff2910, 0x00ea91fc),
WTCP(0x7ffe9cb2, 0x012d96b1), WTCP(0x7ffded3d, 0x01709b13),
WTCP(0x7ffd1ab2, 0x01b39f11), WTCP(0x7ffc250f, 0x01f6a297),
WTCP(0x7ffb0c56, 0x0239a593), WTCP(0x7ff9d087, 0x027ca7f3),
WTCP(0x7ff871a2, 0x02bfa9a4), WTCP(0x7ff6efa7, 0x0302aa95),
WTCP(0x7ff54a98, 0x0345aab2), WTCP(0x7ff38274, 0x0388a9ea),
WTCP(0x7ff1973b, 0x03cba829), WTCP(0x7fef88ef, 0x040ea55e),
WTCP(0x7fed5791, 0x0451a177), WTCP(0x7feb031f, 0x04949c60),
WTCP(0x7fe88b9c, 0x04d79608), WTCP(0x7fe5f108, 0x051a8e5c),
WTCP(0x7fe33364, 0x055d854a), WTCP(0x7fe052af, 0x05a07abf),
WTCP(0x7fdd4eec, 0x05e36ea9), WTCP(0x7fda281b, 0x062660f6),
WTCP(0x7fd6de3d, 0x06695194), WTCP(0x7fd37153, 0x06ac406f),
WTCP(0x7fcfe15d, 0x06ef2d76), WTCP(0x7fcc2e5d, 0x07321897),
WTCP(0x7fc85854, 0x077501be), WTCP(0x7fc45f42, 0x07b7e8da),
WTCP(0x7fc04329, 0x07facdd9), WTCP(0x7fbc040a, 0x083db0a7),
WTCP(0x7fb7a1e6, 0x08809133), WTCP(0x7fb31cbf, 0x08c36f6a),
WTCP(0x7fae7495, 0x09064b3a), WTCP(0x7fa9a96a, 0x09492491),
WTCP(0x7fa4bb3f, 0x098bfb5c), WTCP(0x7f9faa15, 0x09cecf89),
WTCP(0x7f9a75ef, 0x0a11a106), WTCP(0x7f951ecc, 0x0a546fc0),
WTCP(0x7f8fa4b0, 0x0a973ba5), WTCP(0x7f8a079a, 0x0ada04a3),
WTCP(0x7f84478e, 0x0b1ccaa7), WTCP(0x7f7e648c, 0x0b5f8d9f),
WTCP(0x7f785e96, 0x0ba24d79), WTCP(0x7f7235ad, 0x0be50a23),
WTCP(0x7f6be9d4, 0x0c27c389), WTCP(0x7f657b0c, 0x0c6a799b),
WTCP(0x7f5ee957, 0x0cad2c45), WTCP(0x7f5834b7, 0x0cefdb76),
WTCP(0x7f515d2d, 0x0d32871a), WTCP(0x7f4a62bb, 0x0d752f20),
WTCP(0x7f434563, 0x0db7d376), WTCP(0x7f3c0528, 0x0dfa7409),
WTCP(0x7f34a20b, 0x0e3d10c7), WTCP(0x7f2d1c0e, 0x0e7fa99e),
WTCP(0x7f257334, 0x0ec23e7b), WTCP(0x7f1da77e, 0x0f04cf4c),
WTCP(0x7f15b8ee, 0x0f475bff), WTCP(0x7f0da787, 0x0f89e482),
WTCP(0x7f05734b, 0x0fcc68c2), WTCP(0x7efd1c3c, 0x100ee8ad),
WTCP(0x7ef4a25d, 0x10516432), WTCP(0x7eec05af, 0x1093db3d),
WTCP(0x7ee34636, 0x10d64dbd), WTCP(0x7eda63f3, 0x1118bb9f),
WTCP(0x7ed15ee9, 0x115b24d1), WTCP(0x7ec8371a, 0x119d8941),
WTCP(0x7ebeec89, 0x11dfe8dc), WTCP(0x7eb57f39, 0x12224392),
WTCP(0x7eabef2c, 0x1264994e), WTCP(0x7ea23c65, 0x12a6ea00),
WTCP(0x7e9866e6, 0x12e93594), WTCP(0x7e8e6eb2, 0x132b7bf9),
WTCP(0x7e8453cc, 0x136dbd1d), WTCP(0x7e7a1636, 0x13aff8ed),
WTCP(0x7e6fb5f4, 0x13f22f58), WTCP(0x7e653308, 0x1434604a),
WTCP(0x7e5a8d75, 0x14768bb3), WTCP(0x7e4fc53e, 0x14b8b17f),
WTCP(0x7e44da66, 0x14fad19e), WTCP(0x7e39ccf0, 0x153cebfb),
WTCP(0x7e2e9cdf, 0x157f0086), WTCP(0x7e234a36, 0x15c10f2d),
WTCP(0x7e17d4f8, 0x160317dc), WTCP(0x7e0c3d29, 0x16451a83),
WTCP(0x7e0082cb, 0x1687170f), WTCP(0x7df4a5e2, 0x16c90d6e),
WTCP(0x7de8a670, 0x170afd8d), WTCP(0x7ddc847a, 0x174ce75b),
WTCP(0x7dd04003, 0x178ecac6), WTCP(0x7dc3d90d, 0x17d0a7bc),
WTCP(0x7db74f9d, 0x18127e2a), WTCP(0x7daaa3b5, 0x18544dff),
WTCP(0x7d9dd55a, 0x18961728), WTCP(0x7d90e48f, 0x18d7d993),
WTCP(0x7d83d156, 0x1919952f), WTCP(0x7d769bb5, 0x195b49ea),
WTCP(0x7d6943ae, 0x199cf7b0), WTCP(0x7d5bc946, 0x19de9e72),
WTCP(0x7d4e2c7f, 0x1a203e1b), WTCP(0x7d406d5e, 0x1a61d69b),
WTCP(0x7d328be6, 0x1aa367df), WTCP(0x7d24881b, 0x1ae4f1d6),
WTCP(0x7d166201, 0x1b26746d), WTCP(0x7d08199c, 0x1b67ef93),
WTCP(0x7cf9aef0, 0x1ba96335), WTCP(0x7ceb2201, 0x1beacf42),
WTCP(0x7cdc72d3, 0x1c2c33a7), WTCP(0x7ccda169, 0x1c6d9053),
WTCP(0x7cbeadc8, 0x1caee534), WTCP(0x7caf97f4, 0x1cf03238),
WTCP(0x7ca05ff1, 0x1d31774d), WTCP(0x7c9105c3, 0x1d72b461),
WTCP(0x7c81896f, 0x1db3e962), WTCP(0x7c71eaf9, 0x1df5163f),
WTCP(0x7c622a64, 0x1e363ae5), WTCP(0x7c5247b6, 0x1e775743),
WTCP(0x7c4242f2, 0x1eb86b46), WTCP(0x7c321c1e, 0x1ef976de),
WTCP(0x7c21d33c, 0x1f3a79f7), WTCP(0x7c116853, 0x1f7b7481),
WTCP(0x7c00db66, 0x1fbc6669), WTCP(0x7bf02c7b, 0x1ffd4f9e),
WTCP(0x7bdf5b94, 0x203e300d), WTCP(0x7bce68b8, 0x207f07a6),
WTCP(0x7bbd53eb, 0x20bfd656), WTCP(0x7bac1d31, 0x21009c0c),
WTCP(0x7b9ac490, 0x214158b5), WTCP(0x7b894a0b, 0x21820c41),
WTCP(0x7b77ada8, 0x21c2b69c), WTCP(0x7b65ef6c, 0x220357b6),
WTCP(0x7b540f5b, 0x2243ef7d), WTCP(0x7b420d7a, 0x22847de0),
WTCP(0x7b2fe9cf, 0x22c502cb), WTCP(0x7b1da45e, 0x23057e2e),
WTCP(0x7b0b3d2c, 0x2345eff8), WTCP(0x7af8b43f, 0x23865816),
WTCP(0x7ae6099b, 0x23c6b676), WTCP(0x7ad33d45, 0x24070b08),
WTCP(0x7ac04f44, 0x244755b9), WTCP(0x7aad3f9b, 0x24879678),
WTCP(0x7a9a0e50, 0x24c7cd33), WTCP(0x7a86bb68, 0x2507f9d8),
WTCP(0x7a7346e9, 0x25481c57), WTCP(0x7a5fb0d8, 0x2588349d),
WTCP(0x7a4bf93a, 0x25c84299), WTCP(0x7a382015, 0x26084639),
WTCP(0x7a24256f, 0x26483f6c), WTCP(0x7a10094c, 0x26882e21),
WTCP(0x79fbcbb2, 0x26c81245), WTCP(0x79e76ca7, 0x2707ebc7),
WTCP(0x79d2ec30, 0x2747ba95), WTCP(0x79be4a53, 0x27877e9f),
WTCP(0x79a98715, 0x27c737d3), WTCP(0x7994a27d, 0x2806e61f),
WTCP(0x797f9c90, 0x28468971), WTCP(0x796a7554, 0x288621b9),
WTCP(0x79552cce, 0x28c5aee5), WTCP(0x793fc305, 0x290530e3),
WTCP(0x792a37fe, 0x2944a7a2), WTCP(0x79148bbf, 0x29841311),
WTCP(0x78febe4e, 0x29c3731e), WTCP(0x78e8cfb2, 0x2a02c7b8),
WTCP(0x78d2bfef, 0x2a4210ce), WTCP(0x78bc8f0d, 0x2a814e4d),
WTCP(0x78a63d11, 0x2ac08026), WTCP(0x788fca01, 0x2affa646),
WTCP(0x787935e4, 0x2b3ec09c), WTCP(0x786280bf, 0x2b7dcf17),
WTCP(0x784baa9a, 0x2bbcd1a6), WTCP(0x7834b37a, 0x2bfbc837),
WTCP(0x781d9b65, 0x2c3ab2b9), WTCP(0x78066262, 0x2c79911b),
WTCP(0x77ef0877, 0x2cb8634b), WTCP(0x77d78daa, 0x2cf72939),
WTCP(0x77bff203, 0x2d35e2d3), WTCP(0x77a83587, 0x2d749008),
WTCP(0x7790583e, 0x2db330c7), WTCP(0x77785a2d, 0x2df1c4fe),
WTCP(0x77603b5a, 0x2e304c9d), WTCP(0x7747fbce, 0x2e6ec792),
WTCP(0x772f9b8e, 0x2ead35cd), WTCP(0x77171aa1, 0x2eeb973b),
WTCP(0x76fe790e, 0x2f29ebcc), WTCP(0x76e5b6dc, 0x2f68336f),
WTCP(0x76ccd411, 0x2fa66e13), WTCP(0x76b3d0b4, 0x2fe49ba7),
WTCP(0x769aaccc, 0x3022bc19), WTCP(0x7681685f, 0x3060cf59),
WTCP(0x76680376, 0x309ed556), WTCP(0x764e7e17, 0x30dccdfe),
WTCP(0x7634d848, 0x311ab941), WTCP(0x761b1211, 0x3158970e),
WTCP(0x76012b79, 0x31966753), WTCP(0x75e72487, 0x31d42a00),
WTCP(0x75ccfd42, 0x3211df04), WTCP(0x75b2b5b2, 0x324f864e),
WTCP(0x75984ddc, 0x328d1fcc), WTCP(0x757dc5ca, 0x32caab6f),
WTCP(0x75631d82, 0x33082925), WTCP(0x7548550b, 0x334598de),
WTCP(0x752d6c6c, 0x3382fa88), WTCP(0x751263ae, 0x33c04e13),
WTCP(0x74f73ad7, 0x33fd936e), WTCP(0x74dbf1ef, 0x343aca87),
WTCP(0x74c088fe, 0x3477f350), WTCP(0x74a5000a, 0x34b50db5),
WTCP(0x7489571c, 0x34f219a8), WTCP(0x746d8e3a, 0x352f1716),
WTCP(0x7451a56e, 0x356c05f0), WTCP(0x74359cbd, 0x35a8e625),
WTCP(0x74197431, 0x35e5b7a3), WTCP(0x73fd2bd0, 0x36227a5b),
WTCP(0x73e0c3a3, 0x365f2e3b), WTCP(0x73c43bb1, 0x369bd334),
WTCP(0x73a79402, 0x36d86934), WTCP(0x738acc9e, 0x3714f02a),
WTCP(0x736de58d, 0x37516807), WTCP(0x7350ded7, 0x378dd0b9),
WTCP(0x7333b883, 0x37ca2a30), WTCP(0x7316729a, 0x3806745c),
WTCP(0x72f90d24, 0x3842af2b), WTCP(0x72db8828, 0x387eda8e),
WTCP(0x72bde3af, 0x38baf674), WTCP(0x72a01fc2, 0x38f702cd),
WTCP(0x72823c67, 0x3932ff87), WTCP(0x726439a8, 0x396eec93),
WTCP(0x7246178c, 0x39aac9e0), WTCP(0x7227d61c, 0x39e6975e),
WTCP(0x72097560, 0x3a2254fc), WTCP(0x71eaf561, 0x3a5e02aa),
WTCP(0x71cc5626, 0x3a99a057), WTCP(0x71ad97b9, 0x3ad52df4),
WTCP(0x718eba22, 0x3b10ab70), WTCP(0x716fbd68, 0x3b4c18ba),
WTCP(0x7150a195, 0x3b8775c2), WTCP(0x713166b1, 0x3bc2c279),
WTCP(0x71120cc5, 0x3bfdfecd), WTCP(0x70f293d9, 0x3c392aaf),
WTCP(0x70d2fbf6, 0x3c74460e), WTCP(0x70b34525, 0x3caf50da),
WTCP(0x70936f6e, 0x3cea4b04), WTCP(0x70737ad9, 0x3d253479),
WTCP(0x70536771, 0x3d600d2c), WTCP(0x7033353d, 0x3d9ad50b),
WTCP(0x7012e447, 0x3dd58c06), WTCP(0x6ff27497, 0x3e10320d),
WTCP(0x6fd1e635, 0x3e4ac711), WTCP(0x6fb1392c, 0x3e854b01),
WTCP(0x6f906d84, 0x3ebfbdcd), WTCP(0x6f6f8346, 0x3efa1f65),
WTCP(0x6f4e7a7b, 0x3f346fb8), WTCP(0x6f2d532c, 0x3f6eaeb8),
WTCP(0x6f0c0d62, 0x3fa8dc54), WTCP(0x6eeaa927, 0x3fe2f87c),
WTCP(0x6ec92683, 0x401d0321), WTCP(0x6ea7857f, 0x4056fc31),
WTCP(0x6e85c626, 0x4090e39e), WTCP(0x6e63e87f, 0x40cab958),
WTCP(0x6e41ec95, 0x41047d4e), WTCP(0x6e1fd271, 0x413e2f71),
WTCP(0x6dfd9a1c, 0x4177cfb1), WTCP(0x6ddb439f, 0x41b15dfe),
WTCP(0x6db8cf04, 0x41eada49), WTCP(0x6d963c54, 0x42244481),
WTCP(0x6d738b99, 0x425d9c97), WTCP(0x6d50bcdc, 0x4296e27b),
WTCP(0x6d2dd027, 0x42d0161e), WTCP(0x6d0ac584, 0x43093770),
WTCP(0x6ce79cfc, 0x43424661), WTCP(0x6cc45698, 0x437b42e1),
WTCP(0x6ca0f262, 0x43b42ce1), WTCP(0x6c7d7065, 0x43ed0452),
WTCP(0x6c59d0a9, 0x4425c923), WTCP(0x6c361339, 0x445e7b46),
WTCP(0x6c12381e, 0x44971aaa), WTCP(0x6bee3f62, 0x44cfa740),
WTCP(0x6bca2910, 0x450820f8), WTCP(0x6ba5f530, 0x454087c4),
WTCP(0x6b81a3cd, 0x4578db93), WTCP(0x6b5d34f1, 0x45b11c57),
WTCP(0x6b38a8a6, 0x45e949ff), WTCP(0x6b13fef5, 0x4621647d),
WTCP(0x6aef37e9, 0x46596bc1), WTCP(0x6aca538c, 0x46915fbb),
WTCP(0x6aa551e9, 0x46c9405c), WTCP(0x6a803308, 0x47010d96),
WTCP(0x6a5af6f5, 0x4738c758), WTCP(0x6a359db9, 0x47706d93),
WTCP(0x6a102760, 0x47a80039), WTCP(0x69ea93f2, 0x47df7f3a),
WTCP(0x69c4e37a, 0x4816ea86), WTCP(0x699f1604, 0x484e420f),
WTCP(0x69792b98, 0x488585c5), WTCP(0x69532442, 0x48bcb599),
WTCP(0x692d000c, 0x48f3d17c), WTCP(0x6906bf00, 0x492ad95f),
WTCP(0x68e06129, 0x4961cd33), WTCP(0x68b9e692, 0x4998ace9),
WTCP(0x68934f44, 0x49cf7871), WTCP(0x686c9b4b, 0x4a062fbd),
WTCP(0x6845cab1, 0x4a3cd2be), WTCP(0x681edd81, 0x4a736165),
WTCP(0x67f7d3c5, 0x4aa9dba2), WTCP(0x67d0ad88, 0x4ae04167),
WTCP(0x67a96ad5, 0x4b1692a5), WTCP(0x67820bb7, 0x4b4ccf4d),
WTCP(0x675a9038, 0x4b82f750), WTCP(0x6732f863, 0x4bb90aa0),
WTCP(0x670b4444, 0x4bef092d), WTCP(0x66e373e4, 0x4c24f2e9),
WTCP(0x66bb8750, 0x4c5ac7c4), WTCP(0x66937e91, 0x4c9087b1),
WTCP(0x666b59b3, 0x4cc632a0), WTCP(0x664318c0, 0x4cfbc883),
WTCP(0x661abbc5, 0x4d31494b), WTCP(0x65f242cc, 0x4d66b4e9),
WTCP(0x65c9addf, 0x4d9c0b4f), WTCP(0x65a0fd0b, 0x4dd14c6e),
WTCP(0x6578305a, 0x4e067837), WTCP(0x654f47d7, 0x4e3b8e9d),
WTCP(0x6526438f, 0x4e708f8f), WTCP(0x64fd238b, 0x4ea57b01),
WTCP(0x64d3e7d7, 0x4eda50e2), WTCP(0x64aa907f, 0x4f0f1126),
WTCP(0x64811d8e, 0x4f43bbbd), WTCP(0x64578f0f, 0x4f785099),
WTCP(0x642de50d, 0x4faccfab), WTCP(0x64041f95, 0x4fe138e5),
WTCP(0x63da3eb1, 0x50158c39), WTCP(0x63b0426d, 0x5049c999),
WTCP(0x63862ad5, 0x507df0f6), WTCP(0x635bf7f3, 0x50b20241),
WTCP(0x6331a9d4, 0x50e5fd6d), WTCP(0x63074084, 0x5119e26b),
WTCP(0x62dcbc0d, 0x514db12d), WTCP(0x62b21c7b, 0x518169a5),
WTCP(0x628761db, 0x51b50bc4), WTCP(0x625c8c38, 0x51e8977d),
WTCP(0x62319b9d, 0x521c0cc2), WTCP(0x62069017, 0x524f6b83),
WTCP(0x61db69b1, 0x5282b3b4), WTCP(0x61b02876, 0x52b5e546),
WTCP(0x6184cc74, 0x52e9002a), WTCP(0x615955b6, 0x531c0454),
WTCP(0x612dc447, 0x534ef1b5), WTCP(0x61021834, 0x5381c83f),
WTCP(0x60d65188, 0x53b487e5), WTCP(0x60aa7050, 0x53e73097),
WTCP(0x607e7497, 0x5419c249), WTCP(0x60525e6b, 0x544c3cec),
WTCP(0x60262dd6, 0x547ea073), WTCP(0x5ff9e2e5, 0x54b0ecd0),
WTCP(0x5fcd7da4, 0x54e321f5), WTCP(0x5fa0fe1f, 0x55153fd4),
WTCP(0x5f746462, 0x55474660), WTCP(0x5f47b07a, 0x5579358b),
WTCP(0x5f1ae274, 0x55ab0d46), WTCP(0x5eedfa5a, 0x55dccd86),
WTCP(0x5ec0f839, 0x560e763b), WTCP(0x5e93dc1f, 0x56400758),
WTCP(0x5e66a617, 0x567180d0), WTCP(0x5e39562d, 0x56a2e295),
WTCP(0x5e0bec6e, 0x56d42c99), WTCP(0x5dde68e7, 0x57055ed0),
WTCP(0x5db0cba4, 0x5736792b), WTCP(0x5d8314b1, 0x57677b9d),
WTCP(0x5d55441b, 0x57986619), WTCP(0x5d2759ee, 0x57c93891),
WTCP(0x5cf95638, 0x57f9f2f8), WTCP(0x5ccb3905, 0x582a9540),
WTCP(0x5c9d0260, 0x585b1f5c), WTCP(0x5c6eb258, 0x588b9140),
WTCP(0x5c4048f9, 0x58bbeadd), WTCP(0x5c11c64f, 0x58ec2c26),
WTCP(0x5be32a67, 0x591c550e), WTCP(0x5bb4754e, 0x594c6588),
WTCP(0x5b85a711, 0x597c5d87), WTCP(0x5b56bfbd, 0x59ac3cfd),
WTCP(0x5b27bf5e, 0x59dc03de), WTCP(0x5af8a602, 0x5a0bb21c),
WTCP(0x5ac973b5, 0x5a3b47ab), WTCP(0x5a9a2884, 0x5a6ac47c),
};
RAM_ALIGN
LNK_SECTION_CONSTDATA
const FIXP_WTP SineWindow960[] = {
WTCP(0x7ffffd31, 0x001aceea), WTCP(0x7fffe6bc, 0x00506cb9),
WTCP(0x7fffb9d1, 0x00860a79), WTCP(0x7fff7671, 0x00bba822),
WTCP(0x7fff1c9b, 0x00f145ab), WTCP(0x7ffeac50, 0x0126e309),
WTCP(0x7ffe2590, 0x015c8033), WTCP(0x7ffd885a, 0x01921d20),
WTCP(0x7ffcd4b0, 0x01c7b9c6), WTCP(0x7ffc0a91, 0x01fd561d),
WTCP(0x7ffb29fd, 0x0232f21a), WTCP(0x7ffa32f4, 0x02688db4),
WTCP(0x7ff92577, 0x029e28e2), WTCP(0x7ff80186, 0x02d3c39b),
WTCP(0x7ff6c720, 0x03095dd5), WTCP(0x7ff57647, 0x033ef786),
WTCP(0x7ff40efa, 0x037490a5), WTCP(0x7ff2913a, 0x03aa292a),
WTCP(0x7ff0fd07, 0x03dfc109), WTCP(0x7fef5260, 0x0415583b),
WTCP(0x7fed9148, 0x044aeeb5), WTCP(0x7febb9bd, 0x0480846e),
WTCP(0x7fe9cbc0, 0x04b6195d), WTCP(0x7fe7c752, 0x04ebad79),
WTCP(0x7fe5ac72, 0x052140b7), WTCP(0x7fe37b22, 0x0556d30f),
WTCP(0x7fe13361, 0x058c6478), WTCP(0x7fded530, 0x05c1f4e7),
WTCP(0x7fdc608f, 0x05f78453), WTCP(0x7fd9d57f, 0x062d12b4),
WTCP(0x7fd73401, 0x06629ffe), WTCP(0x7fd47c14, 0x06982c2b),
WTCP(0x7fd1adb9, 0x06cdb72f), WTCP(0x7fcec8f1, 0x07034101),
WTCP(0x7fcbcdbc, 0x0738c998), WTCP(0x7fc8bc1b, 0x076e50eb),
WTCP(0x7fc5940e, 0x07a3d6f0), WTCP(0x7fc25596, 0x07d95b9e),
WTCP(0x7fbf00b3, 0x080edeec), WTCP(0x7fbb9567, 0x084460cf),
WTCP(0x7fb813b0, 0x0879e140), WTCP(0x7fb47b91, 0x08af6033),
WTCP(0x7fb0cd0a, 0x08e4dda0), WTCP(0x7fad081b, 0x091a597e),
WTCP(0x7fa92cc5, 0x094fd3c3), WTCP(0x7fa53b09, 0x09854c66),
WTCP(0x7fa132e8, 0x09bac35d), WTCP(0x7f9d1461, 0x09f0389f),
WTCP(0x7f98df77, 0x0a25ac23), WTCP(0x7f949429, 0x0a5b1dde),
WTCP(0x7f903279, 0x0a908dc9), WTCP(0x7f8bba66, 0x0ac5fbd9),
WTCP(0x7f872bf3, 0x0afb6805), WTCP(0x7f82871f, 0x0b30d244),
WTCP(0x7f7dcbec, 0x0b663a8c), WTCP(0x7f78fa5b, 0x0b9ba0d5),
WTCP(0x7f74126b, 0x0bd10513), WTCP(0x7f6f141f, 0x0c066740),
WTCP(0x7f69ff76, 0x0c3bc74f), WTCP(0x7f64d473, 0x0c71253a),
WTCP(0x7f5f9315, 0x0ca680f5), WTCP(0x7f5a3b5e, 0x0cdbda79),
WTCP(0x7f54cd4f, 0x0d1131ba), WTCP(0x7f4f48e8, 0x0d4686b1),
WTCP(0x7f49ae2a, 0x0d7bd954), WTCP(0x7f43fd18, 0x0db12999),
WTCP(0x7f3e35b0, 0x0de67776), WTCP(0x7f3857f6, 0x0e1bc2e4),
WTCP(0x7f3263e9, 0x0e510bd8), WTCP(0x7f2c598a, 0x0e865248),
WTCP(0x7f2638db, 0x0ebb962c), WTCP(0x7f2001dd, 0x0ef0d77b),
WTCP(0x7f19b491, 0x0f26162a), WTCP(0x7f1350f8, 0x0f5b5231),
WTCP(0x7f0cd712, 0x0f908b86), WTCP(0x7f0646e2, 0x0fc5c220),
WTCP(0x7effa069, 0x0ffaf5f6), WTCP(0x7ef8e3a6, 0x103026fe),
WTCP(0x7ef2109d, 0x1065552e), WTCP(0x7eeb274d, 0x109a807e),
WTCP(0x7ee427b9, 0x10cfa8e5), WTCP(0x7edd11e1, 0x1104ce58),
WTCP(0x7ed5e5c6, 0x1139f0cf), WTCP(0x7ecea36b, 0x116f1040),
WTCP(0x7ec74acf, 0x11a42ca2), WTCP(0x7ebfdbf5, 0x11d945eb),
WTCP(0x7eb856de, 0x120e5c13), WTCP(0x7eb0bb8a, 0x12436f10),
WTCP(0x7ea909fc, 0x12787ed8), WTCP(0x7ea14235, 0x12ad8b63),
WTCP(0x7e996436, 0x12e294a7), WTCP(0x7e917000, 0x13179a9b),
WTCP(0x7e896595, 0x134c9d34), WTCP(0x7e8144f6, 0x13819c6c),
WTCP(0x7e790e25, 0x13b69836), WTCP(0x7e70c124, 0x13eb908c),
WTCP(0x7e685df2, 0x14208563), WTCP(0x7e5fe493, 0x145576b1),
WTCP(0x7e575508, 0x148a646e), WTCP(0x7e4eaf51, 0x14bf4e91),
WTCP(0x7e45f371, 0x14f43510), WTCP(0x7e3d2169, 0x152917e1),
WTCP(0x7e34393b, 0x155df6fc), WTCP(0x7e2b3ae8, 0x1592d257),
WTCP(0x7e222672, 0x15c7a9ea), WTCP(0x7e18fbda, 0x15fc7daa),
WTCP(0x7e0fbb22, 0x16314d8e), WTCP(0x7e06644c, 0x1666198d),
WTCP(0x7dfcf759, 0x169ae19f), WTCP(0x7df3744b, 0x16cfa5b9),
WTCP(0x7de9db23, 0x170465d2), WTCP(0x7de02be4, 0x173921e2),
WTCP(0x7dd6668f, 0x176dd9de), WTCP(0x7dcc8b25, 0x17a28dbe),
WTCP(0x7dc299a9, 0x17d73d79), WTCP(0x7db8921c, 0x180be904),
WTCP(0x7dae747f, 0x18409058), WTCP(0x7da440d6, 0x1875336a),
WTCP(0x7d99f721, 0x18a9d231), WTCP(0x7d8f9762, 0x18de6ca5),
WTCP(0x7d85219c, 0x191302bc), WTCP(0x7d7a95cf, 0x1947946c),
WTCP(0x7d6ff3fe, 0x197c21ad), WTCP(0x7d653c2b, 0x19b0aa75),
WTCP(0x7d5a6e57, 0x19e52ebb), WTCP(0x7d4f8a85, 0x1a19ae76),
WTCP(0x7d4490b6, 0x1a4e299d), WTCP(0x7d3980ec, 0x1a82a026),
WTCP(0x7d2e5b2a, 0x1ab71208), WTCP(0x7d231f70, 0x1aeb7f3a),
WTCP(0x7d17cdc2, 0x1b1fe7b3), WTCP(0x7d0c6621, 0x1b544b6a),
WTCP(0x7d00e88f, 0x1b88aa55), WTCP(0x7cf5550e, 0x1bbd046c),
WTCP(0x7ce9aba1, 0x1bf159a4), WTCP(0x7cddec48, 0x1c25a9f6),
WTCP(0x7cd21707, 0x1c59f557), WTCP(0x7cc62bdf, 0x1c8e3bbe),
WTCP(0x7cba2ad3, 0x1cc27d23), WTCP(0x7cae13e4, 0x1cf6b97c),
WTCP(0x7ca1e715, 0x1d2af0c1), WTCP(0x7c95a467, 0x1d5f22e7),
WTCP(0x7c894bde, 0x1d934fe5), WTCP(0x7c7cdd7b, 0x1dc777b3),
WTCP(0x7c705940, 0x1dfb9a48), WTCP(0x7c63bf2f, 0x1e2fb79a),
WTCP(0x7c570f4b, 0x1e63cfa0), WTCP(0x7c4a4996, 0x1e97e251),
WTCP(0x7c3d6e13, 0x1ecbefa4), WTCP(0x7c307cc2, 0x1efff78f),
WTCP(0x7c2375a8, 0x1f33fa0a), WTCP(0x7c1658c5, 0x1f67f70b),
WTCP(0x7c09261d, 0x1f9bee8a), WTCP(0x7bfbddb1, 0x1fcfe07d),
WTCP(0x7bee7f85, 0x2003ccdb), WTCP(0x7be10b99, 0x2037b39b),
WTCP(0x7bd381f1, 0x206b94b4), WTCP(0x7bc5e290, 0x209f701c),
WTCP(0x7bb82d76, 0x20d345cc), WTCP(0x7baa62a8, 0x210715b8),
WTCP(0x7b9c8226, 0x213adfda), WTCP(0x7b8e8bf5, 0x216ea426),
WTCP(0x7b808015, 0x21a26295), WTCP(0x7b725e8a, 0x21d61b1e),
WTCP(0x7b642756, 0x2209cdb6), WTCP(0x7b55da7c, 0x223d7a55),
WTCP(0x7b4777fe, 0x227120f3), WTCP(0x7b38ffde, 0x22a4c185),
WTCP(0x7b2a721f, 0x22d85c04), WTCP(0x7b1bcec4, 0x230bf065),
WTCP(0x7b0d15d0, 0x233f7ea0), WTCP(0x7afe4744, 0x237306ab),
WTCP(0x7aef6323, 0x23a6887f), WTCP(0x7ae06971, 0x23da0411),
WTCP(0x7ad15a2f, 0x240d7958), WTCP(0x7ac23561, 0x2440e84d),
WTCP(0x7ab2fb09, 0x247450e4), WTCP(0x7aa3ab29, 0x24a7b317),
WTCP(0x7a9445c5, 0x24db0edb), WTCP(0x7a84cade, 0x250e6427),
WTCP(0x7a753a79, 0x2541b2f3), WTCP(0x7a659496, 0x2574fb36),
WTCP(0x7a55d93a, 0x25a83ce6), WTCP(0x7a460867, 0x25db77fa),
WTCP(0x7a362220, 0x260eac6a), WTCP(0x7a262668, 0x2641da2d),
WTCP(0x7a161540, 0x26750139), WTCP(0x7a05eead, 0x26a82186),
WTCP(0x79f5b2b1, 0x26db3b0a), WTCP(0x79e5614f, 0x270e4dbd),
WTCP(0x79d4fa89, 0x27415996), WTCP(0x79c47e63, 0x27745e8c),
WTCP(0x79b3ece0, 0x27a75c95), WTCP(0x79a34602, 0x27da53a9),
WTCP(0x799289cc, 0x280d43bf), WTCP(0x7981b841, 0x28402cce),
WTCP(0x7970d165, 0x28730ecd), WTCP(0x795fd53a, 0x28a5e9b4),
WTCP(0x794ec3c3, 0x28d8bd78), WTCP(0x793d9d03, 0x290b8a12),
WTCP(0x792c60fe, 0x293e4f78), WTCP(0x791b0fb5, 0x29710da1),
WTCP(0x7909a92d, 0x29a3c485), WTCP(0x78f82d68, 0x29d6741b),
WTCP(0x78e69c69, 0x2a091c59), WTCP(0x78d4f634, 0x2a3bbd37),
WTCP(0x78c33acb, 0x2a6e56ac), WTCP(0x78b16a32, 0x2aa0e8b0),
WTCP(0x789f846b, 0x2ad37338), WTCP(0x788d897b, 0x2b05f63d),
WTCP(0x787b7963, 0x2b3871b5), WTCP(0x78695428, 0x2b6ae598),
WTCP(0x785719cc, 0x2b9d51dd), WTCP(0x7844ca53, 0x2bcfb67b),
WTCP(0x783265c0, 0x2c021369), WTCP(0x781fec15, 0x2c34689e),
WTCP(0x780d5d57, 0x2c66b611), WTCP(0x77fab989, 0x2c98fbba),
WTCP(0x77e800ad, 0x2ccb3990), WTCP(0x77d532c7, 0x2cfd6f8a),
WTCP(0x77c24fdb, 0x2d2f9d9f), WTCP(0x77af57eb, 0x2d61c3c7),
WTCP(0x779c4afc, 0x2d93e1f8), WTCP(0x77892910, 0x2dc5f829),
WTCP(0x7775f22a, 0x2df80653), WTCP(0x7762a64f, 0x2e2a0c6c),
WTCP(0x774f4581, 0x2e5c0a6b), WTCP(0x773bcfc4, 0x2e8e0048),
WTCP(0x7728451c, 0x2ebfedfa), WTCP(0x7714a58b, 0x2ef1d377),
WTCP(0x7700f115, 0x2f23b0b9), WTCP(0x76ed27be, 0x2f5585b5),
WTCP(0x76d94989, 0x2f875262), WTCP(0x76c55679, 0x2fb916b9),
WTCP(0x76b14e93, 0x2fead2b0), WTCP(0x769d31d9, 0x301c863f),
WTCP(0x76890050, 0x304e315d), WTCP(0x7674b9fa, 0x307fd401),
WTCP(0x76605edb, 0x30b16e23), WTCP(0x764beef8, 0x30e2ffb9),
WTCP(0x76376a52, 0x311488bc), WTCP(0x7622d0ef, 0x31460922),
WTCP(0x760e22d1, 0x317780e2), WTCP(0x75f95ffc, 0x31a8eff5),
WTCP(0x75e48874, 0x31da5651), WTCP(0x75cf9c3d, 0x320bb3ee),
WTCP(0x75ba9b5a, 0x323d08c3), WTCP(0x75a585cf, 0x326e54c7),
WTCP(0x75905ba0, 0x329f97f3), WTCP(0x757b1ccf, 0x32d0d23c),
WTCP(0x7565c962, 0x3302039b), WTCP(0x7550615c, 0x33332c06),
WTCP(0x753ae4c0, 0x33644b76), WTCP(0x75255392, 0x339561e1),
WTCP(0x750fadd7, 0x33c66f40), WTCP(0x74f9f391, 0x33f77388),
WTCP(0x74e424c5, 0x34286eb3), WTCP(0x74ce4177, 0x345960b7),
WTCP(0x74b849aa, 0x348a498b), WTCP(0x74a23d62, 0x34bb2927),
WTCP(0x748c1ca4, 0x34ebff83), WTCP(0x7475e772, 0x351ccc96),
WTCP(0x745f9dd1, 0x354d9057), WTCP(0x74493fc5, 0x357e4abe),
WTCP(0x7432cd51, 0x35aefbc2), WTCP(0x741c467b, 0x35dfa35a),
WTCP(0x7405ab45, 0x3610417f), WTCP(0x73eefbb3, 0x3640d627),
WTCP(0x73d837ca, 0x3671614b), WTCP(0x73c15f8d, 0x36a1e2e0),
WTCP(0x73aa7301, 0x36d25ae0), WTCP(0x7393722a, 0x3702c942),
WTCP(0x737c5d0b, 0x37332dfd), WTCP(0x736533a9, 0x37638908),
WTCP(0x734df607, 0x3793da5b), WTCP(0x7336a42b, 0x37c421ee),
WTCP(0x731f3e17, 0x37f45fb7), WTCP(0x7307c3d0, 0x382493b0),
WTCP(0x72f0355a, 0x3854bdcf), WTCP(0x72d892ba, 0x3884de0b),
WTCP(0x72c0dbf3, 0x38b4f45d), WTCP(0x72a91109, 0x38e500bc),
WTCP(0x72913201, 0x3915031f), WTCP(0x72793edf, 0x3944fb7e),
WTCP(0x726137a8, 0x3974e9d0), WTCP(0x72491c5e, 0x39a4ce0e),
WTCP(0x7230ed07, 0x39d4a82f), WTCP(0x7218a9a7, 0x3a04782a),
WTCP(0x72005242, 0x3a343df7), WTCP(0x71e7e6dc, 0x3a63f98d),
WTCP(0x71cf677a, 0x3a93aae5), WTCP(0x71b6d420, 0x3ac351f6),
WTCP(0x719e2cd2, 0x3af2eeb7), WTCP(0x71857195, 0x3b228120),
WTCP(0x716ca26c, 0x3b52092a), WTCP(0x7153bf5d, 0x3b8186ca),
WTCP(0x713ac86b, 0x3bb0f9fa), WTCP(0x7121bd9c, 0x3be062b0),
WTCP(0x71089ef2, 0x3c0fc0e6), WTCP(0x70ef6c74, 0x3c3f1491),
WTCP(0x70d62625, 0x3c6e5daa), WTCP(0x70bccc09, 0x3c9d9c28),
WTCP(0x70a35e25, 0x3cccd004), WTCP(0x7089dc7e, 0x3cfbf935),
WTCP(0x70704718, 0x3d2b17b3), WTCP(0x70569df8, 0x3d5a2b75),
WTCP(0x703ce122, 0x3d893474), WTCP(0x7023109a, 0x3db832a6),
WTCP(0x70092c65, 0x3de72604), WTCP(0x6fef3488, 0x3e160e85),
WTCP(0x6fd52907, 0x3e44ec22), WTCP(0x6fbb09e7, 0x3e73bed2),
WTCP(0x6fa0d72c, 0x3ea2868c), WTCP(0x6f8690db, 0x3ed14349),
WTCP(0x6f6c36f8, 0x3efff501), WTCP(0x6f51c989, 0x3f2e9bab),
WTCP(0x6f374891, 0x3f5d373e), WTCP(0x6f1cb416, 0x3f8bc7b4),
WTCP(0x6f020c1c, 0x3fba4d03), WTCP(0x6ee750a8, 0x3fe8c724),
WTCP(0x6ecc81be, 0x4017360e), WTCP(0x6eb19f64, 0x404599b9),
WTCP(0x6e96a99d, 0x4073f21d), WTCP(0x6e7ba06f, 0x40a23f32),
WTCP(0x6e6083de, 0x40d080f0), WTCP(0x6e4553ef, 0x40feb74f),
WTCP(0x6e2a10a8, 0x412ce246), WTCP(0x6e0eba0c, 0x415b01ce),
WTCP(0x6df35020, 0x418915de), WTCP(0x6dd7d2ea, 0x41b71e6f),
WTCP(0x6dbc426e, 0x41e51b77), WTCP(0x6da09eb1, 0x42130cf0),
WTCP(0x6d84e7b7, 0x4240f2d1), WTCP(0x6d691d87, 0x426ecd12),
WTCP(0x6d4d4023, 0x429c9bab), WTCP(0x6d314f93, 0x42ca5e94),
WTCP(0x6d154bd9, 0x42f815c5), WTCP(0x6cf934fc, 0x4325c135),
WTCP(0x6cdd0b00, 0x435360de), WTCP(0x6cc0cdea, 0x4380f4b7),
WTCP(0x6ca47dbf, 0x43ae7cb7), WTCP(0x6c881a84, 0x43dbf8d7),
WTCP(0x6c6ba43e, 0x44096910), WTCP(0x6c4f1af2, 0x4436cd58),
WTCP(0x6c327ea6, 0x446425a8), WTCP(0x6c15cf5d, 0x449171f8),
WTCP(0x6bf90d1d, 0x44beb240), WTCP(0x6bdc37eb, 0x44ebe679),
WTCP(0x6bbf4fcd, 0x45190e99), WTCP(0x6ba254c7, 0x45462a9a),
WTCP(0x6b8546de, 0x45733a73), WTCP(0x6b682617, 0x45a03e1d),
WTCP(0x6b4af279, 0x45cd358f), WTCP(0x6b2dac06, 0x45fa20c2),
WTCP(0x6b1052c6, 0x4626ffae), WTCP(0x6af2e6bc, 0x4653d24b),
WTCP(0x6ad567ef, 0x46809891), WTCP(0x6ab7d663, 0x46ad5278),
WTCP(0x6a9a321d, 0x46d9fff8), WTCP(0x6a7c7b23, 0x4706a10a),
WTCP(0x6a5eb17a, 0x473335a5), WTCP(0x6a40d527, 0x475fbdc3),
WTCP(0x6a22e630, 0x478c395a), WTCP(0x6a04e499, 0x47b8a864),
WTCP(0x69e6d067, 0x47e50ad8), WTCP(0x69c8a9a1, 0x481160ae),
WTCP(0x69aa704c, 0x483da9e0), WTCP(0x698c246c, 0x4869e665),
WTCP(0x696dc607, 0x48961635), WTCP(0x694f5523, 0x48c23949),
WTCP(0x6930d1c4, 0x48ee4f98), WTCP(0x69123bf1, 0x491a591c),
WTCP(0x68f393ae, 0x494655cc), WTCP(0x68d4d900, 0x497245a1),
WTCP(0x68b60bee, 0x499e2892), WTCP(0x68972c7d, 0x49c9fe99),
WTCP(0x68783ab1, 0x49f5c7ae), WTCP(0x68593691, 0x4a2183c8),
WTCP(0x683a2022, 0x4a4d32e1), WTCP(0x681af76a, 0x4a78d4f0),
WTCP(0x67fbbc6d, 0x4aa469ee), WTCP(0x67dc6f31, 0x4acff1d3),
WTCP(0x67bd0fbd, 0x4afb6c98), WTCP(0x679d9e14, 0x4b26da35),
WTCP(0x677e1a3e, 0x4b523aa2), WTCP(0x675e843e, 0x4b7d8dd8),
WTCP(0x673edc1c, 0x4ba8d3cf), WTCP(0x671f21dc, 0x4bd40c80),
WTCP(0x66ff5584, 0x4bff37e2), WTCP(0x66df771a, 0x4c2a55ef),
WTCP(0x66bf86a3, 0x4c55669f), WTCP(0x669f8425, 0x4c8069ea),
WTCP(0x667f6fa5, 0x4cab5fc9), WTCP(0x665f4929, 0x4cd64834),
WTCP(0x663f10b7, 0x4d012324), WTCP(0x661ec654, 0x4d2bf091),
WTCP(0x65fe6a06, 0x4d56b073), WTCP(0x65ddfbd3, 0x4d8162c4),
WTCP(0x65bd7bc0, 0x4dac077b), WTCP(0x659ce9d4, 0x4dd69e92),
WTCP(0x657c4613, 0x4e012800), WTCP(0x655b9083, 0x4e2ba3be),
WTCP(0x653ac92b, 0x4e5611c5), WTCP(0x6519f010, 0x4e80720e),
WTCP(0x64f90538, 0x4eaac490), WTCP(0x64d808a8, 0x4ed50945),
WTCP(0x64b6fa66, 0x4eff4025), WTCP(0x6495da79, 0x4f296928),
WTCP(0x6474a8e5, 0x4f538448), WTCP(0x645365b2, 0x4f7d917c),
WTCP(0x643210e4, 0x4fa790be), WTCP(0x6410aa81, 0x4fd18206),
WTCP(0x63ef3290, 0x4ffb654d), WTCP(0x63cda916, 0x50253a8b),
WTCP(0x63ac0e19, 0x504f01ba), WTCP(0x638a619e, 0x5078bad1),
WTCP(0x6368a3ad, 0x50a265c9), WTCP(0x6346d44b, 0x50cc029c),
WTCP(0x6324f37d, 0x50f59141), WTCP(0x6303014a, 0x511f11b2),
WTCP(0x62e0fdb8, 0x514883e7), WTCP(0x62bee8cc, 0x5171e7d9),
WTCP(0x629cc28c, 0x519b3d80), WTCP(0x627a8b00, 0x51c484d6),
WTCP(0x6258422c, 0x51edbdd4), WTCP(0x6235e816, 0x5216e871),
WTCP(0x62137cc5, 0x524004a7), WTCP(0x61f1003f, 0x5269126e),
WTCP(0x61ce7289, 0x529211c0), WTCP(0x61abd3ab, 0x52bb0295),
WTCP(0x618923a9, 0x52e3e4e6), WTCP(0x61666289, 0x530cb8ac),
WTCP(0x61439053, 0x53357ddf), WTCP(0x6120ad0d, 0x535e3479),
WTCP(0x60fdb8bb, 0x5386dc72), WTCP(0x60dab365, 0x53af75c3),
WTCP(0x60b79d10, 0x53d80065), WTCP(0x609475c3, 0x54007c51),
WTCP(0x60713d84, 0x5428e980), WTCP(0x604df459, 0x545147eb),
WTCP(0x602a9a48, 0x5479978a), WTCP(0x60072f57, 0x54a1d857),
WTCP(0x5fe3b38d, 0x54ca0a4b), WTCP(0x5fc026f0, 0x54f22d5d),
WTCP(0x5f9c8987, 0x551a4189), WTCP(0x5f78db56, 0x554246c6),
WTCP(0x5f551c65, 0x556a3d0d), WTCP(0x5f314cba, 0x55922457),
WTCP(0x5f0d6c5b, 0x55b9fc9e), WTCP(0x5ee97b4f, 0x55e1c5da),
WTCP(0x5ec5799b, 0x56098005), WTCP(0x5ea16747, 0x56312b17),
WTCP(0x5e7d4458, 0x5658c709), WTCP(0x5e5910d4, 0x568053d5),
WTCP(0x5e34ccc3, 0x56a7d174), WTCP(0x5e10782b, 0x56cf3fde),
WTCP(0x5dec1311, 0x56f69f0d), WTCP(0x5dc79d7c, 0x571deefa),
WTCP(0x5da31773, 0x57452f9d), WTCP(0x5d7e80fc, 0x576c60f1),
WTCP(0x5d59da1e, 0x579382ee), WTCP(0x5d3522de, 0x57ba958d),
WTCP(0x5d105b44, 0x57e198c7), WTCP(0x5ceb8355, 0x58088c96),
WTCP(0x5cc69b19, 0x582f70f3), WTCP(0x5ca1a295, 0x585645d7),
WTCP(0x5c7c99d1, 0x587d0b3b), WTCP(0x5c5780d3, 0x58a3c118),
WTCP(0x5c3257a0, 0x58ca6767), WTCP(0x5c0d1e41, 0x58f0fe23),
WTCP(0x5be7d4ba, 0x59178543), WTCP(0x5bc27b14, 0x593dfcc2),
WTCP(0x5b9d1154, 0x59646498), WTCP(0x5b779780, 0x598abcbe),
WTCP(0x5b520da1, 0x59b1052f), WTCP(0x5b2c73bb, 0x59d73de3),
WTCP(0x5b06c9d6, 0x59fd66d4), WTCP(0x5ae10ff9, 0x5a237ffa),
WTCP(0x5abb4629, 0x5a498950), WTCP(0x5a956c6e, 0x5a6f82ce),
};
RAM_ALIGN
LNK_SECTION_CONSTDATA
const FIXP_WTP SineWindow1024[] = {
WTCP(0x7ffffd88, 0x001921fb), WTCP(0x7fffe9cb, 0x004b65ee),
WTCP(0x7fffc251, 0x007da9d4), WTCP(0x7fff8719, 0x00afeda8),
WTCP(0x7fff3824, 0x00e23160), WTCP(0x7ffed572, 0x011474f6),
WTCP(0x7ffe5f03, 0x0146b860), WTCP(0x7ffdd4d7, 0x0178fb99),
WTCP(0x7ffd36ee, 0x01ab3e97), WTCP(0x7ffc8549, 0x01dd8154),
WTCP(0x7ffbbfe6, 0x020fc3c6), WTCP(0x7ffae6c7, 0x024205e8),
WTCP(0x7ff9f9ec, 0x027447b0), WTCP(0x7ff8f954, 0x02a68917),
WTCP(0x7ff7e500, 0x02d8ca16), WTCP(0x7ff6bcf0, 0x030b0aa4),
WTCP(0x7ff58125, 0x033d4abb), WTCP(0x7ff4319d, 0x036f8a51),
WTCP(0x7ff2ce5b, 0x03a1c960), WTCP(0x7ff1575d, 0x03d407df),
WTCP(0x7fefcca4, 0x040645c7), WTCP(0x7fee2e30, 0x04388310),
WTCP(0x7fec7c02, 0x046abfb3), WTCP(0x7feab61a, 0x049cfba7),
WTCP(0x7fe8dc78, 0x04cf36e5), WTCP(0x7fe6ef1c, 0x05017165),
WTCP(0x7fe4ee06, 0x0533ab20), WTCP(0x7fe2d938, 0x0565e40d),
WTCP(0x7fe0b0b1, 0x05981c26), WTCP(0x7fde7471, 0x05ca5361),
WTCP(0x7fdc247a, 0x05fc89b8), WTCP(0x7fd9c0ca, 0x062ebf22),
WTCP(0x7fd74964, 0x0660f398), WTCP(0x7fd4be46, 0x06932713),
WTCP(0x7fd21f72, 0x06c5598a), WTCP(0x7fcf6ce8, 0x06f78af6),
WTCP(0x7fcca6a7, 0x0729bb4e), WTCP(0x7fc9ccb2, 0x075bea8c),
WTCP(0x7fc6df08, 0x078e18a7), WTCP(0x7fc3dda9, 0x07c04598),
WTCP(0x7fc0c896, 0x07f27157), WTCP(0x7fbd9fd0, 0x08249bdd),
WTCP(0x7fba6357, 0x0856c520), WTCP(0x7fb7132b, 0x0888ed1b),
WTCP(0x7fb3af4e, 0x08bb13c5), WTCP(0x7fb037bf, 0x08ed3916),
WTCP(0x7facac7f, 0x091f5d06), WTCP(0x7fa90d8e, 0x09517f8f),
WTCP(0x7fa55aee, 0x0983a0a7), WTCP(0x7fa1949e, 0x09b5c048),
WTCP(0x7f9dbaa0, 0x09e7de6a), WTCP(0x7f99ccf4, 0x0a19fb04),
WTCP(0x7f95cb9a, 0x0a4c1610), WTCP(0x7f91b694, 0x0a7e2f85),
WTCP(0x7f8d8de1, 0x0ab0475c), WTCP(0x7f895182, 0x0ae25d8d),
WTCP(0x7f850179, 0x0b147211), WTCP(0x7f809dc5, 0x0b4684df),
WTCP(0x7f7c2668, 0x0b7895f0), WTCP(0x7f779b62, 0x0baaa53b),
WTCP(0x7f72fcb4, 0x0bdcb2bb), WTCP(0x7f6e4a5e, 0x0c0ebe66),
WTCP(0x7f698461, 0x0c40c835), WTCP(0x7f64aabf, 0x0c72d020),
WTCP(0x7f5fbd77, 0x0ca4d620), WTCP(0x7f5abc8a, 0x0cd6da2d),
WTCP(0x7f55a7fa, 0x0d08dc3f), WTCP(0x7f507fc7, 0x0d3adc4e),
WTCP(0x7f4b43f2, 0x0d6cda53), WTCP(0x7f45f47b, 0x0d9ed646),
WTCP(0x7f409164, 0x0dd0d01f), WTCP(0x7f3b1aad, 0x0e02c7d7),
WTCP(0x7f359057, 0x0e34bd66), WTCP(0x7f2ff263, 0x0e66b0c3),
WTCP(0x7f2a40d2, 0x0e98a1e9), WTCP(0x7f247ba5, 0x0eca90ce),
WTCP(0x7f1ea2dc, 0x0efc7d6b), WTCP(0x7f18b679, 0x0f2e67b8),
WTCP(0x7f12b67c, 0x0f604faf), WTCP(0x7f0ca2e7, 0x0f923546),
WTCP(0x7f067bba, 0x0fc41876), WTCP(0x7f0040f6, 0x0ff5f938),
WTCP(0x7ef9f29d, 0x1027d784), WTCP(0x7ef390ae, 0x1059b352),
WTCP(0x7eed1b2c, 0x108b8c9b), WTCP(0x7ee69217, 0x10bd6356),
WTCP(0x7edff570, 0x10ef377d), WTCP(0x7ed94538, 0x11210907),
WTCP(0x7ed28171, 0x1152d7ed), WTCP(0x7ecbaa1a, 0x1184a427),
WTCP(0x7ec4bf36, 0x11b66dad), WTCP(0x7ebdc0c6, 0x11e83478),
WTCP(0x7eb6aeca, 0x1219f880), WTCP(0x7eaf8943, 0x124bb9be),
WTCP(0x7ea85033, 0x127d7829), WTCP(0x7ea1039b, 0x12af33ba),
WTCP(0x7e99a37c, 0x12e0ec6a), WTCP(0x7e922fd6, 0x1312a230),
WTCP(0x7e8aa8ac, 0x13445505), WTCP(0x7e830dff, 0x137604e2),
WTCP(0x7e7b5fce, 0x13a7b1bf), WTCP(0x7e739e1d, 0x13d95b93),
WTCP(0x7e6bc8eb, 0x140b0258), WTCP(0x7e63e03b, 0x143ca605),
WTCP(0x7e5be40c, 0x146e4694), WTCP(0x7e53d462, 0x149fe3fc),
WTCP(0x7e4bb13c, 0x14d17e36), WTCP(0x7e437a9c, 0x1503153a),
WTCP(0x7e3b3083, 0x1534a901), WTCP(0x7e32d2f4, 0x15663982),
WTCP(0x7e2a61ed, 0x1597c6b7), WTCP(0x7e21dd73, 0x15c95097),
WTCP(0x7e194584, 0x15fad71b), WTCP(0x7e109a24, 0x162c5a3b),
WTCP(0x7e07db52, 0x165dd9f0), WTCP(0x7dff0911, 0x168f5632),
WTCP(0x7df62362, 0x16c0cef9), WTCP(0x7ded2a47, 0x16f2443e),
WTCP(0x7de41dc0, 0x1723b5f9), WTCP(0x7ddafdce, 0x17552422),
WTCP(0x7dd1ca75, 0x17868eb3), WTCP(0x7dc883b4, 0x17b7f5a3),
WTCP(0x7dbf298d, 0x17e958ea), WTCP(0x7db5bc02, 0x181ab881),
WTCP(0x7dac3b15, 0x184c1461), WTCP(0x7da2a6c6, 0x187d6c82),
WTCP(0x7d98ff17, 0x18aec0db), WTCP(0x7d8f4409, 0x18e01167),
WTCP(0x7d85759f, 0x19115e1c), WTCP(0x7d7b93da, 0x1942a6f3),
WTCP(0x7d719eba, 0x1973ebe6), WTCP(0x7d679642, 0x19a52ceb),
WTCP(0x7d5d7a74, 0x19d669fc), WTCP(0x7d534b50, 0x1a07a311),
WTCP(0x7d4908d9, 0x1a38d823), WTCP(0x7d3eb30f, 0x1a6a0929),
WTCP(0x7d3449f5, 0x1a9b361d), WTCP(0x7d29cd8c, 0x1acc5ef6),
WTCP(0x7d1f3dd6, 0x1afd83ad), WTCP(0x7d149ad5, 0x1b2ea43a),
WTCP(0x7d09e489, 0x1b5fc097), WTCP(0x7cff1af5, 0x1b90d8bb),
WTCP(0x7cf43e1a, 0x1bc1ec9e), WTCP(0x7ce94dfb, 0x1bf2fc3a),
WTCP(0x7cde4a98, 0x1c240786), WTCP(0x7cd333f3, 0x1c550e7c),
WTCP(0x7cc80a0f, 0x1c861113), WTCP(0x7cbcccec, 0x1cb70f43),
WTCP(0x7cb17c8d, 0x1ce80906), WTCP(0x7ca618f3, 0x1d18fe54),
WTCP(0x7c9aa221, 0x1d49ef26), WTCP(0x7c8f1817, 0x1d7adb73),
WTCP(0x7c837ad8, 0x1dabc334), WTCP(0x7c77ca65, 0x1ddca662),
WTCP(0x7c6c06c0, 0x1e0d84f5), WTCP(0x7c602fec, 0x1e3e5ee5),
WTCP(0x7c5445e9, 0x1e6f342c), WTCP(0x7c4848ba, 0x1ea004c1),
WTCP(0x7c3c3860, 0x1ed0d09d), WTCP(0x7c3014de, 0x1f0197b8),
WTCP(0x7c23de35, 0x1f325a0b), WTCP(0x7c179467, 0x1f63178f),
WTCP(0x7c0b3777, 0x1f93d03c), WTCP(0x7bfec765, 0x1fc4840a),
WTCP(0x7bf24434, 0x1ff532f2), WTCP(0x7be5ade6, 0x2025dcec),
WTCP(0x7bd9047c, 0x205681f1), WTCP(0x7bcc47fa, 0x208721f9),
WTCP(0x7bbf7860, 0x20b7bcfe), WTCP(0x7bb295b0, 0x20e852f6),
WTCP(0x7ba59fee, 0x2118e3dc), WTCP(0x7b989719, 0x21496fa7),
WTCP(0x7b8b7b36, 0x2179f64f), WTCP(0x7b7e4c45, 0x21aa77cf),
WTCP(0x7b710a49, 0x21daf41d), WTCP(0x7b63b543, 0x220b6b32),
WTCP(0x7b564d36, 0x223bdd08), WTCP(0x7b48d225, 0x226c4996),
WTCP(0x7b3b4410, 0x229cb0d5), WTCP(0x7b2da2fa, 0x22cd12bd),
WTCP(0x7b1feee5, 0x22fd6f48), WTCP(0x7b1227d3, 0x232dc66d),
WTCP(0x7b044dc7, 0x235e1826), WTCP(0x7af660c2, 0x238e646a),
WTCP(0x7ae860c7, 0x23beab33), WTCP(0x7ada4dd8, 0x23eeec78),
WTCP(0x7acc27f7, 0x241f2833), WTCP(0x7abdef25, 0x244f5e5c),
WTCP(0x7aafa367, 0x247f8eec), WTCP(0x7aa144bc, 0x24afb9da),
WTCP(0x7a92d329, 0x24dfdf20), WTCP(0x7a844eae, 0x250ffeb7),
WTCP(0x7a75b74f, 0x25401896), WTCP(0x7a670d0d, 0x25702cb7),
WTCP(0x7a584feb, 0x25a03b11), WTCP(0x7a497feb, 0x25d0439f),
WTCP(0x7a3a9d0f, 0x26004657), WTCP(0x7a2ba75a, 0x26304333),
WTCP(0x7a1c9ece, 0x26603a2c), WTCP(0x7a0d836d, 0x26902b39),
WTCP(0x79fe5539, 0x26c01655), WTCP(0x79ef1436, 0x26effb76),
WTCP(0x79dfc064, 0x271fda96), WTCP(0x79d059c8, 0x274fb3ae),
WTCP(0x79c0e062, 0x277f86b5), WTCP(0x79b15435, 0x27af53a6),
WTCP(0x79a1b545, 0x27df1a77), WTCP(0x79920392, 0x280edb23),
WTCP(0x79823f20, 0x283e95a1), WTCP(0x797267f2, 0x286e49ea),
WTCP(0x79627e08, 0x289df7f8), WTCP(0x79528167, 0x28cd9fc1),
WTCP(0x79427210, 0x28fd4140), WTCP(0x79325006, 0x292cdc6d),
WTCP(0x79221b4b, 0x295c7140), WTCP(0x7911d3e2, 0x298bffb2),
WTCP(0x790179cd, 0x29bb87bc), WTCP(0x78f10d0f, 0x29eb0957),
WTCP(0x78e08dab, 0x2a1a847b), WTCP(0x78cffba3, 0x2a49f920),
WTCP(0x78bf56f9, 0x2a796740), WTCP(0x78ae9fb0, 0x2aa8ced3),
WTCP(0x789dd5cb, 0x2ad82fd2), WTCP(0x788cf94c, 0x2b078a36),
WTCP(0x787c0a36, 0x2b36ddf7), WTCP(0x786b088c, 0x2b662b0e),
WTCP(0x7859f44f, 0x2b957173), WTCP(0x7848cd83, 0x2bc4b120),
WTCP(0x7837942b, 0x2bf3ea0d), WTCP(0x78264849, 0x2c231c33),
WTCP(0x7814e9df, 0x2c52478a), WTCP(0x780378f1, 0x2c816c0c),
WTCP(0x77f1f581, 0x2cb089b1), WTCP(0x77e05f91, 0x2cdfa071),
WTCP(0x77ceb725, 0x2d0eb046), WTCP(0x77bcfc3f, 0x2d3db928),
WTCP(0x77ab2ee2, 0x2d6cbb10), WTCP(0x77994f11, 0x2d9bb5f6),
WTCP(0x77875cce, 0x2dcaa9d5), WTCP(0x7775581d, 0x2df996a3),
WTCP(0x776340ff, 0x2e287c5a), WTCP(0x77511778, 0x2e575af3),
WTCP(0x773edb8b, 0x2e863267), WTCP(0x772c8d3a, 0x2eb502ae),
WTCP(0x771a2c88, 0x2ee3cbc1), WTCP(0x7707b979, 0x2f128d99),
WTCP(0x76f5340e, 0x2f41482e), WTCP(0x76e29c4b, 0x2f6ffb7a),
WTCP(0x76cff232, 0x2f9ea775), WTCP(0x76bd35c7, 0x2fcd4c19),
WTCP(0x76aa670d, 0x2ffbe95d), WTCP(0x76978605, 0x302a7f3a),
WTCP(0x768492b4, 0x30590dab), WTCP(0x76718d1c, 0x308794a6),
WTCP(0x765e7540, 0x30b61426), WTCP(0x764b4b23, 0x30e48c22),
WTCP(0x76380ec8, 0x3112fc95), WTCP(0x7624c031, 0x31416576),
WTCP(0x76115f63, 0x316fc6be), WTCP(0x75fdec60, 0x319e2067),
WTCP(0x75ea672a, 0x31cc7269), WTCP(0x75d6cfc5, 0x31fabcbd),
WTCP(0x75c32634, 0x3228ff5c), WTCP(0x75af6a7b, 0x32573a3f),
WTCP(0x759b9c9b, 0x32856d5e), WTCP(0x7587bc98, 0x32b398b3),
WTCP(0x7573ca75, 0x32e1bc36), WTCP(0x755fc635, 0x330fd7e1),
WTCP(0x754bafdc, 0x333debab), WTCP(0x7537876c, 0x336bf78f),
WTCP(0x75234ce8, 0x3399fb85), WTCP(0x750f0054, 0x33c7f785),
WTCP(0x74faa1b3, 0x33f5eb89), WTCP(0x74e63108, 0x3423d78a),
WTCP(0x74d1ae55, 0x3451bb81), WTCP(0x74bd199f, 0x347f9766),
WTCP(0x74a872e8, 0x34ad6b32), WTCP(0x7493ba34, 0x34db36df),
WTCP(0x747eef85, 0x3508fa66), WTCP(0x746a12df, 0x3536b5be),
WTCP(0x74552446, 0x356468e2), WTCP(0x744023bc, 0x359213c9),
WTCP(0x742b1144, 0x35bfb66e), WTCP(0x7415ece2, 0x35ed50c9),
WTCP(0x7400b69a, 0x361ae2d3), WTCP(0x73eb6e6e, 0x36486c86),
WTCP(0x73d61461, 0x3675edd9), WTCP(0x73c0a878, 0x36a366c6),
WTCP(0x73ab2ab4, 0x36d0d746), WTCP(0x73959b1b, 0x36fe3f52),
WTCP(0x737ff9ae, 0x372b9ee3), WTCP(0x736a4671, 0x3758f5f2),
WTCP(0x73548168, 0x37864477), WTCP(0x733eaa96, 0x37b38a6d),
WTCP(0x7328c1ff, 0x37e0c7cc), WTCP(0x7312c7a5, 0x380dfc8d),
WTCP(0x72fcbb8c, 0x383b28a9), WTCP(0x72e69db7, 0x38684c19),
WTCP(0x72d06e2b, 0x389566d6), WTCP(0x72ba2cea, 0x38c278d9),
WTCP(0x72a3d9f7, 0x38ef821c), WTCP(0x728d7557, 0x391c8297),
WTCP(0x7276ff0d, 0x39497a43), WTCP(0x7260771b, 0x39766919),
WTCP(0x7249dd86, 0x39a34f13), WTCP(0x72333251, 0x39d02c2a),
WTCP(0x721c7580, 0x39fd0056), WTCP(0x7205a716, 0x3a29cb91),
WTCP(0x71eec716, 0x3a568dd4), WTCP(0x71d7d585, 0x3a834717),
WTCP(0x71c0d265, 0x3aaff755), WTCP(0x71a9bdba, 0x3adc9e86),
WTCP(0x71929789, 0x3b093ca3), WTCP(0x717b5fd3, 0x3b35d1a5),
WTCP(0x7164169d, 0x3b625d86), WTCP(0x714cbbeb, 0x3b8ee03e),
WTCP(0x71354fc0, 0x3bbb59c7), WTCP(0x711dd220, 0x3be7ca1a),
WTCP(0x7106430e, 0x3c143130), WTCP(0x70eea28e, 0x3c408f03),
WTCP(0x70d6f0a4, 0x3c6ce38a), WTCP(0x70bf2d53, 0x3c992ec0),
WTCP(0x70a7589f, 0x3cc5709e), WTCP(0x708f728b, 0x3cf1a91c),
WTCP(0x70777b1c, 0x3d1dd835), WTCP(0x705f7255, 0x3d49fde1),
WTCP(0x70475839, 0x3d761a19), WTCP(0x702f2ccd, 0x3da22cd7),
WTCP(0x7016f014, 0x3dce3614), WTCP(0x6ffea212, 0x3dfa35c8),
WTCP(0x6fe642ca, 0x3e262bee), WTCP(0x6fcdd241, 0x3e52187f),
WTCP(0x6fb5507a, 0x3e7dfb73), WTCP(0x6f9cbd79, 0x3ea9d4c3),
WTCP(0x6f841942, 0x3ed5a46b), WTCP(0x6f6b63d8, 0x3f016a61),
WTCP(0x6f529d40, 0x3f2d26a0), WTCP(0x6f39c57d, 0x3f58d921),
WTCP(0x6f20dc92, 0x3f8481dd), WTCP(0x6f07e285, 0x3fb020ce),
WTCP(0x6eeed758, 0x3fdbb5ec), WTCP(0x6ed5bb10, 0x40074132),
WTCP(0x6ebc8db0, 0x4032c297), WTCP(0x6ea34f3d, 0x405e3a16),
WTCP(0x6e89ffb9, 0x4089a7a8), WTCP(0x6e709f2a, 0x40b50b46),
WTCP(0x6e572d93, 0x40e064ea), WTCP(0x6e3daaf8, 0x410bb48c),
WTCP(0x6e24175c, 0x4136fa27), WTCP(0x6e0a72c5, 0x416235b2),
WTCP(0x6df0bd35, 0x418d6729), WTCP(0x6dd6f6b1, 0x41b88e84),
WTCP(0x6dbd1f3c, 0x41e3abbc), WTCP(0x6da336dc, 0x420ebecb),
WTCP(0x6d893d93, 0x4239c7aa), WTCP(0x6d6f3365, 0x4264c653),
WTCP(0x6d551858, 0x428fbabe), WTCP(0x6d3aec6e, 0x42baa4e6),
WTCP(0x6d20afac, 0x42e584c3), WTCP(0x6d066215, 0x43105a50),
WTCP(0x6cec03af, 0x433b2585), WTCP(0x6cd1947c, 0x4365e65b),
WTCP(0x6cb71482, 0x43909ccd), WTCP(0x6c9c83c3, 0x43bb48d4),
WTCP(0x6c81e245, 0x43e5ea68), WTCP(0x6c67300b, 0x44108184),
WTCP(0x6c4c6d1a, 0x443b0e21), WTCP(0x6c319975, 0x44659039),
WTCP(0x6c16b521, 0x449007c4), WTCP(0x6bfbc021, 0x44ba74bd),
WTCP(0x6be0ba7b, 0x44e4d71c), WTCP(0x6bc5a431, 0x450f2edb),
WTCP(0x6baa7d49, 0x45397bf4), WTCP(0x6b8f45c7, 0x4563be60),
WTCP(0x6b73fdae, 0x458df619), WTCP(0x6b58a503, 0x45b82318),
WTCP(0x6b3d3bcb, 0x45e24556), WTCP(0x6b21c208, 0x460c5cce),
WTCP(0x6b0637c1, 0x46366978), WTCP(0x6aea9cf8, 0x46606b4e),
WTCP(0x6acef1b2, 0x468a624a), WTCP(0x6ab335f4, 0x46b44e65),
WTCP(0x6a9769c1, 0x46de2f99), WTCP(0x6a7b8d1e, 0x470805df),
WTCP(0x6a5fa010, 0x4731d131), WTCP(0x6a43a29a, 0x475b9188),
WTCP(0x6a2794c1, 0x478546de), WTCP(0x6a0b7689, 0x47aef12c),
WTCP(0x69ef47f6, 0x47d8906d), WTCP(0x69d3090e, 0x48022499),
WTCP(0x69b6b9d3, 0x482badab), WTCP(0x699a5a4c, 0x48552b9b),
WTCP(0x697dea7b, 0x487e9e64), WTCP(0x69616a65, 0x48a805ff),
WTCP(0x6944da10, 0x48d16265), WTCP(0x6928397e, 0x48fab391),
WTCP(0x690b88b5, 0x4923f97b), WTCP(0x68eec7b9, 0x494d341e),
WTCP(0x68d1f68f, 0x49766373), WTCP(0x68b5153a, 0x499f8774),
WTCP(0x689823bf, 0x49c8a01b), WTCP(0x687b2224, 0x49f1ad61),
WTCP(0x685e106c, 0x4a1aaf3f), WTCP(0x6840ee9b, 0x4a43a5b0),
WTCP(0x6823bcb7, 0x4a6c90ad), WTCP(0x68067ac3, 0x4a957030),
WTCP(0x67e928c5, 0x4abe4433), WTCP(0x67cbc6c0, 0x4ae70caf),
WTCP(0x67ae54ba, 0x4b0fc99d), WTCP(0x6790d2b6, 0x4b387af9),
WTCP(0x677340ba, 0x4b6120bb), WTCP(0x67559eca, 0x4b89badd),
WTCP(0x6737ecea, 0x4bb24958), WTCP(0x671a2b20, 0x4bdacc28),
WTCP(0x66fc596f, 0x4c034345), WTCP(0x66de77dc, 0x4c2baea9),
WTCP(0x66c0866d, 0x4c540e4e), WTCP(0x66a28524, 0x4c7c622d),
WTCP(0x66847408, 0x4ca4aa41), WTCP(0x6666531d, 0x4ccce684),
WTCP(0x66482267, 0x4cf516ee), WTCP(0x6629e1ec, 0x4d1d3b7a),
WTCP(0x660b91af, 0x4d455422), WTCP(0x65ed31b5, 0x4d6d60df),
WTCP(0x65cec204, 0x4d9561ac), WTCP(0x65b0429f, 0x4dbd5682),
WTCP(0x6591b38c, 0x4de53f5a), WTCP(0x657314cf, 0x4e0d1c30),
WTCP(0x6554666d, 0x4e34ecfc), WTCP(0x6535a86b, 0x4e5cb1b9),
WTCP(0x6516dacd, 0x4e846a60), WTCP(0x64f7fd98, 0x4eac16eb),
WTCP(0x64d910d1, 0x4ed3b755), WTCP(0x64ba147d, 0x4efb4b96),
WTCP(0x649b08a0, 0x4f22d3aa), WTCP(0x647bed3f, 0x4f4a4f89),
WTCP(0x645cc260, 0x4f71bf2e), WTCP(0x643d8806, 0x4f992293),
WTCP(0x641e3e38, 0x4fc079b1), WTCP(0x63fee4f8, 0x4fe7c483),
WTCP(0x63df7c4d, 0x500f0302), WTCP(0x63c0043b, 0x50363529),
WTCP(0x63a07cc7, 0x505d5af1), WTCP(0x6380e5f6, 0x50847454),
WTCP(0x63613fcd, 0x50ab814d), WTCP(0x63418a50, 0x50d281d5),
WTCP(0x6321c585, 0x50f975e6), WTCP(0x6301f171, 0x51205d7b),
WTCP(0x62e20e17, 0x5147388c), WTCP(0x62c21b7e, 0x516e0715),
WTCP(0x62a219aa, 0x5194c910), WTCP(0x628208a1, 0x51bb7e75),
WTCP(0x6261e866, 0x51e22740), WTCP(0x6241b8ff, 0x5208c36a),
WTCP(0x62217a72, 0x522f52ee), WTCP(0x62012cc2, 0x5255d5c5),
WTCP(0x61e0cff5, 0x527c4bea), WTCP(0x61c06410, 0x52a2b556),
WTCP(0x619fe918, 0x52c91204), WTCP(0x617f5f12, 0x52ef61ee),
WTCP(0x615ec603, 0x5315a50e), WTCP(0x613e1df0, 0x533bdb5d),
WTCP(0x611d66de, 0x536204d7), WTCP(0x60fca0d2, 0x53882175),
WTCP(0x60dbcbd1, 0x53ae3131), WTCP(0x60bae7e1, 0x53d43406),
WTCP(0x6099f505, 0x53fa29ed), WTCP(0x6078f344, 0x542012e1),
WTCP(0x6057e2a2, 0x5445eedb), WTCP(0x6036c325, 0x546bbdd7),
WTCP(0x601594d1, 0x54917fce), WTCP(0x5ff457ad, 0x54b734ba),
WTCP(0x5fd30bbc, 0x54dcdc96), WTCP(0x5fb1b104, 0x5502775c),
WTCP(0x5f90478a, 0x55280505), WTCP(0x5f6ecf53, 0x554d858d),
WTCP(0x5f4d4865, 0x5572f8ed), WTCP(0x5f2bb2c5, 0x55985f20),
WTCP(0x5f0a0e77, 0x55bdb81f), WTCP(0x5ee85b82, 0x55e303e6),
WTCP(0x5ec699e9, 0x5608426e), WTCP(0x5ea4c9b3, 0x562d73b2),
WTCP(0x5e82eae5, 0x565297ab), WTCP(0x5e60fd84, 0x5677ae54),
WTCP(0x5e3f0194, 0x569cb7a8), WTCP(0x5e1cf71c, 0x56c1b3a1),
WTCP(0x5dfade20, 0x56e6a239), WTCP(0x5dd8b6a7, 0x570b8369),
WTCP(0x5db680b4, 0x5730572e), WTCP(0x5d943c4e, 0x57551d80),
WTCP(0x5d71e979, 0x5779d65b), WTCP(0x5d4f883b, 0x579e81b8),
WTCP(0x5d2d189a, 0x57c31f92), WTCP(0x5d0a9a9a, 0x57e7afe4),
WTCP(0x5ce80e41, 0x580c32a7), WTCP(0x5cc57394, 0x5830a7d6),
WTCP(0x5ca2ca99, 0x58550f6c), WTCP(0x5c801354, 0x58796962),
WTCP(0x5c5d4dcc, 0x589db5b3), WTCP(0x5c3a7a05, 0x58c1f45b),
WTCP(0x5c179806, 0x58e62552), WTCP(0x5bf4a7d2, 0x590a4893),
WTCP(0x5bd1a971, 0x592e5e19), WTCP(0x5bae9ce7, 0x595265df),
WTCP(0x5b8b8239, 0x59765fde), WTCP(0x5b68596d, 0x599a4c12),
WTCP(0x5b452288, 0x59be2a74), WTCP(0x5b21dd90, 0x59e1faff),
WTCP(0x5afe8a8b, 0x5a05bdae), WTCP(0x5adb297d, 0x5a29727b),
WTCP(0x5ab7ba6c, 0x5a4d1960), WTCP(0x5a943d5e, 0x5a70b258),
};
RAM_ALIGN
LNK_SECTION_CONSTDATA
const FIXP_WTP KBDWindow96[] = {
WTCP(0x7ffffffd, 0x0001a838), WTCP(0x7fffffe2, 0x00056e83),
WTCP(0x7fffff79, 0x000b9fda), WTCP(0x7ffffe45, 0x00150e8e),
WTCP(0x7ffffb4d, 0x0022aeeb), WTCP(0x7ffff4c6, 0x00359b36),
WTCP(0x7fffe792, 0x004f14ff), WTCP(0x7fffce8b, 0x0070858c),
WTCP(0x7fffa18f, 0x009b7d75), WTCP(0x7fff5439, 0x00d1b353),
WTCP(0x7ffed442, 0x0115018f), WTCP(0x7ffe0775, 0x01676335),
WTCP(0x7ffcc937, 0x01caefcb), WTCP(0x7ffae79f, 0x0241d62e),
WTCP(0x7ff82019, 0x02ce567f), WTCP(0x7ff41ba4, 0x0372bb25),
WTCP(0x7fee6ac3, 0x043150fc), WTCP(0x7fe68129, 0x050c5ec8),
WTCP(0x7fdbb164, 0x06061c0f), WTCP(0x7fcd2894, 0x0720a779),
WTCP(0x7fb9ea80, 0x085dfce2), WTCP(0x7fa0ce2e, 0x09bfeb4d),
WTCP(0x7f807b45, 0x0b480ae2), WTCP(0x7f576880, 0x0cf7b339),
WTCP(0x7f23db4e, 0x0ecff212), WTCP(0x7ee3e8ee, 0x10d182c0),
WTCP(0x7e95791f, 0x12fcc670), WTCP(0x7e364a74, 0x1551bd88),
WTCP(0x7dc3f864, 0x17d00238), WTCP(0x7d3c02fd, 0x1a76c47e),
WTCP(0x7c9bd82a, 0x1d44c7ad), WTCP(0x7be0de56, 0x203861a1),
WTCP(0x7b08803d, 0x234f7ba6), WTCP(0x7a103993, 0x26879530),
WTCP(0x78f5a442, 0x29ddc854), WTCP(0x77b685de, 0x2d4ed00f),
WTCP(0x7650dcf5, 0x30d7103d), WTCP(0x74c2ede4, 0x34729f2d),
WTCP(0x730b4edb, 0x381d50ad), WTCP(0x7128f2c1, 0x3bd2c273),
WTCP(0x6f1b32a9, 0x3f8e698f), WTCP(0x6ce1d5a0, 0x434ba0d6),
WTCP(0x6a7d16a3, 0x4705b7e5), WTCP(0x67eda890, 0x4ab80288),
WTCP(0x6534b7f8, 0x4e5de842), WTCP(0x6253eacd, 0x51f2f39a),
WTCP(0x5f4d5de1, 0x5572e0f7), WTCP(0x5c23a04a, 0x58d9acb9),
};
RAM_ALIGN
LNK_SECTION_CONSTDATA
const FIXP_WTP KBDWindow120[] = {
WTCP(0x7ffffffe, 0x00017b6f), WTCP(0x7fffffef, 0x00042d2f),
WTCP(0x7fffffbb, 0x000849d0), WTCP(0x7fffff36, 0x000e3494),
WTCP(0x7ffffe0c, 0x00165efd), WTCP(0x7ffffbac, 0x002149be),
WTCP(0x7ffff72e, 0x002f854c), WTCP(0x7fffef24, 0x0041b235),
WTCP(0x7fffe167, 0x0058814f), WTCP(0x7fffcacd, 0x0074b3af),
WTCP(0x7fffa6d0, 0x00971a67), WTCP(0x7fff6f1e, 0x00c0960e),
WTCP(0x7fff1b12, 0x00f21602), WTCP(0x7ffe9f0b, 0x012c9775),
WTCP(0x7ffdebb2, 0x01712428), WTCP(0x7ffced1b, 0x01c0d0f7),
WTCP(0x7ffb89c2, 0x021cbc12), WTCP(0x7ff9a17c, 0x02860b05),
WTCP(0x7ff70c39, 0x02fde875), WTCP(0x7ff398bc, 0x038581b3),
WTCP(0x7fef0b3b, 0x041e040c), WTCP(0x7fe91bf3, 0x04c899f4),
WTCP(0x7fe175ba, 0x05866803), WTCP(0x7fd7b493, 0x065889d5),
WTCP(0x7fcb6459, 0x07400ed4), WTCP(0x7fbbff82, 0x083df6e9),
WTCP(0x7fa8ee09, 0x09532f37), WTCP(0x7f91849a, 0x0a808ed1),
WTCP(0x7f7503f2, 0x0bc6d381), WTCP(0x7f52989a, 0x0d269eb0),
WTCP(0x7f295af4, 0x0ea07270), WTCP(0x7ef84fb6, 0x1034aeb6),
WTCP(0x7ebe68c5, 0x11e38ed2), WTCP(0x7e7a8686, 0x13ad2733),
WTCP(0x7e2b79a3, 0x1591636d), WTCP(0x7dd0053c, 0x179004a7),
WTCP(0x7d66e18b, 0x19a8a05f), WTCP(0x7ceebef0, 0x1bda9fa2),
WTCP(0x7c664953, 0x1e253ea1), WTCP(0x7bcc2be8, 0x20878cce),
WTCP(0x7b1f1526, 0x23006d5d), WTCP(0x7a5dbb01, 0x258e9848),
WTCP(0x7986df3e, 0x28309bc6), WTCP(0x789953e0, 0x2ae4de3e),
WTCP(0x7793ff88, 0x2da9a0a8), WTCP(0x7675e1cc, 0x307d0163),
WTCP(0x753e1763, 0x335cff72), WTCP(0x73ebde10, 0x36477e1f),
WTCP(0x727e984e, 0x393a48f1), WTCP(0x70f5d09b, 0x3c3317f9),
WTCP(0x6f513c60, 0x3f2f945c), WTCP(0x6d90be61, 0x422d5d18),
WTCP(0x6bb468b1, 0x452a0bf3), WTCP(0x69bc7e1e, 0x48233a81),
WTCP(0x67a97317, 0x4b16873e), WTCP(0x657bedfa, 0x4e019a9d),
WTCP(0x6334c6d2, 0x50e22c0b), WTCP(0x60d50689, 0x53b606cb),
WTCP(0x5e5de588, 0x567b0ea7), WTCP(0x5bd0c9c6, 0x592f4460),
};
RAM_ALIGN
LNK_SECTION_CONSTDATA
const FIXP_WTP KBDWindow128[] = {
WTCP(0x7ffffffe, 0x00016f63), WTCP(0x7ffffff1, 0x0003e382),
WTCP(0x7fffffc7, 0x00078f64), WTCP(0x7fffff5d, 0x000cc323),
WTCP(0x7ffffe76, 0x0013d9ed), WTCP(0x7ffffcaa, 0x001d3a9d),
WTCP(0x7ffff953, 0x0029581f), WTCP(0x7ffff372, 0x0038b1bd),
WTCP(0x7fffe98b, 0x004bd34d), WTCP(0x7fffd975, 0x00635538),
WTCP(0x7fffc024, 0x007fdc64), WTCP(0x7fff995b, 0x00a219f1),
WTCP(0x7fff5f5b, 0x00cacad0), WTCP(0x7fff0a75, 0x00fab72d),
WTCP(0x7ffe9091, 0x0132b1af), WTCP(0x7ffde49e, 0x01739689),
WTCP(0x7ffcf5ef, 0x01be4a63), WTCP(0x7ffbaf84, 0x0213b910),
WTCP(0x7ff9f73a, 0x0274d41e), WTCP(0x7ff7acf1, 0x02e2913a),
WTCP(0x7ff4a99a, 0x035de86c), WTCP(0x7ff0be3d, 0x03e7d233),
WTCP(0x7febb2f1, 0x0481457c), WTCP(0x7fe545d4, 0x052b357c),
WTCP(0x7fdd2a02, 0x05e68f77), WTCP(0x7fd30695, 0x06b4386f),
WTCP(0x7fc675b4, 0x07950acb), WTCP(0x7fb703be, 0x0889d3ef),
WTCP(0x7fa42e89, 0x099351e0), WTCP(0x7f8d64d8, 0x0ab230e0),
WTCP(0x7f7205f8, 0x0be70923), WTCP(0x7f516195, 0x0d325c93),
WTCP(0x7f2ab7d0, 0x0e9494ae), WTCP(0x7efd3997, 0x100e0085),
WTCP(0x7ec8094a, 0x119ed2ef), WTCP(0x7e8a3ba7, 0x134720d8),
WTCP(0x7e42d906, 0x1506dfdc), WTCP(0x7df0dee4, 0x16dde50b),
WTCP(0x7d9341b4, 0x18cbe3f7), WTCP(0x7d28ef02, 0x1ad06e07),
WTCP(0x7cb0cfcc, 0x1ceaf215), WTCP(0x7c29cb20, 0x1f1abc4f),
WTCP(0x7b92c8eb, 0x215ef677), WTCP(0x7aeab4ec, 0x23b6a867),
WTCP(0x7a3081d0, 0x2620b8ec), WTCP(0x79632c5a, 0x289beef5),
WTCP(0x7881be95, 0x2b26f30b), WTCP(0x778b5304, 0x2dc0511f),
WTCP(0x767f17c0, 0x30667aa2), WTCP(0x755c5178, 0x3317c8dd),
WTCP(0x74225e50, 0x35d27f98), WTCP(0x72d0b887, 0x3894cff3),
WTCP(0x7166f8e7, 0x3b5cdb7b), WTCP(0x6fe4d8e8, 0x3e28b770),
WTCP(0x6e4a3491, 0x40f6702a), WTCP(0x6c970bfc, 0x43c40caa),
WTCP(0x6acb8483, 0x468f9231), WTCP(0x68e7e994, 0x495707f5),
WTCP(0x66ecad1c, 0x4c187ac7), WTCP(0x64da6797, 0x4ed200c5),
WTCP(0x62b1d7b7, 0x5181bcea), WTCP(0x6073e1ae, 0x5425e28e),
WTCP(0x5e218e16, 0x56bcb8c2), WTCP(0x5bbc0875, 0x59449d76),
};
RAM_ALIGN
LNK_SECTION_CONSTDATA
const FIXP_WTP KBDWindow256[] = {
WTCP(0x7fffffff, 0x000103c8), WTCP(0x7ffffffc, 0x000203ad),
WTCP(0x7ffffff5, 0x0003410a), WTCP(0x7fffffe9, 0x0004c6ce),
WTCP(0x7fffffd4, 0x00069ee0), WTCP(0x7fffffb2, 0x0008d376),
WTCP(0x7fffff7d, 0x000b6f5a), WTCP(0x7fffff2e, 0x000e7dfd),
WTCP(0x7ffffeba, 0x00120b83), WTCP(0x7ffffe16, 0x001624cd),
WTCP(0x7ffffd30, 0x001ad778), WTCP(0x7ffffbf3, 0x002031e2),
WTCP(0x7ffffa48, 0x00264330), WTCP(0x7ffff80d, 0x002d1b4b),
WTCP(0x7ffff51d, 0x0034cae6), WTCP(0x7ffff147, 0x003d637c),
WTCP(0x7fffec54, 0x0046f751), WTCP(0x7fffe5fe, 0x00519974),
WTCP(0x7fffddf3, 0x005d5dba), WTCP(0x7fffd3d2, 0x006a58c1),
WTCP(0x7fffc72a, 0x00789feb), WTCP(0x7fffb772, 0x0088495d),
WTCP(0x7fffa40e, 0x00996bfb), WTCP(0x7fff8c46, 0x00ac1f63),
WTCP(0x7fff6f46, 0x00c07bec), WTCP(0x7fff4c19, 0x00d69a9b),
WTCP(0x7fff21a6, 0x00ee9523), WTCP(0x7ffeeeab, 0x010885d9),
WTCP(0x7ffeb1b8, 0x012487b1), WTCP(0x7ffe692f, 0x0142b631),
WTCP(0x7ffe1335, 0x01632d6f), WTCP(0x7ffdadb8, 0x01860a00),
WTCP(0x7ffd3661, 0x01ab68f3), WTCP(0x7ffcaa91, 0x01d367c5),
WTCP(0x7ffc075b, 0x01fe2453), WTCP(0x7ffb497e, 0x022bbcd0),
WTCP(0x7ffa6d59, 0x025c4fba), WTCP(0x7ff96eeb, 0x028ffbc7),
WTCP(0x7ff849c6, 0x02c6dfdb), WTCP(0x7ff6f90b, 0x03011afc),
WTCP(0x7ff57760, 0x033ecc3a), WTCP(0x7ff3bee7, 0x038012a8),
WTCP(0x7ff1c939, 0x03c50d47), WTCP(0x7fef8f5a, 0x040ddaf6),
WTCP(0x7fed09b4, 0x045a9a64), WTCP(0x7fea300e, 0x04ab69f9),
WTCP(0x7fe6f980, 0x050067c7), WTCP(0x7fe35c70, 0x0559b17b),
WTCP(0x7fdf4e88, 0x05b76443), WTCP(0x7fdac4ad, 0x06199cc4),
WTCP(0x7fd5b2f8, 0x068076fe), WTCP(0x7fd00caf, 0x06ec0e41),
WTCP(0x7fc9c441, 0x075c7d16), WTCP(0x7fc2cb3b, 0x07d1dd2c),
WTCP(0x7fbb1242, 0x084c4745), WTCP(0x7fb28915, 0x08cbd323),
WTCP(0x7fa91e7e, 0x09509778), WTCP(0x7f9ec059, 0x09daa9cc),
WTCP(0x7f935b87, 0x0a6a1e74), WTCP(0x7f86dbf2, 0x0aff0877),
WTCP(0x7f792c8a, 0x0b997983), WTCP(0x7f6a3746, 0x0c3981d6),
WTCP(0x7f59e520, 0x0cdf3030), WTCP(0x7f481e1c, 0x0d8a91c3),
WTCP(0x7f34c949, 0x0e3bb222), WTCP(0x7f1fccc3, 0x0ef29b30),
WTCP(0x7f090dbc, 0x0faf5513), WTCP(0x7ef0707d, 0x1071e629),
WTCP(0x7ed5d872, 0x113a52f4), WTCP(0x7eb92831, 0x12089e14),
WTCP(0x7e9a4183, 0x12dcc836), WTCP(0x7e790571, 0x13b6d010),
WTCP(0x7e55544e, 0x1496b24f), WTCP(0x7e2f0dc8, 0x157c6998),
WTCP(0x7e0610f1, 0x1667ee77), WTCP(0x7dda3c54, 0x17593760),
WTCP(0x7dab6e06, 0x185038a3), WTCP(0x7d7983b3, 0x194ce46e),
WTCP(0x7d445ab5, 0x1a4f2ac4), WTCP(0x7d0bd028, 0x1b56f981),
WTCP(0x7ccfc0fd, 0x1c643c54), WTCP(0x7c900a11, 0x1d76dcc2),
WTCP(0x7c4c8844, 0x1e8ec227), WTCP(0x7c05188d, 0x1fabd1bb),
WTCP(0x7bb99817, 0x20cdee92), WTCP(0x7b69e455, 0x21f4f9a6),
WTCP(0x7b15db1a, 0x2320d1dc), WTCP(0x7abd5ab8, 0x2451540c),
WTCP(0x7a604213, 0x25865b09), WTCP(0x79fe70bf, 0x26bfbfaf),
WTCP(0x7997c716, 0x27fd58ed), WTCP(0x792c2654, 0x293efbd0),
WTCP(0x78bb70b0, 0x2a847b97), WTCP(0x78458976, 0x2bcda9bb),
WTCP(0x77ca551d, 0x2d1a5608), WTCP(0x7749b965, 0x2e6a4ea6),
WTCP(0x76c39d68, 0x2fbd6036), WTCP(0x7637e9b8, 0x311355dc),
WTCP(0x75a68873, 0x326bf95a), WTCP(0x750f6559, 0x33c71326),
WTCP(0x74726de1, 0x35246a7e), WTCP(0x73cf914f, 0x3683c582),
WTCP(0x7326c0c8, 0x37e4e94b), WTCP(0x7277ef5f, 0x39479a08),
WTCP(0x71c3122f, 0x3aab9b14), WTCP(0x71082063, 0x3c10af11),
WTCP(0x7047134a, 0x3d769807), WTCP(0x6f7fe661, 0x3edd177c),
WTCP(0x6eb29763, 0x4043ee92), WTCP(0x6ddf2651, 0x41aade26),
WTCP(0x6d05957c, 0x4311a6e8), WTCP(0x6c25e98f, 0x4478097b),
WTCP(0x6b402991, 0x45ddc693), WTCP(0x6a545ef0, 0x47429f13),
WTCP(0x6962957f, 0x48a65427), WTCP(0x686adb7c, 0x4a08a764),
WTCP(0x676d418d, 0x4b695ae8), WTCP(0x6669dac2, 0x4cc83171),
WTCP(0x6560bc90, 0x4e24ee7d), WTCP(0x6451fecf, 0x4f7f5668),
WTCP(0x633dbbb1, 0x50d72e85), WTCP(0x62240fbd, 0x522c3d3b),
WTCP(0x610519c7, 0x537e4a1f), WTCP(0x5fe0fae3, 0x54cd1e10),
WTCP(0x5eb7d65c, 0x5618834c), WTCP(0x5d89d1a5, 0x57604590),
WTCP(0x5c57144b, 0x58a43227), WTCP(0x5b1fc7e6, 0x59e41808),
};
RAM_ALIGN
LNK_SECTION_CONSTDATA
const FIXP_WTP KBDWindow768[] = {
WTCP(0x7fffff85, 0x000b11d9), WTCP(0x7ffffef0, 0x00107aa9),
WTCP(0x7ffffe3e, 0x0015351c), WTCP(0x7ffffd6c, 0x0019b0a1),
WTCP(0x7ffffc77, 0x001e1656), WTCP(0x7ffffb5b, 0x00227a80),
WTCP(0x7ffffa16, 0x0026e8d3), WTCP(0x7ffff8a4, 0x002b68c9),
WTCP(0x7ffff700, 0x002fff8a), WTCP(0x7ffff528, 0x0034b0d9),
WTCP(0x7ffff316, 0x00397f9c), WTCP(0x7ffff0c6, 0x003e6e22),
WTCP(0x7fffee35, 0x00437e53), WTCP(0x7fffeb5b, 0x0048b1d0),
WTCP(0x7fffe836, 0x004e0a05), WTCP(0x7fffe4be, 0x00538837),
WTCP(0x7fffe0ef, 0x00592d8e), WTCP(0x7fffdcc3, 0x005efb1a),
WTCP(0x7fffd832, 0x0064f1da), WTCP(0x7fffd337, 0x006b12c1),
WTCP(0x7fffcdcb, 0x00715eb4), WTCP(0x7fffc7e7, 0x0077d692),
WTCP(0x7fffc182, 0x007e7b30), WTCP(0x7fffba96, 0x00854d61),
WTCP(0x7fffb31b, 0x008c4df0), WTCP(0x7fffab06, 0x00937da6),
WTCP(0x7fffa251, 0x009add48), WTCP(0x7fff98f1, 0x00a26d98),
WTCP(0x7fff8edd, 0x00aa2f57), WTCP(0x7fff840b, 0x00b22343),
WTCP(0x7fff7870, 0x00ba4a19), WTCP(0x7fff6c02, 0x00c2a495),
WTCP(0x7fff5eb5, 0x00cb3371), WTCP(0x7fff507e, 0x00d3f767),
WTCP(0x7fff4150, 0x00dcf130), WTCP(0x7fff311f, 0x00e62183),
WTCP(0x7fff1fde, 0x00ef8919), WTCP(0x7fff0d7f, 0x00f928a7),
WTCP(0x7ffef9f4, 0x010300e5), WTCP(0x7ffee52f, 0x010d1288),
WTCP(0x7ffecf20, 0x01175e47), WTCP(0x7ffeb7b8, 0x0121e4d6),
WTCP(0x7ffe9ee6, 0x012ca6eb), WTCP(0x7ffe849b, 0x0137a53b),
WTCP(0x7ffe68c4, 0x0142e07a), WTCP(0x7ffe4b50, 0x014e595c),
WTCP(0x7ffe2c2c, 0x015a1095), WTCP(0x7ffe0b45, 0x016606da),
WTCP(0x7ffde888, 0x01723cde), WTCP(0x7ffdc3df, 0x017eb353),
WTCP(0x7ffd9d37, 0x018b6aed), WTCP(0x7ffd7479, 0x0198645f),
WTCP(0x7ffd4990, 0x01a5a05b), WTCP(0x7ffd1c63, 0x01b31f92),
WTCP(0x7ffcecdc, 0x01c0e2b8), WTCP(0x7ffcbae2, 0x01ceea7d),
WTCP(0x7ffc865c, 0x01dd3793), WTCP(0x7ffc4f2f, 0x01ebcaaa),
WTCP(0x7ffc1542, 0x01faa472), WTCP(0x7ffbd879, 0x0209c59c),
WTCP(0x7ffb98b7, 0x02192ed7), WTCP(0x7ffb55e0, 0x0228e0d2),
WTCP(0x7ffb0fd6, 0x0238dc3c), WTCP(0x7ffac679, 0x024921c3),
WTCP(0x7ffa79ac, 0x0259b215), WTCP(0x7ffa294d, 0x026a8dde),
WTCP(0x7ff9d53b, 0x027bb5cc), WTCP(0x7ff97d54, 0x028d2a8a),
WTCP(0x7ff92175, 0x029eecc3), WTCP(0x7ff8c17a, 0x02b0fd23),
WTCP(0x7ff85d3f, 0x02c35c53), WTCP(0x7ff7f49d, 0x02d60afd),
WTCP(0x7ff7876e, 0x02e909ca), WTCP(0x7ff7158b, 0x02fc5960),
WTCP(0x7ff69eca, 0x030ffa69), WTCP(0x7ff62303, 0x0323ed89),
WTCP(0x7ff5a20a, 0x03383367), WTCP(0x7ff51bb3, 0x034ccca7),
WTCP(0x7ff48fd3, 0x0361b9ed), WTCP(0x7ff3fe3c, 0x0376fbdd),
WTCP(0x7ff366be, 0x038c9317), WTCP(0x7ff2c929, 0x03a2803e),
WTCP(0x7ff2254e, 0x03b8c3f2), WTCP(0x7ff17afa, 0x03cf5ed1),
WTCP(0x7ff0c9f9, 0x03e6517a), WTCP(0x7ff01218, 0x03fd9c8a),
WTCP(0x7fef5321, 0x0415409c), WTCP(0x7fee8cde, 0x042d3e4d),
WTCP(0x7fedbf17, 0x04459634), WTCP(0x7fece993, 0x045e48ec),
WTCP(0x7fec0c18, 0x0477570a), WTCP(0x7feb266a, 0x0490c127),
WTCP(0x7fea384e, 0x04aa87d5), WTCP(0x7fe94186, 0x04c4abaa),
WTCP(0x7fe841d3, 0x04df2d37), WTCP(0x7fe738f4, 0x04fa0d0d),
WTCP(0x7fe626a9, 0x05154bbc), WTCP(0x7fe50aaf, 0x0530e9d3),
WTCP(0x7fe3e4c1, 0x054ce7dd), WTCP(0x7fe2b49b, 0x05694667),
WTCP(0x7fe179f6, 0x058605fa), WTCP(0x7fe0348b, 0x05a3271e),
WTCP(0x7fdee410, 0x05c0aa5c), WTCP(0x7fdd883b, 0x05de9038),
WTCP(0x7fdc20c1, 0x05fcd935), WTCP(0x7fdaad53, 0x061b85d6),
WTCP(0x7fd92da5, 0x063a969c), WTCP(0x7fd7a166, 0x065a0c06),
WTCP(0x7fd60844, 0x0679e690), WTCP(0x7fd461ee, 0x069a26b6),
WTCP(0x7fd2ae10, 0x06baccf2), WTCP(0x7fd0ec55, 0x06dbd9bd),
WTCP(0x7fcf1c65, 0x06fd4d8c), WTCP(0x7fcd3de9, 0x071f28d3),
WTCP(0x7fcb5088, 0x07416c06), WTCP(0x7fc953e6, 0x07641794),
WTCP(0x7fc747a8, 0x07872bee), WTCP(0x7fc52b70, 0x07aaa97f),
WTCP(0x7fc2fedf, 0x07ce90b4), WTCP(0x7fc0c195, 0x07f2e1f4),
WTCP(0x7fbe732f, 0x08179da7), WTCP(0x7fbc134b, 0x083cc431),
WTCP(0x7fb9a183, 0x086255f7), WTCP(0x7fb71d72, 0x08885359),
WTCP(0x7fb486af, 0x08aebcb5), WTCP(0x7fb1dcd3, 0x08d59269),
WTCP(0x7faf1f72, 0x08fcd4cf), WTCP(0x7fac4e21, 0x09248440),
WTCP(0x7fa96873, 0x094ca111), WTCP(0x7fa66df8, 0x09752b98),
WTCP(0x7fa35e40, 0x099e2425), WTCP(0x7fa038db, 0x09c78b09),
WTCP(0x7f9cfd54, 0x09f16090), WTCP(0x7f99ab38, 0x0a1ba507),
WTCP(0x7f964210, 0x0a4658b6), WTCP(0x7f92c165, 0x0a717be2),
WTCP(0x7f8f28bf, 0x0a9d0ed1), WTCP(0x7f8b77a4, 0x0ac911c4),
WTCP(0x7f87ad97, 0x0af584fb), WTCP(0x7f83ca1d, 0x0b2268b2),
WTCP(0x7f7fccb5, 0x0b4fbd23), WTCP(0x7f7bb4e2, 0x0b7d8288),
WTCP(0x7f778221, 0x0babb915), WTCP(0x7f7333f1, 0x0bda60fd),
WTCP(0x7f6ec9cd, 0x0c097a72), WTCP(0x7f6a4330, 0x0c3905a1),
WTCP(0x7f659f94, 0x0c6902b6), WTCP(0x7f60de70, 0x0c9971d9),
WTCP(0x7f5bff3b, 0x0cca5331), WTCP(0x7f57016b, 0x0cfba6e3),
WTCP(0x7f51e474, 0x0d2d6d0e), WTCP(0x7f4ca7c8, 0x0d5fa5d2),
WTCP(0x7f474ad9, 0x0d92514a), WTCP(0x7f41cd17, 0x0dc56f90),
WTCP(0x7f3c2df1, 0x0df900bb), WTCP(0x7f366cd5, 0x0e2d04de),
WTCP(0x7f30892e, 0x0e617c0a), WTCP(0x7f2a8269, 0x0e96664e),
WTCP(0x7f2457ef, 0x0ecbc3b5), WTCP(0x7f1e0929, 0x0f019449),
WTCP(0x7f17957e, 0x0f37d80f), WTCP(0x7f10fc55, 0x0f6e8f0c),
WTCP(0x7f0a3d14, 0x0fa5b940), WTCP(0x7f03571d, 0x0fdd56a8),
WTCP(0x7efc49d4, 0x10156740), WTCP(0x7ef5149b, 0x104deb00),
WTCP(0x7eedb6d2, 0x1086e1dd), WTCP(0x7ee62fda, 0x10c04bca),
WTCP(0x7ede7f11, 0x10fa28b7), WTCP(0x7ed6a3d5, 0x11347890),
WTCP(0x7ece9d81, 0x116f3b3f), WTCP(0x7ec66b73, 0x11aa70ac),
WTCP(0x7ebe0d04, 0x11e618ba), WTCP(0x7eb5818d, 0x1222334c),
WTCP(0x7eacc869, 0x125ec03e), WTCP(0x7ea3e0ef, 0x129bbf6e),
WTCP(0x7e9aca75, 0x12d930b2), WTCP(0x7e918452, 0x131713e2),
WTCP(0x7e880ddb, 0x135568cf), WTCP(0x7e7e6665, 0x13942f49),
WTCP(0x7e748d43, 0x13d3671e), WTCP(0x7e6a81c8, 0x14131017),
WTCP(0x7e604347, 0x145329fa), WTCP(0x7e55d111, 0x1493b48c),
WTCP(0x7e4b2a76, 0x14d4af8e), WTCP(0x7e404ec8, 0x15161abe),
WTCP(0x7e353d55, 0x1557f5d7), WTCP(0x7e29f56c, 0x159a4090),
WTCP(0x7e1e765c, 0x15dcfaa0), WTCP(0x7e12bf72, 0x162023b7),
WTCP(0x7e06cffc, 0x1663bb86), WTCP(0x7dfaa746, 0x16a7c1b9),
WTCP(0x7dee449e, 0x16ec35f7), WTCP(0x7de1a74e, 0x173117e9),
WTCP(0x7dd4cea3, 0x17766731), WTCP(0x7dc7b9e7, 0x17bc236f),
WTCP(0x7dba6865, 0x18024c40), WTCP(0x7dacd968, 0x1848e13f),
WTCP(0x7d9f0c3a, 0x188fe204), WTCP(0x7d910025, 0x18d74e22),
WTCP(0x7d82b472, 0x191f252c), WTCP(0x7d74286c, 0x196766ae),
WTCP(0x7d655b5b, 0x19b01236), WTCP(0x7d564c8a, 0x19f9274b),
WTCP(0x7d46fb40, 0x1a42a574), WTCP(0x7d3766c8, 0x1a8c8c32),
WTCP(0x7d278e6a, 0x1ad6db06), WTCP(0x7d17716f, 0x1b21916c),
WTCP(0x7d070f22, 0x1b6caedf), WTCP(0x7cf666cb, 0x1bb832d5),
WTCP(0x7ce577b3, 0x1c041cc2), WTCP(0x7cd44124, 0x1c506c17),
WTCP(0x7cc2c269, 0x1c9d2044), WTCP(0x7cb0faca, 0x1cea38b2),
WTCP(0x7c9ee992, 0x1d37b4cc), WTCP(0x7c8c8e0c, 0x1d8593f5),
WTCP(0x7c79e782, 0x1dd3d592), WTCP(0x7c66f541, 0x1e227903),
WTCP(0x7c53b692, 0x1e717da3), WTCP(0x7c402ac3, 0x1ec0e2cf),
WTCP(0x7c2c5120, 0x1f10a7dc), WTCP(0x7c1828f6, 0x1f60cc21),
WTCP(0x7c03b193, 0x1fb14eef), WTCP(0x7beeea44, 0x20022f96),
WTCP(0x7bd9d259, 0x20536d61), WTCP(0x7bc46921, 0x20a5079a),
WTCP(0x7baeadec, 0x20f6fd8a), WTCP(0x7b98a00b, 0x21494e73),
WTCP(0x7b823ecf, 0x219bf998), WTCP(0x7b6b898b, 0x21eefe37),
WTCP(0x7b547f93, 0x22425b8d), WTCP(0x7b3d203a, 0x229610d4),
WTCP(0x7b256ad5, 0x22ea1d42), WTCP(0x7b0d5ebb, 0x233e800c),
WTCP(0x7af4fb42, 0x23933864), WTCP(0x7adc3fc2, 0x23e8457a),
WTCP(0x7ac32b95, 0x243da679), WTCP(0x7aa9be14, 0x24935a8d),
WTCP(0x7a8ff69a, 0x24e960dd), WTCP(0x7a75d485, 0x253fb88e),
WTCP(0x7a5b5731, 0x259660c3), WTCP(0x7a407dfe, 0x25ed589c),
WTCP(0x7a25484c, 0x26449f38), WTCP(0x7a09b57c, 0x269c33b1),
WTCP(0x79edc4f1, 0x26f41522), WTCP(0x79d1760e, 0x274c42a0),
WTCP(0x79b4c83b, 0x27a4bb40), WTCP(0x7997badd, 0x27fd7e15),
WTCP(0x797a4d5e, 0x28568a2f), WTCP(0x795c7f26, 0x28afde9a),
WTCP(0x793e4fa3, 0x29097a63), WTCP(0x791fbe40, 0x29635c92),
WTCP(0x7900ca6e, 0x29bd842e), WTCP(0x78e1739c, 0x2a17f03e),
WTCP(0x78c1b93d, 0x2a729fc2), WTCP(0x78a19ac4, 0x2acd91bc),
WTCP(0x788117a7, 0x2b28c52a), WTCP(0x78602f5e, 0x2b843909),
WTCP(0x783ee163, 0x2bdfec54), WTCP(0x781d2d2f, 0x2c3bde02),
WTCP(0x77fb1241, 0x2c980d0a), WTCP(0x77d89017, 0x2cf47862),
WTCP(0x77b5a632, 0x2d511efb), WTCP(0x77925416, 0x2dadffc6),
WTCP(0x776e9947, 0x2e0b19b3), WTCP(0x774a754d, 0x2e686bae),
WTCP(0x7725e7b0, 0x2ec5f4a4), WTCP(0x7700effd, 0x2f23b37d),
WTCP(0x76db8dbf, 0x2f81a721), WTCP(0x76b5c088, 0x2fdfce77),
WTCP(0x768f87e8, 0x303e2863), WTCP(0x7668e375, 0x309cb3c8),
WTCP(0x7641d2c4, 0x30fb6f88), WTCP(0x761a556e, 0x315a5a82),
WTCP(0x75f26b0e, 0x31b97394), WTCP(0x75ca1341, 0x3218b99c),
WTCP(0x75a14da8, 0x32782b74), WTCP(0x757819e4, 0x32d7c7f6),
WTCP(0x754e779a, 0x33378dfc), WTCP(0x75246671, 0x33977c5b),
WTCP(0x74f9e613, 0x33f791e9), WTCP(0x74cef62b, 0x3457cd7c),
WTCP(0x74a3966a, 0x34b82de6), WTCP(0x7477c67f, 0x3518b1f9),
WTCP(0x744b861e, 0x35795887), WTCP(0x741ed4ff, 0x35da205e),
WTCP(0x73f1b2da, 0x363b084e), WTCP(0x73c41f6b, 0x369c0f24),
WTCP(0x73961a71, 0x36fd33ac), WTCP(0x7367a3ac, 0x375e74b1),
WTCP(0x7338bae1, 0x37bfd0ff), WTCP(0x73095fd7, 0x3821475f),
WTCP(0x72d99257, 0x3882d699), WTCP(0x72a9522d, 0x38e47d75),
WTCP(0x72789f28, 0x39463aba), WTCP(0x7247791b, 0x39a80d2e),
WTCP(0x7215dfda, 0x3a09f397), WTCP(0x71e3d33d, 0x3a6becba),
WTCP(0x71b1531f, 0x3acdf75a), WTCP(0x717e5f5d, 0x3b30123b),
WTCP(0x714af7d7, 0x3b923c20), WTCP(0x71171c72, 0x3bf473cc),
WTCP(0x70e2cd14, 0x3c56b7ff), WTCP(0x70ae09a6, 0x3cb9077b),
WTCP(0x7078d215, 0x3d1b6101), WTCP(0x7043264f, 0x3d7dc353),
WTCP(0x700d0648, 0x3de02d2e), WTCP(0x6fd671f5, 0x3e429d55),
WTCP(0x6f9f694f, 0x3ea51285), WTCP(0x6f67ec52, 0x3f078b7f),
WTCP(0x6f2ffafb, 0x3f6a0701), WTCP(0x6ef7954e, 0x3fcc83ca),
WTCP(0x6ebebb4e, 0x402f009a), WTCP(0x6e856d05, 0x40917c2e),
WTCP(0x6e4baa7e, 0x40f3f546), WTCP(0x6e1173c6, 0x41566aa1),
WTCP(0x6dd6c8ef, 0x41b8dafc), WTCP(0x6d9baa0f, 0x421b4518),
WTCP(0x6d60173d, 0x427da7b1), WTCP(0x6d241094, 0x42e00189),
WTCP(0x6ce79632, 0x4342515e), WTCP(0x6caaa839, 0x43a495ef),
WTCP(0x6c6d46ce, 0x4406cdfd), WTCP(0x6c2f7218, 0x4468f848),
WTCP(0x6bf12a42, 0x44cb138f), WTCP(0x6bb26f7b, 0x452d1e94),
WTCP(0x6b7341f5, 0x458f1818), WTCP(0x6b33a1e3, 0x45f0fede),
WTCP(0x6af38f7e, 0x4652d1a6), WTCP(0x6ab30b01, 0x46b48f34),
WTCP(0x6a7214ab, 0x4716364c), WTCP(0x6a30acbd, 0x4777c5b2),
WTCP(0x69eed37c, 0x47d93c2a), WTCP(0x69ac8930, 0x483a987a),
WTCP(0x6969ce24, 0x489bd968), WTCP(0x6926a2a8, 0x48fcfdbb),
WTCP(0x68e3070c, 0x495e043b), WTCP(0x689efba7, 0x49beebb0),
WTCP(0x685a80cf, 0x4a1fb2e5), WTCP(0x681596e1, 0x4a8058a4),
WTCP(0x67d03e3b, 0x4ae0dbb8), WTCP(0x678a773f, 0x4b413aee),
WTCP(0x67444253, 0x4ba17514), WTCP(0x66fd9fde, 0x4c0188f8),
WTCP(0x66b6904c, 0x4c61756b), WTCP(0x666f140d, 0x4cc1393d),
WTCP(0x66272b91, 0x4d20d341), WTCP(0x65ded74d, 0x4d80424a),
WTCP(0x659617bb, 0x4ddf852d), WTCP(0x654ced55, 0x4e3e9ac1),
WTCP(0x6503589b, 0x4e9d81dc), WTCP(0x64b95a0d, 0x4efc3959),
WTCP(0x646ef230, 0x4f5ac010), WTCP(0x6424218d, 0x4fb914df),
WTCP(0x63d8e8ae, 0x501736a1), WTCP(0x638d4822, 0x50752438),
WTCP(0x6341407a, 0x50d2dc82), WTCP(0x62f4d24b, 0x51305e61),
WTCP(0x62a7fe2b, 0x518da8bb), WTCP(0x625ac4b5, 0x51eaba74),
WTCP(0x620d2686, 0x52479273), WTCP(0x61bf2440, 0x52a42fa2),
WTCP(0x6170be85, 0x530090ea), WTCP(0x6121f5fb, 0x535cb53a),
WTCP(0x60d2cb4e, 0x53b89b7e), WTCP(0x60833f28, 0x541442a8),
WTCP(0x60335239, 0x546fa9a9), WTCP(0x5fe30533, 0x54cacf77),
WTCP(0x5f9258cc, 0x5525b306), WTCP(0x5f414dbb, 0x55805350),
WTCP(0x5eefe4bc, 0x55daaf4e), WTCP(0x5e9e1e8c, 0x5634c5fe),
WTCP(0x5e4bfbec, 0x568e965c), WTCP(0x5df97d9e, 0x56e81f6c),
WTCP(0x5da6a46a, 0x5741602e), WTCP(0x5d537118, 0x579a57a8),
WTCP(0x5cffe474, 0x57f304e2), WTCP(0x5cabff4c, 0x584b66e4),
WTCP(0x5c57c271, 0x58a37cbb), WTCP(0x5c032eb7, 0x58fb4576),
WTCP(0x5bae44f4, 0x5952c024), WTCP(0x5b590602, 0x59a9ebd8),
WTCP(0x5b0372bb, 0x5a00c7a8), WTCP(0x5aad8bfe, 0x5a5752ac),
};
RAM_ALIGN
LNK_SECTION_CONSTDATA
const FIXP_WTP KBDWindow960[] = {
WTCP(0x7fffff9e, 0x0009e6ac), WTCP(0x7fffff2b, 0x000e96d5),
WTCP(0x7ffffea6, 0x0012987e), WTCP(0x7ffffe0e, 0x001652b6),
WTCP(0x7ffffd60, 0x0019ebce), WTCP(0x7ffffc9c, 0x001d76bf),
WTCP(0x7ffffbbf, 0x0020fe79), WTCP(0x7ffffac9, 0x002489ef),
WTCP(0x7ffff9b7, 0x00281de2), WTCP(0x7ffff887, 0x002bbdbb),
WTCP(0x7ffff737, 0x002f6c0d), WTCP(0x7ffff5c6, 0x00332ad8),
WTCP(0x7ffff431, 0x0036fbb9), WTCP(0x7ffff276, 0x003ae004),
WTCP(0x7ffff092, 0x003ed8d8), WTCP(0x7fffee84, 0x0042e72f),
WTCP(0x7fffec48, 0x00470be3), WTCP(0x7fffe9dd, 0x004b47b8),
WTCP(0x7fffe73f, 0x004f9b5f), WTCP(0x7fffe46b, 0x0054077a),
WTCP(0x7fffe15f, 0x00588ca1), WTCP(0x7fffde17, 0x005d2b61),
WTCP(0x7fffda91, 0x0061e442), WTCP(0x7fffd6c9, 0x0066b7c2),
WTCP(0x7fffd2bb, 0x006ba65c), WTCP(0x7fffce65, 0x0070b087),
WTCP(0x7fffc9c2, 0x0075d6b5), WTCP(0x7fffc4cf, 0x007b1955),
WTCP(0x7fffbf87, 0x008078d5), WTCP(0x7fffb9e7, 0x0085f5a0),
WTCP(0x7fffb3ea, 0x008b901d), WTCP(0x7fffad8c, 0x009148b4),
WTCP(0x7fffa6c9, 0x00971fcb), WTCP(0x7fff9f9c, 0x009d15c7),
WTCP(0x7fff9800, 0x00a32b0b), WTCP(0x7fff8ff0, 0x00a95ff9),
WTCP(0x7fff8767, 0x00afb4f4), WTCP(0x7fff7e5f, 0x00b62a5c),
WTCP(0x7fff74d4, 0x00bcc093), WTCP(0x7fff6ac0, 0x00c377f8),
WTCP(0x7fff601c, 0x00ca50eb), WTCP(0x7fff54e3, 0x00d14bcb),
WTCP(0x7fff490e, 0x00d868f7), WTCP(0x7fff3c98, 0x00dfa8ce),
WTCP(0x7fff2f79, 0x00e70bad), WTCP(0x7fff21ac, 0x00ee91f3),
WTCP(0x7fff1328, 0x00f63bfe), WTCP(0x7fff03e7, 0x00fe0a2c),
WTCP(0x7ffef3e1, 0x0105fcd9), WTCP(0x7ffee310, 0x010e1462),
WTCP(0x7ffed16a, 0x01165126), WTCP(0x7ffebee9, 0x011eb381),
WTCP(0x7ffeab83, 0x01273bd0), WTCP(0x7ffe9731, 0x012fea6f),
WTCP(0x7ffe81ea, 0x0138bfbc), WTCP(0x7ffe6ba4, 0x0141bc12),
WTCP(0x7ffe5457, 0x014adfce), WTCP(0x7ffe3bfa, 0x01542b4d),
WTCP(0x7ffe2282, 0x015d9ee9), WTCP(0x7ffe07e6, 0x01673b01),
WTCP(0x7ffdec1b, 0x0170ffee), WTCP(0x7ffdcf17, 0x017aee0e),
WTCP(0x7ffdb0d0, 0x018505bc), WTCP(0x7ffd913b, 0x018f4754),
WTCP(0x7ffd704b, 0x0199b330), WTCP(0x7ffd4df7, 0x01a449ad),
WTCP(0x7ffd2a31, 0x01af0b25), WTCP(0x7ffd04ef, 0x01b9f7f4),
WTCP(0x7ffcde23, 0x01c51074), WTCP(0x7ffcb5c1, 0x01d05501),
WTCP(0x7ffc8bbc, 0x01dbc5f5), WTCP(0x7ffc6006, 0x01e763ab),
WTCP(0x7ffc3293, 0x01f32e7d), WTCP(0x7ffc0354, 0x01ff26c5),
WTCP(0x7ffbd23b, 0x020b4cde), WTCP(0x7ffb9f3a, 0x0217a120),
WTCP(0x7ffb6a41, 0x022423e6), WTCP(0x7ffb3342, 0x0230d58a),
WTCP(0x7ffafa2d, 0x023db664), WTCP(0x7ffabef2, 0x024ac6ce),
WTCP(0x7ffa8180, 0x02580720), WTCP(0x7ffa41c9, 0x026577b3),
WTCP(0x7ff9ffb9, 0x027318e0), WTCP(0x7ff9bb41, 0x0280eaff),
WTCP(0x7ff9744e, 0x028eee68), WTCP(0x7ff92acf, 0x029d2371),
WTCP(0x7ff8deb1, 0x02ab8a74), WTCP(0x7ff88fe2, 0x02ba23c7),
WTCP(0x7ff83e4d, 0x02c8efc0), WTCP(0x7ff7e9e1, 0x02d7eeb7),
WTCP(0x7ff79288, 0x02e72101), WTCP(0x7ff7382f, 0x02f686f5),
WTCP(0x7ff6dac1, 0x030620e9), WTCP(0x7ff67a29, 0x0315ef31),
WTCP(0x7ff61651, 0x0325f224), WTCP(0x7ff5af23, 0x03362a14),
WTCP(0x7ff5448a, 0x03469758), WTCP(0x7ff4d66d, 0x03573a42),
WTCP(0x7ff464b7, 0x03681327), WTCP(0x7ff3ef4f, 0x0379225a),
WTCP(0x7ff3761d, 0x038a682e), WTCP(0x7ff2f90a, 0x039be4f4),
WTCP(0x7ff277fb, 0x03ad9900), WTCP(0x7ff1f2d8, 0x03bf84a3),
WTCP(0x7ff16986, 0x03d1a82e), WTCP(0x7ff0dbec, 0x03e403f3),
WTCP(0x7ff049ef, 0x03f69840), WTCP(0x7fefb373, 0x04096568),
WTCP(0x7fef185d, 0x041c6bb8), WTCP(0x7fee7890, 0x042fab81),
WTCP(0x7fedd3f1, 0x04432510), WTCP(0x7fed2a61, 0x0456d8b4),
WTCP(0x7fec7bc4, 0x046ac6ba), WTCP(0x7febc7fb, 0x047eef70),
WTCP(0x7feb0ee8, 0x04935322), WTCP(0x7fea506b, 0x04a7f21d),
WTCP(0x7fe98c65, 0x04bcccab), WTCP(0x7fe8c2b7, 0x04d1e318),
WTCP(0x7fe7f33e, 0x04e735af), WTCP(0x7fe71ddb, 0x04fcc4ba),
WTCP(0x7fe6426c, 0x05129081), WTCP(0x7fe560ce, 0x0528994d),
WTCP(0x7fe478df, 0x053edf68), WTCP(0x7fe38a7c, 0x05556318),
WTCP(0x7fe29581, 0x056c24a5), WTCP(0x7fe199ca, 0x05832455),
WTCP(0x7fe09733, 0x059a626e), WTCP(0x7fdf8d95, 0x05b1df35),
WTCP(0x7fde7ccb, 0x05c99aef), WTCP(0x7fdd64af, 0x05e195e0),
WTCP(0x7fdc451a, 0x05f9d04b), WTCP(0x7fdb1de4, 0x06124a73),
WTCP(0x7fd9eee5, 0x062b0499), WTCP(0x7fd8b7f5, 0x0643ff00),
WTCP(0x7fd778ec, 0x065d39e7), WTCP(0x7fd6319e, 0x0676b58f),
WTCP(0x7fd4e1e2, 0x06907237), WTCP(0x7fd3898d, 0x06aa701d),
WTCP(0x7fd22873, 0x06c4af80), WTCP(0x7fd0be6a, 0x06df309c),
WTCP(0x7fcf4b44, 0x06f9f3ad), WTCP(0x7fcdced4, 0x0714f8f0),
WTCP(0x7fcc48ed, 0x0730409f), WTCP(0x7fcab960, 0x074bcaf5),
WTCP(0x7fc91fff, 0x0767982a), WTCP(0x7fc77c9a, 0x0783a877),
WTCP(0x7fc5cf02, 0x079ffc14), WTCP(0x7fc41705, 0x07bc9338),
WTCP(0x7fc25474, 0x07d96e19), WTCP(0x7fc0871b, 0x07f68ced),
WTCP(0x7fbeaeca, 0x0813efe7), WTCP(0x7fbccb4c, 0x0831973d),
WTCP(0x7fbadc70, 0x084f8320), WTCP(0x7fb8e200, 0x086db3c3),
WTCP(0x7fb6dbc8, 0x088c2957), WTCP(0x7fb4c993, 0x08aae40c),
WTCP(0x7fb2ab2b, 0x08c9e412), WTCP(0x7fb0805a, 0x08e92997),
WTCP(0x7fae48e9, 0x0908b4c9), WTCP(0x7fac04a0, 0x092885d6),
WTCP(0x7fa9b347, 0x09489ce8), WTCP(0x7fa754a6, 0x0968fa2c),
WTCP(0x7fa4e884, 0x09899dcb), WTCP(0x7fa26ea6, 0x09aa87ee),
WTCP(0x7f9fe6d1, 0x09cbb8be), WTCP(0x7f9d50cc, 0x09ed3062),
WTCP(0x7f9aac5a, 0x0a0eef00), WTCP(0x7f97f93f, 0x0a30f4bf),
WTCP(0x7f95373e, 0x0a5341c2), WTCP(0x7f92661b, 0x0a75d62e),
WTCP(0x7f8f8596, 0x0a98b224), WTCP(0x7f8c9572, 0x0abbd5c7),
WTCP(0x7f89956f, 0x0adf4137), WTCP(0x7f86854d, 0x0b02f494),
WTCP(0x7f8364cd, 0x0b26effd), WTCP(0x7f8033ae, 0x0b4b338f),
WTCP(0x7f7cf1ae, 0x0b6fbf67), WTCP(0x7f799e8b, 0x0b9493a0),
WTCP(0x7f763a03, 0x0bb9b056), WTCP(0x7f72c3d2, 0x0bdf15a2),
WTCP(0x7f6f3bb5, 0x0c04c39c), WTCP(0x7f6ba168, 0x0c2aba5d),
WTCP(0x7f67f4a6, 0x0c50f9fa), WTCP(0x7f643529, 0x0c77828a),
WTCP(0x7f6062ac, 0x0c9e5420), WTCP(0x7f5c7ce8, 0x0cc56ed1),
WTCP(0x7f588397, 0x0cecd2ae), WTCP(0x7f547670, 0x0d147fc8),
WTCP(0x7f50552c, 0x0d3c7630), WTCP(0x7f4c1f83, 0x0d64b5f6),
WTCP(0x7f47d52a, 0x0d8d3f26), WTCP(0x7f4375d9, 0x0db611ce),
WTCP(0x7f3f0144, 0x0ddf2dfa), WTCP(0x7f3a7723, 0x0e0893b4),
WTCP(0x7f35d729, 0x0e324306), WTCP(0x7f31210a, 0x0e5c3bf9),
WTCP(0x7f2c547b, 0x0e867e94), WTCP(0x7f27712e, 0x0eb10add),
WTCP(0x7f2276d8, 0x0edbe0da), WTCP(0x7f1d6529, 0x0f07008e),
WTCP(0x7f183bd3, 0x0f3269fc), WTCP(0x7f12fa89, 0x0f5e1d27),
WTCP(0x7f0da0fb, 0x0f8a1a0e), WTCP(0x7f082ed8, 0x0fb660b1),
WTCP(0x7f02a3d2, 0x0fe2f10f), WTCP(0x7efcff98, 0x100fcb25),
WTCP(0x7ef741d9, 0x103ceeee), WTCP(0x7ef16a42, 0x106a5c66),
WTCP(0x7eeb7884, 0x10981386), WTCP(0x7ee56c4a, 0x10c61447),
WTCP(0x7edf4543, 0x10f45ea0), WTCP(0x7ed9031b, 0x1122f288),
WTCP(0x7ed2a57f, 0x1151cff3), WTCP(0x7ecc2c1a, 0x1180f6d5),
WTCP(0x7ec59699, 0x11b06720), WTCP(0x7ebee4a6, 0x11e020c8),
WTCP(0x7eb815ed, 0x121023ba), WTCP(0x7eb12a18, 0x12406fe8),
WTCP(0x7eaa20d1, 0x1271053e), WTCP(0x7ea2f9c2, 0x12a1e3a9),
WTCP(0x7e9bb494, 0x12d30b15), WTCP(0x7e9450f0, 0x13047b6c),
WTCP(0x7e8cce7f, 0x13363497), WTCP(0x7e852ce9, 0x1368367f),
WTCP(0x7e7d6bd6, 0x139a8109), WTCP(0x7e758aee, 0x13cd141b),
WTCP(0x7e6d89d9, 0x13ffef99), WTCP(0x7e65683d, 0x14331368),
WTCP(0x7e5d25c1, 0x14667f67), WTCP(0x7e54c20b, 0x149a3379),
WTCP(0x7e4c3cc3, 0x14ce2f7c), WTCP(0x7e43958e, 0x1502734f),
WTCP(0x7e3acc11, 0x1536fece), WTCP(0x7e31dff2, 0x156bd1d6),
WTCP(0x7e28d0d7, 0x15a0ec41), WTCP(0x7e1f9e63, 0x15d64de9),
WTCP(0x7e16483d, 0x160bf6a5), WTCP(0x7e0cce08, 0x1641e64c),
WTCP(0x7e032f6a, 0x16781cb4), WTCP(0x7df96c05, 0x16ae99b2),
WTCP(0x7def837e, 0x16e55d18), WTCP(0x7de57579, 0x171c66ba),
WTCP(0x7ddb419a, 0x1753b667), WTCP(0x7dd0e784, 0x178b4bef),
WTCP(0x7dc666d9, 0x17c32721), WTCP(0x7dbbbf3e, 0x17fb47ca),
WTCP(0x7db0f056, 0x1833adb5), WTCP(0x7da5f9c3, 0x186c58ae),
WTCP(0x7d9adb29, 0x18a5487d), WTCP(0x7d8f9429, 0x18de7cec),
WTCP(0x7d842467, 0x1917f5c1), WTCP(0x7d788b86, 0x1951b2c2),
WTCP(0x7d6cc927, 0x198bb3b4), WTCP(0x7d60dced, 0x19c5f85a),
WTCP(0x7d54c67c, 0x1a008077), WTCP(0x7d488574, 0x1a3b4bcb),
WTCP(0x7d3c1979, 0x1a765a17), WTCP(0x7d2f822d, 0x1ab1ab18),
WTCP(0x7d22bf32, 0x1aed3e8d), WTCP(0x7d15d02b, 0x1b291432),
WTCP(0x7d08b4ba, 0x1b652bc1), WTCP(0x7cfb6c82, 0x1ba184f5),
WTCP(0x7cedf725, 0x1bde1f86), WTCP(0x7ce05445, 0x1c1afb2c),
WTCP(0x7cd28386, 0x1c58179c), WTCP(0x7cc48489, 0x1c95748d),
WTCP(0x7cb656f3, 0x1cd311b1), WTCP(0x7ca7fa65, 0x1d10eebd),
WTCP(0x7c996e83, 0x1d4f0b60), WTCP(0x7c8ab2f0, 0x1d8d674c),
WTCP(0x7c7bc74f, 0x1dcc0230), WTCP(0x7c6cab44, 0x1e0adbbb),
WTCP(0x7c5d5e71, 0x1e49f398), WTCP(0x7c4de07c, 0x1e894973),
WTCP(0x7c3e3108, 0x1ec8dcf8), WTCP(0x7c2e4fb9, 0x1f08add0),
WTCP(0x7c1e3c34, 0x1f48bba3), WTCP(0x7c0df61d, 0x1f890618),
WTCP(0x7bfd7d18, 0x1fc98cd6), WTCP(0x7becd0cc, 0x200a4f80),
WTCP(0x7bdbf0dd, 0x204b4dbc), WTCP(0x7bcadcf1, 0x208c872c),
WTCP(0x7bb994ae, 0x20cdfb71), WTCP(0x7ba817b9, 0x210faa2c),
WTCP(0x7b9665bb, 0x215192fc), WTCP(0x7b847e58, 0x2193b57f),
WTCP(0x7b726139, 0x21d61153), WTCP(0x7b600e05, 0x2218a614),
WTCP(0x7b4d8463, 0x225b735d), WTCP(0x7b3ac3fc, 0x229e78c7),
WTCP(0x7b27cc79, 0x22e1b5eb), WTCP(0x7b149d82, 0x23252a62),
WTCP(0x7b0136c1, 0x2368d5c2), WTCP(0x7aed97df, 0x23acb7a0),
WTCP(0x7ad9c087, 0x23f0cf92), WTCP(0x7ac5b063, 0x24351d2a),
WTCP(0x7ab1671e, 0x24799ffc), WTCP(0x7a9ce464, 0x24be5799),
WTCP(0x7a8827e1, 0x25034391), WTCP(0x7a733142, 0x25486375),
WTCP(0x7a5e0033, 0x258db6d2), WTCP(0x7a489461, 0x25d33d35),
WTCP(0x7a32ed7c, 0x2618f62c), WTCP(0x7a1d0b31, 0x265ee143),
WTCP(0x7a06ed2f, 0x26a4fe02), WTCP(0x79f09327, 0x26eb4bf5),
WTCP(0x79d9fcc8, 0x2731caa3), WTCP(0x79c329c2, 0x27787995),
WTCP(0x79ac19c9, 0x27bf5850), WTCP(0x7994cc8d, 0x2806665c),
WTCP(0x797d41c1, 0x284da33c), WTCP(0x79657918, 0x28950e74),
WTCP(0x794d7247, 0x28dca788), WTCP(0x79352d01, 0x29246dfa),
WTCP(0x791ca8fc, 0x296c614a), WTCP(0x7903e5ee, 0x29b480f9),
WTCP(0x78eae38d, 0x29fccc87), WTCP(0x78d1a191, 0x2a454372),
WTCP(0x78b81fb1, 0x2a8de537), WTCP(0x789e5da6, 0x2ad6b155),
WTCP(0x78845b29, 0x2b1fa745), WTCP(0x786a17f5, 0x2b68c684),
WTCP(0x784f93c4, 0x2bb20e8c), WTCP(0x7834ce53, 0x2bfb7ed7),
WTCP(0x7819c75c, 0x2c4516dc), WTCP(0x77fe7e9e, 0x2c8ed615),
WTCP(0x77e2f3d7, 0x2cd8bbf7), WTCP(0x77c726c5, 0x2d22c7fa),
WTCP(0x77ab1728, 0x2d6cf993), WTCP(0x778ec4c0, 0x2db75037),
WTCP(0x77722f4e, 0x2e01cb59), WTCP(0x77555695, 0x2e4c6a6d),
WTCP(0x77383a58, 0x2e972ce6), WTCP(0x771ada5a, 0x2ee21235),
WTCP(0x76fd3660, 0x2f2d19cc), WTCP(0x76df4e30, 0x2f78431a),
WTCP(0x76c12190, 0x2fc38d91), WTCP(0x76a2b047, 0x300ef89d),
WTCP(0x7683fa1e, 0x305a83af), WTCP(0x7664fede, 0x30a62e34),
WTCP(0x7645be51, 0x30f1f798), WTCP(0x76263842, 0x313ddf49),
WTCP(0x76066c7e, 0x3189e4b1), WTCP(0x75e65ad1, 0x31d6073d),
WTCP(0x75c60309, 0x32224657), WTCP(0x75a564f6, 0x326ea168),
WTCP(0x75848067, 0x32bb17da), WTCP(0x7563552d, 0x3307a917),
WTCP(0x7541e31a, 0x33545486), WTCP(0x75202a02, 0x33a1198e),
WTCP(0x74fe29b8, 0x33edf798), WTCP(0x74dbe211, 0x343aee09),
WTCP(0x74b952e3, 0x3487fc48), WTCP(0x74967c06, 0x34d521bb),
WTCP(0x74735d51, 0x35225dc7), WTCP(0x744ff69f, 0x356fafcf),
WTCP(0x742c47c9, 0x35bd173a), WTCP(0x740850ab, 0x360a9369),
WTCP(0x73e41121, 0x365823c1), WTCP(0x73bf8909, 0x36a5c7a4),
WTCP(0x739ab842, 0x36f37e75), WTCP(0x73759eab, 0x37414796),
WTCP(0x73503c26, 0x378f2268), WTCP(0x732a9095, 0x37dd0e4c),
WTCP(0x73049bda, 0x382b0aa4), WTCP(0x72de5ddb, 0x387916d0),
WTCP(0x72b7d67d, 0x38c73230), WTCP(0x729105a6, 0x39155c24),
WTCP(0x7269eb3f, 0x3963940c), WTCP(0x72428730, 0x39b1d946),
WTCP(0x721ad964, 0x3a002b31), WTCP(0x71f2e1c5, 0x3a4e892c),
WTCP(0x71caa042, 0x3a9cf296), WTCP(0x71a214c7, 0x3aeb66cc),
WTCP(0x71793f43, 0x3b39e52c), WTCP(0x71501fa6, 0x3b886d14),
WTCP(0x7126b5e3, 0x3bd6fde1), WTCP(0x70fd01eb, 0x3c2596f1),
WTCP(0x70d303b2, 0x3c74379f), WTCP(0x70a8bb2e, 0x3cc2df49),
WTCP(0x707e2855, 0x3d118d4c), WTCP(0x70534b1e, 0x3d604103),
WTCP(0x70282381, 0x3daef9cc), WTCP(0x6ffcb17a, 0x3dfdb702),
WTCP(0x6fd0f504, 0x3e4c7800), WTCP(0x6fa4ee1a, 0x3e9b3c25),
WTCP(0x6f789cbb, 0x3eea02ca), WTCP(0x6f4c00e5, 0x3f38cb4b),
WTCP(0x6f1f1a9a, 0x3f879505), WTCP(0x6ef1e9da, 0x3fd65f53),
WTCP(0x6ec46ea9, 0x40252990), WTCP(0x6e96a90b, 0x4073f318),
WTCP(0x6e689905, 0x40c2bb46), WTCP(0x6e3a3e9d, 0x41118176),
WTCP(0x6e0b99dd, 0x41604504), WTCP(0x6ddcaacc, 0x41af054a),
WTCP(0x6dad7177, 0x41fdc1a5), WTCP(0x6d7dede8, 0x424c7970),
WTCP(0x6d4e202e, 0x429b2c06), WTCP(0x6d1e0855, 0x42e9d8c4),
WTCP(0x6ceda66f, 0x43387f05), WTCP(0x6cbcfa8d, 0x43871e26),
WTCP(0x6c8c04c0, 0x43d5b581), WTCP(0x6c5ac51d, 0x44244474),
WTCP(0x6c293bb8, 0x4472ca5a), WTCP(0x6bf768a8, 0x44c14690),
WTCP(0x6bc54c06, 0x450fb873), WTCP(0x6b92e5e9, 0x455e1f5f),
WTCP(0x6b60366c, 0x45ac7ab2), WTCP(0x6b2d3dab, 0x45fac9c8),
WTCP(0x6af9fbc2, 0x46490bff), WTCP(0x6ac670d1, 0x469740b5),
WTCP(0x6a929cf6, 0x46e56747), WTCP(0x6a5e8053, 0x47337f13),
WTCP(0x6a2a1b0a, 0x47818779), WTCP(0x69f56d3e, 0x47cf7fd6),
WTCP(0x69c07715, 0x481d678a), WTCP(0x698b38b4, 0x486b3df3),
WTCP(0x6955b243, 0x48b90272), WTCP(0x691fe3ec, 0x4906b466),
WTCP(0x68e9cdd8, 0x49545330), WTCP(0x68b37033, 0x49a1de30),
WTCP(0x687ccb29, 0x49ef54c8), WTCP(0x6845dee9, 0x4a3cb657),
WTCP(0x680eaba3, 0x4a8a0242), WTCP(0x67d73187, 0x4ad737e9),
WTCP(0x679f70c7, 0x4b2456af), WTCP(0x67676997, 0x4b715df7),
WTCP(0x672f1c2b, 0x4bbe4d25), WTCP(0x66f688ba, 0x4c0b239c),
WTCP(0x66bdaf7b, 0x4c57e0c2), WTCP(0x668490a6, 0x4ca483fa),
WTCP(0x664b2c76, 0x4cf10cac), WTCP(0x66118326, 0x4d3d7a3b),
WTCP(0x65d794f3, 0x4d89cc0f), WTCP(0x659d621a, 0x4dd6018f),
WTCP(0x6562eada, 0x4e221a22), WTCP(0x65282f74, 0x4e6e1530),
WTCP(0x64ed302b, 0x4eb9f222), WTCP(0x64b1ed40, 0x4f05b061),
WTCP(0x647666f8, 0x4f514f57), WTCP(0x643a9d99, 0x4f9cce6f),
WTCP(0x63fe916a, 0x4fe82d13), WTCP(0x63c242b2, 0x50336aaf),
WTCP(0x6385b1bc, 0x507e86b0), WTCP(0x6348ded1, 0x50c98082),
WTCP(0x630bca3f, 0x51145793), WTCP(0x62ce7451, 0x515f0b51),
WTCP(0x6290dd57, 0x51a99b2b), WTCP(0x625305a0, 0x51f40692),
WTCP(0x6214ed7d, 0x523e4cf5), WTCP(0x61d69541, 0x52886dc5),
WTCP(0x6197fd3e, 0x52d26875), WTCP(0x615925c9, 0x531c3c77),
WTCP(0x611a0f39, 0x5365e93e), WTCP(0x60dab9e3, 0x53af6e3e),
WTCP(0x609b2621, 0x53f8caed), WTCP(0x605b544c, 0x5441fec0),
WTCP(0x601b44bf, 0x548b092e), WTCP(0x5fdaf7d5, 0x54d3e9ae),
WTCP(0x5f9a6deb, 0x551c9fb7), WTCP(0x5f59a761, 0x55652ac3),
WTCP(0x5f18a494, 0x55ad8a4d), WTCP(0x5ed765e6, 0x55f5bdcd),
WTCP(0x5e95ebb8, 0x563dc4c1), WTCP(0x5e54366d, 0x56859ea3),
WTCP(0x5e12466a, 0x56cd4af3), WTCP(0x5dd01c13, 0x5714c92d),
WTCP(0x5d8db7cf, 0x575c18d0), WTCP(0x5d4b1a05, 0x57a3395e),
WTCP(0x5d08431e, 0x57ea2a56), WTCP(0x5cc53384, 0x5830eb3a),
WTCP(0x5c81eba0, 0x58777b8e), WTCP(0x5c3e6bdf, 0x58bddad5),
WTCP(0x5bfab4af, 0x59040893), WTCP(0x5bb6c67c, 0x594a044f),
WTCP(0x5b72a1b6, 0x598fcd8e), WTCP(0x5b2e46ce, 0x59d563d9),
WTCP(0x5ae9b634, 0x5a1ac6b8), WTCP(0x5aa4f05a, 0x5a5ff5b5),
};
RAM_ALIGN
LNK_SECTION_CONSTDATA
const FIXP_WTP KBDWindow1024[] = {
WTCP(0x7fffffa4, 0x0009962f), WTCP(0x7fffff39, 0x000e16fb),
WTCP(0x7ffffebf, 0x0011ea65), WTCP(0x7ffffe34, 0x0015750e),
WTCP(0x7ffffd96, 0x0018dc74), WTCP(0x7ffffce5, 0x001c332e),
WTCP(0x7ffffc1f, 0x001f83f5), WTCP(0x7ffffb43, 0x0022d59a),
WTCP(0x7ffffa4f, 0x00262cc2), WTCP(0x7ffff942, 0x00298cc4),
WTCP(0x7ffff81a, 0x002cf81f), WTCP(0x7ffff6d6, 0x003070c4),
WTCP(0x7ffff573, 0x0033f840), WTCP(0x7ffff3f1, 0x00378fd9),
WTCP(0x7ffff24d, 0x003b38a1), WTCP(0x7ffff085, 0x003ef381),
WTCP(0x7fffee98, 0x0042c147), WTCP(0x7fffec83, 0x0046a2a8),
WTCP(0x7fffea44, 0x004a9847), WTCP(0x7fffe7d8, 0x004ea2b7),
WTCP(0x7fffe53f, 0x0052c283), WTCP(0x7fffe274, 0x0056f829),
WTCP(0x7fffdf76, 0x005b4422), WTCP(0x7fffdc43, 0x005fa6dd),
WTCP(0x7fffd8d6, 0x006420c8), WTCP(0x7fffd52f, 0x0068b249),
WTCP(0x7fffd149, 0x006d5bc4), WTCP(0x7fffcd22, 0x00721d9a),
WTCP(0x7fffc8b6, 0x0076f828), WTCP(0x7fffc404, 0x007bebca),
WTCP(0x7fffbf06, 0x0080f8d9), WTCP(0x7fffb9bb, 0x00861fae),
WTCP(0x7fffb41e, 0x008b609e), WTCP(0x7fffae2c, 0x0090bbff),
WTCP(0x7fffa7e1, 0x00963224), WTCP(0x7fffa13a, 0x009bc362),
WTCP(0x7fff9a32, 0x00a17009), WTCP(0x7fff92c5, 0x00a7386c),
WTCP(0x7fff8af0, 0x00ad1cdc), WTCP(0x7fff82ad, 0x00b31da8),
WTCP(0x7fff79f9, 0x00b93b21), WTCP(0x7fff70cf, 0x00bf7596),
WTCP(0x7fff672a, 0x00c5cd57), WTCP(0x7fff5d05, 0x00cc42b1),
WTCP(0x7fff525c, 0x00d2d5f3), WTCP(0x7fff4729, 0x00d9876c),
WTCP(0x7fff3b66, 0x00e05769), WTCP(0x7fff2f10, 0x00e74638),
WTCP(0x7fff221f, 0x00ee5426), WTCP(0x7fff148e, 0x00f58182),
WTCP(0x7fff0658, 0x00fcce97), WTCP(0x7ffef776, 0x01043bb3),
WTCP(0x7ffee7e2, 0x010bc923), WTCP(0x7ffed795, 0x01137733),
WTCP(0x7ffec68a, 0x011b4631), WTCP(0x7ffeb4ba, 0x01233669),
WTCP(0x7ffea21d, 0x012b4827), WTCP(0x7ffe8eac, 0x01337bb8),
WTCP(0x7ffe7a61, 0x013bd167), WTCP(0x7ffe6533, 0x01444982),
WTCP(0x7ffe4f1c, 0x014ce454), WTCP(0x7ffe3813, 0x0155a229),
WTCP(0x7ffe2011, 0x015e834d), WTCP(0x7ffe070d, 0x0167880c),
WTCP(0x7ffdecff, 0x0170b0b2), WTCP(0x7ffdd1df, 0x0179fd8b),
WTCP(0x7ffdb5a2, 0x01836ee1), WTCP(0x7ffd9842, 0x018d0500),
WTCP(0x7ffd79b3, 0x0196c035), WTCP(0x7ffd59ee, 0x01a0a0ca),
WTCP(0x7ffd38e8, 0x01aaa70a), WTCP(0x7ffd1697, 0x01b4d341),
WTCP(0x7ffcf2f2, 0x01bf25b9), WTCP(0x7ffccdee, 0x01c99ebd),
WTCP(0x7ffca780, 0x01d43e99), WTCP(0x7ffc7f9e, 0x01df0597),
WTCP(0x7ffc563d, 0x01e9f401), WTCP(0x7ffc2b51, 0x01f50a22),
WTCP(0x7ffbfecf, 0x02004844), WTCP(0x7ffbd0ab, 0x020baeb1),
WTCP(0x7ffba0da, 0x02173db4), WTCP(0x7ffb6f4f, 0x0222f596),
WTCP(0x7ffb3bfd, 0x022ed6a1), WTCP(0x7ffb06d8, 0x023ae11f),
WTCP(0x7ffacfd3, 0x02471558), WTCP(0x7ffa96e0, 0x02537397),
WTCP(0x7ffa5bf2, 0x025ffc25), WTCP(0x7ffa1efc, 0x026caf4a),
WTCP(0x7ff9dfee, 0x02798d4f), WTCP(0x7ff99ebb, 0x0286967c),
WTCP(0x7ff95b55, 0x0293cb1b), WTCP(0x7ff915ab, 0x02a12b72),
WTCP(0x7ff8cdaf, 0x02aeb7cb), WTCP(0x7ff88351, 0x02bc706d),
WTCP(0x7ff83682, 0x02ca559f), WTCP(0x7ff7e731, 0x02d867a9),
WTCP(0x7ff7954e, 0x02e6a6d2), WTCP(0x7ff740c8, 0x02f51361),
WTCP(0x7ff6e98e, 0x0303ad9c), WTCP(0x7ff68f8f, 0x031275ca),
WTCP(0x7ff632ba, 0x03216c30), WTCP(0x7ff5d2fb, 0x03309116),
WTCP(0x7ff57042, 0x033fe4bf), WTCP(0x7ff50a7a, 0x034f6773),
WTCP(0x7ff4a192, 0x035f1975), WTCP(0x7ff43576, 0x036efb0a),
WTCP(0x7ff3c612, 0x037f0c78), WTCP(0x7ff35353, 0x038f4e02),
WTCP(0x7ff2dd24, 0x039fbfeb), WTCP(0x7ff26370, 0x03b06279),
WTCP(0x7ff1e623, 0x03c135ed), WTCP(0x7ff16527, 0x03d23a8b),
WTCP(0x7ff0e067, 0x03e37095), WTCP(0x7ff057cc, 0x03f4d84e),
WTCP(0x7fefcb40, 0x040671f7), WTCP(0x7fef3aad, 0x04183dd3),
WTCP(0x7feea5fa, 0x042a3c22), WTCP(0x7fee0d11, 0x043c6d25),
WTCP(0x7fed6fda, 0x044ed11d), WTCP(0x7fecce3d, 0x04616849),
WTCP(0x7fec2821, 0x047432eb), WTCP(0x7feb7d6c, 0x04873140),
WTCP(0x7feace07, 0x049a6388), WTCP(0x7fea19d6, 0x04adca01),
WTCP(0x7fe960c0, 0x04c164ea), WTCP(0x7fe8a2aa, 0x04d53481),
WTCP(0x7fe7df79, 0x04e93902), WTCP(0x7fe71712, 0x04fd72aa),
WTCP(0x7fe6495a, 0x0511e1b6), WTCP(0x7fe57634, 0x05268663),
WTCP(0x7fe49d83, 0x053b60eb), WTCP(0x7fe3bf2b, 0x05507189),
WTCP(0x7fe2db0f, 0x0565b879), WTCP(0x7fe1f110, 0x057b35f4),
WTCP(0x7fe10111, 0x0590ea35), WTCP(0x7fe00af3, 0x05a6d574),
WTCP(0x7fdf0e97, 0x05bcf7ea), WTCP(0x7fde0bdd, 0x05d351cf),
WTCP(0x7fdd02a6, 0x05e9e35c), WTCP(0x7fdbf2d2, 0x0600acc8),
WTCP(0x7fdadc40, 0x0617ae48), WTCP(0x7fd9becf, 0x062ee814),
WTCP(0x7fd89a5e, 0x06465a62), WTCP(0x7fd76eca, 0x065e0565),
WTCP(0x7fd63bf1, 0x0675e954), WTCP(0x7fd501b0, 0x068e0662),
WTCP(0x7fd3bfe4, 0x06a65cc3), WTCP(0x7fd2766a, 0x06beecaa),
WTCP(0x7fd1251e, 0x06d7b648), WTCP(0x7fcfcbda, 0x06f0b9d1),
WTCP(0x7fce6a7a, 0x0709f775), WTCP(0x7fcd00d8, 0x07236f65),
WTCP(0x7fcb8ecf, 0x073d21d2), WTCP(0x7fca1439, 0x07570eea),
WTCP(0x7fc890ed, 0x077136dd), WTCP(0x7fc704c7, 0x078b99da),
WTCP(0x7fc56f9d, 0x07a6380d), WTCP(0x7fc3d147, 0x07c111a4),
WTCP(0x7fc2299e, 0x07dc26cc), WTCP(0x7fc07878, 0x07f777b1),
WTCP(0x7fbebdac, 0x0813047d), WTCP(0x7fbcf90f, 0x082ecd5b),
WTCP(0x7fbb2a78, 0x084ad276), WTCP(0x7fb951bc, 0x086713f7),
WTCP(0x7fb76eaf, 0x08839206), WTCP(0x7fb58126, 0x08a04ccb),
WTCP(0x7fb388f4, 0x08bd446e), WTCP(0x7fb185ee, 0x08da7915),
WTCP(0x7faf77e5, 0x08f7eae7), WTCP(0x7fad5ead, 0x09159a09),
WTCP(0x7fab3a17, 0x0933869f), WTCP(0x7fa909f6, 0x0951b0cd),
WTCP(0x7fa6ce1a, 0x097018b7), WTCP(0x7fa48653, 0x098ebe7f),
WTCP(0x7fa23273, 0x09ada248), WTCP(0x7f9fd249, 0x09ccc431),
WTCP(0x7f9d65a4, 0x09ec245b), WTCP(0x7f9aec53, 0x0a0bc2e7),
WTCP(0x7f986625, 0x0a2b9ff3), WTCP(0x7f95d2e7, 0x0a4bbb9e),
WTCP(0x7f933267, 0x0a6c1604), WTCP(0x7f908472, 0x0a8caf43),
WTCP(0x7f8dc8d5, 0x0aad8776), WTCP(0x7f8aff5c, 0x0ace9eb9),
WTCP(0x7f8827d3, 0x0aeff526), WTCP(0x7f854204, 0x0b118ad8),
WTCP(0x7f824dbb, 0x0b335fe6), WTCP(0x7f7f4ac3, 0x0b557469),
WTCP(0x7f7c38e4, 0x0b77c879), WTCP(0x7f7917e9, 0x0b9a5c2b),
WTCP(0x7f75e79b, 0x0bbd2f97), WTCP(0x7f72a7c3, 0x0be042d0),
WTCP(0x7f6f5828, 0x0c0395ec), WTCP(0x7f6bf892, 0x0c2728fd),
WTCP(0x7f6888c9, 0x0c4afc16), WTCP(0x7f650894, 0x0c6f0f4a),
WTCP(0x7f6177b9, 0x0c9362a8), WTCP(0x7f5dd5ff, 0x0cb7f642),
WTCP(0x7f5a232a, 0x0cdcca26), WTCP(0x7f565f00, 0x0d01de63),
WTCP(0x7f528947, 0x0d273307), WTCP(0x7f4ea1c2, 0x0d4cc81f),
WTCP(0x7f4aa835, 0x0d729db7), WTCP(0x7f469c65, 0x0d98b3da),
WTCP(0x7f427e13, 0x0dbf0a92), WTCP(0x7f3e4d04, 0x0de5a1e9),
WTCP(0x7f3a08f9, 0x0e0c79e7), WTCP(0x7f35b1b4, 0x0e339295),
WTCP(0x7f3146f8, 0x0e5aebfa), WTCP(0x7f2cc884, 0x0e82861a),
WTCP(0x7f28361b, 0x0eaa60fd), WTCP(0x7f238f7c, 0x0ed27ca5),
WTCP(0x7f1ed467, 0x0efad917), WTCP(0x7f1a049d, 0x0f237656),
WTCP(0x7f151fdc, 0x0f4c5462), WTCP(0x7f1025e3, 0x0f75733d),
WTCP(0x7f0b1672, 0x0f9ed2e6), WTCP(0x7f05f146, 0x0fc8735e),
WTCP(0x7f00b61d, 0x0ff254a1), WTCP(0x7efb64b4, 0x101c76ae),
WTCP(0x7ef5fcca, 0x1046d981), WTCP(0x7ef07e19, 0x10717d15),
WTCP(0x7eeae860, 0x109c6165), WTCP(0x7ee53b5b, 0x10c7866a),
WTCP(0x7edf76c4, 0x10f2ec1e), WTCP(0x7ed99a58, 0x111e9279),
WTCP(0x7ed3a5d1, 0x114a7971), WTCP(0x7ecd98eb, 0x1176a0fc),
WTCP(0x7ec77360, 0x11a30910), WTCP(0x7ec134eb, 0x11cfb1a1),
WTCP(0x7ebadd44, 0x11fc9aa2), WTCP(0x7eb46c27, 0x1229c406),
WTCP(0x7eade14c, 0x12572dbf), WTCP(0x7ea73c6c, 0x1284d7bc),
WTCP(0x7ea07d41, 0x12b2c1ed), WTCP(0x7e99a382, 0x12e0ec42),
WTCP(0x7e92aee7, 0x130f56a8), WTCP(0x7e8b9f2a, 0x133e010b),
WTCP(0x7e847402, 0x136ceb59), WTCP(0x7e7d2d25, 0x139c157b),
WTCP(0x7e75ca4c, 0x13cb7f5d), WTCP(0x7e6e4b2d, 0x13fb28e6),
WTCP(0x7e66af7f, 0x142b1200), WTCP(0x7e5ef6f8, 0x145b3a92),
WTCP(0x7e572150, 0x148ba281), WTCP(0x7e4f2e3b, 0x14bc49b4),
WTCP(0x7e471d70, 0x14ed300f), WTCP(0x7e3eeea5, 0x151e5575),
WTCP(0x7e36a18e, 0x154fb9c9), WTCP(0x7e2e35e2, 0x15815ced),
WTCP(0x7e25ab56, 0x15b33ec1), WTCP(0x7e1d019e, 0x15e55f25),
WTCP(0x7e14386e, 0x1617bdf9), WTCP(0x7e0b4f7d, 0x164a5b19),
WTCP(0x7e02467e, 0x167d3662), WTCP(0x7df91d25, 0x16b04fb2),
WTCP(0x7defd327, 0x16e3a6e2), WTCP(0x7de66837, 0x17173bce),
WTCP(0x7ddcdc0a, 0x174b0e4d), WTCP(0x7dd32e53, 0x177f1e39),
WTCP(0x7dc95ec6, 0x17b36b69), WTCP(0x7dbf6d17, 0x17e7f5b3),
WTCP(0x7db558f9, 0x181cbcec), WTCP(0x7dab221f, 0x1851c0e9),
WTCP(0x7da0c83c, 0x1887017d), WTCP(0x7d964b05, 0x18bc7e7c),
WTCP(0x7d8baa2b, 0x18f237b6), WTCP(0x7d80e563, 0x19282cfd),
WTCP(0x7d75fc5e, 0x195e5e20), WTCP(0x7d6aeed0, 0x1994caee),
WTCP(0x7d5fbc6d, 0x19cb7335), WTCP(0x7d5464e6, 0x1a0256c2),
WTCP(0x7d48e7ef, 0x1a397561), WTCP(0x7d3d453b, 0x1a70cede),
WTCP(0x7d317c7c, 0x1aa86301), WTCP(0x7d258d65, 0x1ae03195),
WTCP(0x7d1977aa, 0x1b183a63), WTCP(0x7d0d3afc, 0x1b507d30),
WTCP(0x7d00d710, 0x1b88f9c5), WTCP(0x7cf44b97, 0x1bc1afe6),
WTCP(0x7ce79846, 0x1bfa9f58), WTCP(0x7cdabcce, 0x1c33c7e0),
WTCP(0x7ccdb8e4, 0x1c6d293f), WTCP(0x7cc08c39, 0x1ca6c337),
WTCP(0x7cb33682, 0x1ce0958a), WTCP(0x7ca5b772, 0x1d1a9ff8),
WTCP(0x7c980ebd, 0x1d54e240), WTCP(0x7c8a3c14, 0x1d8f5c21),
WTCP(0x7c7c3f2e, 0x1dca0d56), WTCP(0x7c6e17bc, 0x1e04f59f),
WTCP(0x7c5fc573, 0x1e4014b4), WTCP(0x7c514807, 0x1e7b6a53),
WTCP(0x7c429f2c, 0x1eb6f633), WTCP(0x7c33ca96, 0x1ef2b80f),
WTCP(0x7c24c9fa, 0x1f2eaf9e), WTCP(0x7c159d0d, 0x1f6adc98),
WTCP(0x7c064383, 0x1fa73eb2), WTCP(0x7bf6bd11, 0x1fe3d5a3),
WTCP(0x7be7096c, 0x2020a11e), WTCP(0x7bd7284a, 0x205da0d8),
WTCP(0x7bc71960, 0x209ad483), WTCP(0x7bb6dc65, 0x20d83bd1),
WTCP(0x7ba6710d, 0x2115d674), WTCP(0x7b95d710, 0x2153a41b),
WTCP(0x7b850e24, 0x2191a476), WTCP(0x7b7415ff, 0x21cfd734),
WTCP(0x7b62ee59, 0x220e3c02), WTCP(0x7b5196e9, 0x224cd28d),
WTCP(0x7b400f67, 0x228b9a82), WTCP(0x7b2e578a, 0x22ca938a),
WTCP(0x7b1c6f0b, 0x2309bd52), WTCP(0x7b0a55a1, 0x23491783),
WTCP(0x7af80b07, 0x2388a1c4), WTCP(0x7ae58ef5, 0x23c85bbf),
WTCP(0x7ad2e124, 0x2408451a), WTCP(0x7ac0014e, 0x24485d7c),
WTCP(0x7aacef2e, 0x2488a48a), WTCP(0x7a99aa7e, 0x24c919e9),
WTCP(0x7a8632f8, 0x2509bd3d), WTCP(0x7a728858, 0x254a8e29),
WTCP(0x7a5eaa5a, 0x258b8c50), WTCP(0x7a4a98b9, 0x25ccb753),
WTCP(0x7a365333, 0x260e0ed3), WTCP(0x7a21d983, 0x264f9271),
WTCP(0x7a0d2b68, 0x269141cb), WTCP(0x79f8489e, 0x26d31c80),
WTCP(0x79e330e4, 0x2715222f), WTCP(0x79cde3f8, 0x27575273),
WTCP(0x79b8619a, 0x2799acea), WTCP(0x79a2a989, 0x27dc3130),
WTCP(0x798cbb85, 0x281ededf), WTCP(0x7976974e, 0x2861b591),
WTCP(0x79603ca5, 0x28a4b4e0), WTCP(0x7949ab4c, 0x28e7dc65),
WTCP(0x7932e304, 0x292b2bb8), WTCP(0x791be390, 0x296ea270),
WTCP(0x7904acb3, 0x29b24024), WTCP(0x78ed3e30, 0x29f6046b),
WTCP(0x78d597cc, 0x2a39eed8), WTCP(0x78bdb94a, 0x2a7dff02),
WTCP(0x78a5a270, 0x2ac2347c), WTCP(0x788d5304, 0x2b068eda),
WTCP(0x7874cacb, 0x2b4b0dae), WTCP(0x785c098d, 0x2b8fb08a),
WTCP(0x78430f11, 0x2bd47700), WTCP(0x7829db1f, 0x2c1960a1),
WTCP(0x78106d7f, 0x2c5e6cfd), WTCP(0x77f6c5fb, 0x2ca39ba3),
WTCP(0x77dce45c, 0x2ce8ec23), WTCP(0x77c2c86e, 0x2d2e5e0b),
WTCP(0x77a871fa, 0x2d73f0e8), WTCP(0x778de0cd, 0x2db9a449),
WTCP(0x777314b2, 0x2dff77b8), WTCP(0x77580d78, 0x2e456ac4),
WTCP(0x773ccaeb, 0x2e8b7cf6), WTCP(0x77214cdb, 0x2ed1addb),
WTCP(0x77059315, 0x2f17fcfb), WTCP(0x76e99d69, 0x2f5e69e2),
WTCP(0x76cd6ba9, 0x2fa4f419), WTCP(0x76b0fda4, 0x2feb9b27),
WTCP(0x7694532e, 0x30325e96), WTCP(0x76776c17, 0x30793dee),
WTCP(0x765a4834, 0x30c038b5), WTCP(0x763ce759, 0x31074e72),
WTCP(0x761f4959, 0x314e7eab), WTCP(0x76016e0b, 0x3195c8e6),
WTCP(0x75e35545, 0x31dd2ca9), WTCP(0x75c4fedc, 0x3224a979),
WTCP(0x75a66aab, 0x326c3ed8), WTCP(0x75879887, 0x32b3ec4d),
WTCP(0x7568884b, 0x32fbb159), WTCP(0x754939d1, 0x33438d81),
WTCP(0x7529acf4, 0x338b8045), WTCP(0x7509e18e, 0x33d3892a),
WTCP(0x74e9d77d, 0x341ba7b1), WTCP(0x74c98e9e, 0x3463db5a),
WTCP(0x74a906cd, 0x34ac23a7), WTCP(0x74883fec, 0x34f48019),
WTCP(0x746739d8, 0x353cf02f), WTCP(0x7445f472, 0x3585736a),
WTCP(0x74246f9c, 0x35ce0949), WTCP(0x7402ab37, 0x3616b14c),
WTCP(0x73e0a727, 0x365f6af0), WTCP(0x73be6350, 0x36a835b5),
WTCP(0x739bdf95, 0x36f11118), WTCP(0x73791bdd, 0x3739fc98),
WTCP(0x7356180e, 0x3782f7b2), WTCP(0x7332d410, 0x37cc01e3),
WTCP(0x730f4fc9, 0x38151aa8), WTCP(0x72eb8b24, 0x385e417e),
WTCP(0x72c7860a, 0x38a775e1), WTCP(0x72a34066, 0x38f0b74d),
WTCP(0x727eba24, 0x393a053e), WTCP(0x7259f331, 0x39835f30),
WTCP(0x7234eb79, 0x39ccc49e), WTCP(0x720fa2eb, 0x3a163503),
WTCP(0x71ea1977, 0x3a5fafda), WTCP(0x71c44f0c, 0x3aa9349e),
WTCP(0x719e439d, 0x3af2c2ca), WTCP(0x7177f71a, 0x3b3c59d7),
WTCP(0x71516978, 0x3b85f940), WTCP(0x712a9aaa, 0x3bcfa07e),
WTCP(0x71038aa4, 0x3c194f0d), WTCP(0x70dc395e, 0x3c630464),
WTCP(0x70b4a6cd, 0x3cacbfff), WTCP(0x708cd2e9, 0x3cf68155),
WTCP(0x7064bdab, 0x3d4047e1), WTCP(0x703c670d, 0x3d8a131c),
WTCP(0x7013cf0a, 0x3dd3e27e), WTCP(0x6feaf59c, 0x3e1db580),
WTCP(0x6fc1dac1, 0x3e678b9b), WTCP(0x6f987e76, 0x3eb16449),
WTCP(0x6f6ee0b9, 0x3efb3f01), WTCP(0x6f45018b, 0x3f451b3d),
WTCP(0x6f1ae0eb, 0x3f8ef874), WTCP(0x6ef07edb, 0x3fd8d620),
WTCP(0x6ec5db5d, 0x4022b3b9), WTCP(0x6e9af675, 0x406c90b7),
WTCP(0x6e6fd027, 0x40b66c93), WTCP(0x6e446879, 0x410046c5),
WTCP(0x6e18bf71, 0x414a1ec6), WTCP(0x6decd517, 0x4193f40d),
WTCP(0x6dc0a972, 0x41ddc615), WTCP(0x6d943c8d, 0x42279455),
WTCP(0x6d678e71, 0x42715e45), WTCP(0x6d3a9f2a, 0x42bb235f),
WTCP(0x6d0d6ec5, 0x4304e31a), WTCP(0x6cdffd4f, 0x434e9cf1),
WTCP(0x6cb24ad6, 0x4398505b), WTCP(0x6c84576b, 0x43e1fcd1),
WTCP(0x6c56231c, 0x442ba1cd), WTCP(0x6c27adfd, 0x44753ec7),
WTCP(0x6bf8f81e, 0x44bed33a), WTCP(0x6bca0195, 0x45085e9d),
WTCP(0x6b9aca75, 0x4551e06b), WTCP(0x6b6b52d5, 0x459b581e),
WTCP(0x6b3b9ac9, 0x45e4c52f), WTCP(0x6b0ba26b, 0x462e2717),
WTCP(0x6adb69d3, 0x46777d52), WTCP(0x6aaaf11b, 0x46c0c75a),
WTCP(0x6a7a385c, 0x470a04a9), WTCP(0x6a493fb3, 0x475334b9),
WTCP(0x6a18073d, 0x479c5707), WTCP(0x69e68f17, 0x47e56b0c),
WTCP(0x69b4d761, 0x482e7045), WTCP(0x6982e039, 0x4877662c),
WTCP(0x6950a9c0, 0x48c04c3f), WTCP(0x691e341a, 0x490921f8),
WTCP(0x68eb7f67, 0x4951e6d5), WTCP(0x68b88bcd, 0x499a9a51),
WTCP(0x68855970, 0x49e33beb), WTCP(0x6851e875, 0x4a2bcb1f),
WTCP(0x681e3905, 0x4a74476b), WTCP(0x67ea4b47, 0x4abcb04c),
WTCP(0x67b61f63, 0x4b050541), WTCP(0x6781b585, 0x4b4d45c9),
WTCP(0x674d0dd6, 0x4b957162), WTCP(0x67182883, 0x4bdd878c),
WTCP(0x66e305b8, 0x4c2587c6), WTCP(0x66ada5a5, 0x4c6d7190),
WTCP(0x66780878, 0x4cb5446a), WTCP(0x66422e60, 0x4cfcffd5),
WTCP(0x660c1790, 0x4d44a353), WTCP(0x65d5c439, 0x4d8c2e64),
WTCP(0x659f348e, 0x4dd3a08c), WTCP(0x656868c3, 0x4e1af94b),
WTCP(0x6531610d, 0x4e623825), WTCP(0x64fa1da3, 0x4ea95c9d),
WTCP(0x64c29ebb, 0x4ef06637), WTCP(0x648ae48d, 0x4f375477),
WTCP(0x6452ef53, 0x4f7e26e1), WTCP(0x641abf46, 0x4fc4dcfb),
WTCP(0x63e254a2, 0x500b7649), WTCP(0x63a9afa2, 0x5051f253),
WTCP(0x6370d083, 0x5098509f), WTCP(0x6337b784, 0x50de90b3),
WTCP(0x62fe64e3, 0x5124b218), WTCP(0x62c4d8e0, 0x516ab455),
WTCP(0x628b13bc, 0x51b096f3), WTCP(0x625115b8, 0x51f6597b),
WTCP(0x6216df18, 0x523bfb78), WTCP(0x61dc701f, 0x52817c72),
WTCP(0x61a1c912, 0x52c6dbf5), WTCP(0x6166ea36, 0x530c198d),
WTCP(0x612bd3d2, 0x535134c5), WTCP(0x60f0862d, 0x53962d2a),
WTCP(0x60b50190, 0x53db024a), WTCP(0x60794644, 0x541fb3b1),
WTCP(0x603d5494, 0x546440ef), WTCP(0x60012cca, 0x54a8a992),
WTCP(0x5fc4cf33, 0x54eced2b), WTCP(0x5f883c1c, 0x55310b48),
WTCP(0x5f4b73d2, 0x5575037c), WTCP(0x5f0e76a5, 0x55b8d558),
WTCP(0x5ed144e5, 0x55fc806f), WTCP(0x5e93dee1, 0x56400452),
WTCP(0x5e5644ec, 0x56836096), WTCP(0x5e187757, 0x56c694cf),
WTCP(0x5dda7677, 0x5709a092), WTCP(0x5d9c429f, 0x574c8374),
WTCP(0x5d5ddc24, 0x578f3d0d), WTCP(0x5d1f435d, 0x57d1ccf2),
WTCP(0x5ce078a0, 0x581432bd), WTCP(0x5ca17c45, 0x58566e04),
WTCP(0x5c624ea4, 0x58987e63), WTCP(0x5c22f016, 0x58da6372),
WTCP(0x5be360f6, 0x591c1ccc), WTCP(0x5ba3a19f, 0x595daa0d),
WTCP(0x5b63b26c, 0x599f0ad1), WTCP(0x5b2393ba, 0x59e03eb6),
WTCP(0x5ae345e7, 0x5a214558), WTCP(0x5aa2c951, 0x5a621e56),
};
/**
* \brief Helper table containing the length, rasterand shape mapping to
* individual window slope tables. [0: sine ][0: radix2 raster
* ][ceil(log2(length)) length 4 .. 1024 ] [1: 10ms raster
* ][ceil(log2(length)) length 3.25 .. 960 ] [2: 3/4 of radix 2
* raster][ceil(log2(length)) length 3 .. 768 ] [1: KBD ][0:
* radix2 raster ][ceil(log2(length)) length 128 .. 1024 ] [1: 10ms
* raster ][ceil(log2(length)) length 120 .. 960 ] [2:
* 3/4 of radix 2 raster][ceil(log2(length)) length 96 .. 768 ]
*/
const FIXP_WTP *const windowSlopes[2][4][9] = {
{ /* Sine */
{/* Radix 2 */
NULL, SineWindow8, SineWindow16, SineWindow32, SineWindow64,
SineWindow128, SineWindow256, SineWindow512, SineWindow1024},
{ /* 10ms raster */
NULL, /* 3.25 */
NULL, /* 7.5 */
NULL, NULL, NULL, SineWindow120, SineWindow240, SineWindow480,
SineWindow960},
{ /* 3/4 radix2 raster */
NULL, /* 3 */
NULL, /* 6 */
SineWindow12, SineWindow24, SineWindow48, SineWindow96, SineWindow192,
SineWindow384, SineWindow768},
{
/* 3/4 radix2 raster */
NULL,
NULL, /* 3 */
NULL, /* 6 */
SineWindow20,
SineWindow40,
NULL,
SineWindow160,
NULL,
NULL,
}},
{ /* KBD */
{/* Radix 2 */
NULL, KBDWindow128, KBDWindow256, SineWindow512, KBDWindow1024},
{/* 10ms raster */
NULL, KBDWindow120, NULL, SineWindow480, KBDWindow960},
{/* 3/4 radix2 raster */
NULL, KBDWindow96,
SineWindow192, /* This entry might be accessed for erred bit streams. */
NULL, KBDWindow768},
{NULL, NULL, NULL, NULL}}};
const FIXP_WTP *FDKgetWindowSlope(int length, int shape) {
const FIXP_WTP *w = NULL;
int raster, ld2_length;
/* Get ld2 of length - 2 + 1
-2: because first table entry is window of size 4
+1: because we already include +1 because of ceil(log2(length)) */
ld2_length = DFRACT_BITS - 1 - fNormz((FIXP_DBL)length) - 1;
/* Extract sort of "eigenvalue" (the 4 left most bits) of length. */
switch ((length) >> (ld2_length - 2)) {
case 0x8: /* radix 2 */
raster = 0;
ld2_length--; /* revert + 1 because of ceil(log2(length)) from above. */
break;
case 0xf: /* 10 ms */
raster = 1;
break;
case 0xc: /* 3/4 of radix 2 */
raster = 2;
break;
default:
raster = 0;
break;
}
/* The table for sine windows (shape == 0) is 4 entries longer. */
if (shape == 1) {
ld2_length -= 4;
}
/* Look up table */
w = windowSlopes[shape & 1][raster][ld2_length];
FDK_ASSERT(w != NULL);
return w;
}
/*
* QMF filter and twiddle tables
*/
#ifdef QMF_COEFF_16BIT
#define QFC(x) FX_DBL2FXCONST_SGL(x)
#define QTCFL(x) FL2FXCONST_SGL(x)
#define QTC(x) FX_DBL2FXCONST_SGL(x)
#else
#define QFC(x) ((FIXP_DBL)(x))
#define QTCFL(x) FL2FXCONST_DBL(x)
#define QTC(x) ((FIXP_DBL)(x))
#endif /* ARCH_PREFER_MULT_32x16 */
/*!
\name QMF
\brief QMF-Table
64 channels, N = 640, optimized by PE 010516
The coeffs are rearranged compared with the reference in the following
way, exploiting symmetry :
sbr_qmf_64[5] = p_64_640_qmf[0];
sbr_qmf_64[6] = p_64_640_qmf[128];
sbr_qmf_64[7] = p_64_640_qmf[256];
sbr_qmf_64[8] = p_64_640_qmf[384];
sbr_qmf_64[9] = p_64_640_qmf[512];
sbr_qmf_64[10] = p_64_640_qmf[1];
sbr_qmf_64[11] = p_64_640_qmf[129];
sbr_qmf_64[12] = p_64_640_qmf[257];
sbr_qmf_64[13] = p_64_640_qmf[385];
sbr_qmf_64[14] = p_64_640_qmf[513];
.
.
.
sbr_qmf_64_640_qmf[315] = p_64_640_qmf[62];
sbr_qmf_64_640_qmf[316] = p_64_640_qmf[190];
sbr_qmf_64_640_qmf[317] = p_64_640_qmf[318];
sbr_qmf_64_640_qmf[318] = p_64_640_qmf[446];
sbr_qmf_64_640_qmf[319] = p_64_640_qmf[574];
sbr_qmf_64_640_qmf[320] = p_64_640_qmf[63];
sbr_qmf_64_640_qmf[321] = p_64_640_qmf[191];
sbr_qmf_64_640_qmf[322] = p_64_640_qmf[319];
sbr_qmf_64_640_qmf[323] = p_64_640_qmf[447];
sbr_qmf_64_640_qmf[324] = p_64_640_qmf[575];
sbr_qmf_64_640_qmf[319] = p_64_640_qmf[64];
sbr_qmf_64_640_qmf[318] = p_64_640_qmf[192];
sbr_qmf_64_640_qmf[317] = p_64_640_qmf[320];
sbr_qmf_64_640_qmf[316] = p_64_640_qmf[448];
sbr_qmf_64_640_qmf[315] = p_64_640_qmf[576];
sbr_qmf_64_640_qmf[314] = p_64_640_qmf[65];
sbr_qmf_64_640_qmf[313] = p_64_640_qmf[193];
sbr_qmf_64_640_qmf[312] = p_64_640_qmf[321];
sbr_qmf_64_640_qmf[311] = p_64_640_qmf[449];
sbr_qmf_64_640_qmf[310] = p_64_640_qmf[577];
.
.
.
sbr_qmf_64[9] = p_64_640_qmf[126]
sbr_qmf_64[8] = p_64_640_qmf[254];
sbr_qmf_64[7] = p_64_640_qmf[382];
sbr_qmf_64[6] = p_64_640_qmf[510];
sbr_qmf_64[5] = p_64_640_qmf[638];
sbr_qmf_64[4] = p_64_640_qmf[127]
sbr_qmf_64[3] = p_64_640_qmf[255];
sbr_qmf_64[2] = p_64_640_qmf[383];
sbr_qmf_64[1] = p_64_640_qmf[511];
sbr_qmf_64[0] = p_64_640_qmf[639];
Max sum of all FIR filter absolute coefficients is: 0x7FF5B201
thus, the filter output is not required to be scaled.
\showinitializer
*/
RAM_ALIGN
LNK_SECTION_CONSTDATA
const FIXP_PFT qmf_pfilt120[] = {
QFC(0x00000000), QFC(0x01b2e41d), QFC(0x2e3a7532), QFC(0xd1c58ace),
QFC(0xfe4d1be3), QFC(0xffefcdb5), QFC(0x02828e13), QFC(0x35eecfd1),
QFC(0xd94e53e3), QFC(0xfefdfe42), QFC(0xffec30b0), QFC(0x036b8e20),
QFC(0x3daa7c5c), QFC(0xe08b3fa6), QFC(0xff8f33fc), QFC(0xffe88ba8),
QFC(0x04694101), QFC(0x4547daeb), QFC(0xe75f8bb7), QFC(0x0000e790),
QFC(0xffe69150), QFC(0x057341bc), QFC(0x4c9ef50f), QFC(0xedb0fdbd),
QFC(0x00549c76), QFC(0xffe6db43), QFC(0x067ef951), QFC(0x5389d1bb),
QFC(0xf36dbfe6), QFC(0x008cbe92), QFC(0xffea353a), QFC(0x077fedb3),
QFC(0x59e2f69e), QFC(0xf887507c), QFC(0x00acbd2f), QFC(0xfff176e1),
QFC(0x086685a4), QFC(0x5f845914), QFC(0xfcf2b6c8), QFC(0x00b881db),
QFC(0xfffd1253), QFC(0x09233c49), QFC(0x64504658), QFC(0x00adb69e),
QFC(0x00b4790a), QFC(0x000d31b5), QFC(0x09a3e163), QFC(0x682b39a4),
QFC(0x03b8f8dc), QFC(0x00a520bb), QFC(0x0021e26b), QFC(0x09d536b4),
QFC(0x6afb0c80), QFC(0x06186566), QFC(0x008db1f0), QFC(0x003a81c0),
QFC(0x09a505f2), QFC(0x6cb28145), QFC(0x07d6e67c), QFC(0x00728512),
QFC(0x0055dba1), QFC(0x09015651), QFC(0x6d474e1d), QFC(0x09015651),
QFC(0x0055dba1), QFC(0xfe4d1be3), QFC(0xd1c58ace), QFC(0x2e3a7532),
QFC(0x01b2e41d), QFC(0x00000000),
};
RAM_ALIGN
LNK_SECTION_CONSTDATA
const FIXP_PFT qmf_pfilt200[] = {
QFC(0x00000000), QFC(0x01b2e41d), QFC(0x2e3a7532), QFC(0xd1c58ace),
QFC(0xfe4d1be3), QFC(0xffefd5d9), QFC(0x022c39a4), QFC(0x32d6e6f6),
QFC(0xd652421f), QFC(0xfebafd64), QFC(0xffef3d2e), QFC(0x02af2a39),
QFC(0x377b44a6), QFC(0xdac7ff47), QFC(0xff1d9e1f), QFC(0xffed03e9),
QFC(0x033b07ff), QFC(0x3c1fc4e4), QFC(0xdf2029d5), QFC(0xff74a37e),
QFC(0xffeab7cc), QFC(0x03cf3ade), QFC(0x40bc12f6), QFC(0xe3546cf8),
QFC(0xffc070af), QFC(0xffe88ba8), QFC(0x04694101), QFC(0x4547daeb),
QFC(0xe75f8bb7), QFC(0x0000e790), QFC(0xffe7546d), QFC(0x050826e6),
QFC(0x49ba0a48), QFC(0xeb3ac63a), QFC(0x0036aa5d), QFC(0xffe6665c),
QFC(0x05a92d73), QFC(0x4e0b0602), QFC(0xeee323fd), QFC(0x0061fdf9),
QFC(0xffe6858d), QFC(0x0649e26b), QFC(0x523225cf), QFC(0xf2549ca7),
QFC(0x00838276), QFC(0xffe7e0bd), QFC(0x06e7cba4), QFC(0x5627597c),
QFC(0xf58c23ae), QFC(0x009c49df), QFC(0xffea353a), QFC(0x077fedb3),
QFC(0x59e2f69e), QFC(0xf887507c), QFC(0x00acbd2f), QFC(0xffee0a64),
QFC(0x080e83ac), QFC(0x5d5bac5e), QFC(0xfb432a8a), QFC(0x00b5e294),
QFC(0xfff35c0f), QFC(0x08905893), QFC(0x608bf7c1), QFC(0xfdbfe2d8),
QFC(0x00b8dcd6), QFC(0xfffa67ed), QFC(0x0901a70f), QFC(0x636d2657),
QFC(0xfffccdc7), QFC(0x00b66387), QFC(0x0002f512), QFC(0x095eb98e),
QFC(0x65f9595d), QFC(0x01fa380f), QFC(0x00afb0f3), QFC(0x000d31b5),
QFC(0x09a3e163), QFC(0x682b39a4), QFC(0x03b8f8dc), QFC(0x00a520bb),
QFC(0x00193141), QFC(0x09cc1a7d), QFC(0x69fbfee3), QFC(0x05395430),
QFC(0x0097ce05), QFC(0x00269ad4), QFC(0x09d3fe14), QFC(0x6b69bfaf),
QFC(0x067e12f2), QFC(0x00889924), QFC(0x003567de), QFC(0x09b75cca),
QFC(0x6c716eb9), QFC(0x0789e850), QFC(0x00781556), QFC(0x0045436a),
QFC(0x097277a9), QFC(0x6d110fe4), QFC(0x085f29c6), QFC(0x00670cb6),
QFC(0x0055dba1), QFC(0x09015651), QFC(0x6d474e1d), QFC(0x09015651),
QFC(0x0055dba1), QFC(0xfe4d1be3), QFC(0xd1c58ace), QFC(0x2e3a7532),
QFC(0x01b2e41d), QFC(0x00000000),
};
RAM_ALIGN
LNK_SECTION_CONSTDATA
const FIXP_QTW qmf_phaseshift_cos40[] = {
QTC(0x7fef5260), QTC(0x7f69ff76), QTC(0x7e5fe493), QTC(0x7cd21707),
QTC(0x7ac23561), QTC(0x783265c0), QTC(0x75255392), QTC(0x719e2cd2),
QTC(0x6da09eb1), QTC(0x6930d1c4), QTC(0x645365b2), QTC(0x5f0d6c5b),
QTC(0x59646498), QTC(0x535e3479), QTC(0x4d012324), QTC(0x4653d24b),
QTC(0x3f5d373e), QTC(0x382493b0), QTC(0x30b16e23), QTC(0x290b8a12),
QTC(0x213adfda), QTC(0x1947946c), QTC(0x1139f0cf), QTC(0x091a597e),
QTC(0x00f145ab), QTC(0xf8c73668), QTC(0xf0a4adcf), QTC(0xe8922622),
QTC(0xe09808f5), QTC(0xd8bea66a), QTC(0xd10e2c89), QTC(0xc98e9eb5),
QTC(0xc247cd5a), QTC(0xbb414dc0), QTC(0xb4827228), QTC(0xae12422c),
QTC(0xa7f7736a), QTC(0xa2386284), QTC(0x9cdb0c83), QTC(0x97e50896),
};
RAM_ALIGN
LNK_SECTION_CONSTDATA
const FIXP_QTW qmf_phaseshift_sin40[] = {
QTC(0x0415583b), QTC(0x0c3bc74f), QTC(0x145576b1), QTC(0x1c59f557),
QTC(0x2440e84d), QTC(0x2c021369), QTC(0x339561e1), QTC(0x3af2eeb7),
QTC(0x42130cf0), QTC(0x48ee4f98), QTC(0x4f7d917c), QTC(0x55b9fc9e),
QTC(0x5b9d1154), QTC(0x6120ad0d), QTC(0x663f10b7), QTC(0x6af2e6bc),
QTC(0x6f374891), QTC(0x7307c3d0), QTC(0x76605edb), QTC(0x793d9d03),
QTC(0x7b9c8226), QTC(0x7d7a95cf), QTC(0x7ed5e5c6), QTC(0x7fad081b),
QTC(0x7fff1c9b), QTC(0x7fcbcdbc), QTC(0x7f1350f8), QTC(0x7dd6668f),
QTC(0x7c1658c5), QTC(0x79d4fa89), QTC(0x7714a58b), QTC(0x73d837ca),
QTC(0x7023109a), QTC(0x6bf90d1d), QTC(0x675e843e), QTC(0x6258422c),
QTC(0x5ceb8355), QTC(0x571deefa), QTC(0x50f59141), QTC(0x4a78d4f0),
};
/* This filter is scaled (0.8*pfilt) */
RAM_ALIGN
LNK_SECTION_CONSTDATA
const FIXP_PFT qmf_pfilt400[] = {
QFC(0x00000000), QFC(0x015be9b1), QFC(0x24fb90f5), QFC(0xdb046f0b),
QFC(0xfea4164f), QFC(0xfff15ed6), QFC(0x018b53a8), QFC(0x26d2bd4e),
QFC(0xdcd812f9), QFC(0xfed12595), QFC(0xfff3117b), QFC(0x01bcfae9),
QFC(0x28abebf8), QFC(0xdea834e5), QFC(0xfefbfdea), QFC(0xfff32e53),
QFC(0x01f075de), QFC(0x2a86e540), QFC(0xe07383c3), QFC(0xff24936e),
QFC(0xfff29758), QFC(0x0225bb61), QFC(0x2c629d51), QFC(0xe2399905),
QFC(0xff4ae4e6), QFC(0xfff1ab73), QFC(0x025cb6d7), QFC(0x2e3e69f9),
QFC(0xe3fa13fc), QFC(0xff6eefd4), QFC(0xfff0cfed), QFC(0x0295a000),
QFC(0x30196a50), QFC(0xe5b354ab), QFC(0xff9082cb), QFC(0xffefd442),
QFC(0x02d01d61), QFC(0x31f2b6ac), QFC(0xe765dadc), QFC(0xffb0037f),
QFC(0xffeef970), QFC(0x030c2f18), QFC(0x33c9a8c5), QFC(0xe910572d),
QFC(0xffcd26f2), QFC(0xffee0f91), QFC(0x03494088), QFC(0x359ce8be),
QFC(0xeab28265), QFC(0xffe8133f), QFC(0xffed3c86), QFC(0x03876734),
QFC(0x376caf22), QFC(0xec4c6fc6), QFC(0x0000b940), QFC(0xffecb05f),
QFC(0x03c6b32b), QFC(0x3936c186), QFC(0xeddbfa4a), QFC(0x00174372),
QFC(0xffec438a), QFC(0x04068585), QFC(0x3afb3b6d), QFC(0xef62382f),
QFC(0x002bbb7e), QFC(0xffebc5c7), QFC(0x0446af4f), QFC(0x3cb9159f),
QFC(0xf0de3518), QFC(0x003e0713), QFC(0xffeb8517), QFC(0x0487578f),
QFC(0x3e6f3802), QFC(0xf24f4ffd), QFC(0x004e64c7), QFC(0xffeb8b0d),
QFC(0x04c7cd0d), QFC(0x401d78d8), QFC(0xf3b6114c), QFC(0x005ccd60),
QFC(0xffeb9e0a), QFC(0x0507e855), QFC(0x41c1b7d9), QFC(0xf5107d52),
QFC(0x0069352b), QFC(0xffec0c97), QFC(0x054789e4), QFC(0x435c76d2),
QFC(0xf6600380), QFC(0x0073ff44), QFC(0xffecb3ca), QFC(0x05863c83),
QFC(0x44ec4796), QFC(0xf7a34fbf), QFC(0x007d07e5), QFC(0xffed65ae),
QFC(0x05c3bdde), QFC(0x46702a28), QFC(0xf8da6b28), QFC(0x008444ef),
QFC(0xffee90fb), QFC(0x05fff15c), QFC(0x47e8c54c), QFC(0xfa05d9fc),
QFC(0x008a30f2), QFC(0xffefff78), QFC(0x0639db53), QFC(0x4952ab1e),
QFC(0xfb23d977), QFC(0x008e9313), QFC(0xfff1a1ea), QFC(0x067202f0),
QFC(0x4aafbd18), QFC(0xfc35bba2), QFC(0x00918210), QFC(0xfff3a45f),
QFC(0x06a741b7), QFC(0x4bfdfb06), QFC(0xfd3aee85), QFC(0x009350b6),
QFC(0xfff5e33f), QFC(0x06d9e076), QFC(0x4d3cc634), QFC(0xfe331be0),
QFC(0x0093e3de), QFC(0xfff867de), QFC(0x07090b4f), QFC(0x4e6cc1b3),
QFC(0xff1f4fd2), QFC(0x00936109), QFC(0xfffb8658), QFC(0x073485a5),
QFC(0x4f8a8512), QFC(0xfffd716c), QFC(0x0091e939), QFC(0xfffec6af),
QFC(0x075c2159), QFC(0x50986228), QFC(0x00cfb536), QFC(0x008f7f85),
QFC(0x00025da8), QFC(0x077efad8), QFC(0x5194477e), QFC(0x0194f9a6),
QFC(0x008c8d8f), QFC(0x00064e63), QFC(0x079d423f), QFC(0x527db75e),
QFC(0x024d9e1c), QFC(0x00886b36), QFC(0x000a8e2a), QFC(0x07b64de9),
QFC(0x5355c7b6), QFC(0x02fa60b0), QFC(0x00841a2f), QFC(0x000f2b4f),
QFC(0x07c95704), QFC(0x5418bd4a), QFC(0x0399eb6f), QFC(0x007eea79),
QFC(0x00142767), QFC(0x07d67b97), QFC(0x54c998b6), QFC(0x042ddcf3),
QFC(0x0079719e), QFC(0x00193ee8), QFC(0x07dd27cf), QFC(0x55662c93),
QFC(0x04b5da5c), QFC(0x007369b7), QFC(0x001ee243), QFC(0x07dccb44),
QFC(0x55ee32f2), QFC(0x0531a8c2), QFC(0x006d4750), QFC(0x002471ce),
QFC(0x07d588d9), QFC(0x566317ad), QFC(0x05a2ff7a), QFC(0x0066c7aa),
QFC(0x002ab97f), QFC(0x07c5e3d5), QFC(0x56c12561), QFC(0x0607ed0d),
QFC(0x00601112), QFC(0x0030e1af), QFC(0x07ae9698), QFC(0x570be9e8),
QFC(0x0662a78a), QFC(0x005958bb), QFC(0x00376922), QFC(0x078ec621),
QFC(0x5740d984), QFC(0x06b287d1), QFC(0x00527092), QFC(0x003e065c),
QFC(0x0765b74d), QFC(0x57607ccb), QFC(0x06f819ec), QFC(0x004b9363),
QFC(0x0044afb4), QFC(0x0734450e), QFC(0x576c3e7e), QFC(0x0734450e),
QFC(0x0044afb4), QFC(0xfea4164f), QFC(0xdb046f0b), QFC(0x24fb90f5),
QFC(0x015be9b1), QFC(0x00000000),
};
const FIXP_QTW qmf_phaseshift_cos16[] = {
QTC(0x7fc25596), QTC(0x7dd6668f), QTC(0x7a05eead), QTC(0x745f9dd1),
QTC(0x6cf934fc), QTC(0x63ef3290), QTC(0x59646498), QTC(0x4d8162c4),
QTC(0x4073f21d), QTC(0x326e54c7), QTC(0x23a6887f), QTC(0x145576b1),
QTC(0x04b6195d), QTC(0xf50497fb), QTC(0xe57d5fda), QTC(0xd65c3b7b),
};
const FIXP_QTW qmf_phaseshift_sin16[] = {
QTC(0x07d95b9e), QTC(0x176dd9de), QTC(0x26a82186), QTC(0x354d9057),
QTC(0x4325c135), QTC(0x4ffb654d), QTC(0x5b9d1154), QTC(0x65ddfbd3),
QTC(0x6e96a99d), QTC(0x75a585cf), QTC(0x7aef6323), QTC(0x7e5fe493),
QTC(0x7fe9cbc0), QTC(0x7f872bf3), QTC(0x7d3980ec), QTC(0x7909a92d),
};
RAM_ALIGN
LNK_SECTION_CONSTDATA
const FIXP_PFT qmf_pfilt240[] = {
/* FP filter implementation */
QFC(0x00000000), QFC(0x0121ed68), QFC(0x1ed1a380), QFC(0xe12e5c80),
QFC(0xfede1298), QFC(0xfff4b438), QFC(0x0164d8de), QFC(0x21610064),
QFC(0xe3b64ef2), QFC(0xff1ba1be), QFC(0xfff533ce), QFC(0x01ac5eb8),
QFC(0x23f48a8e), QFC(0xe63437e4), QFC(0xff53fed7), QFC(0xfff40ee0),
QFC(0x01f7edb3), QFC(0x26895855), QFC(0xe8a5bb55), QFC(0xff871d30),
QFC(0xfff2cb20), QFC(0x0247b415), QFC(0x291c52e4), QFC(0xeb077fc7),
QFC(0xffb4cd53), QFC(0xfff18a22), QFC(0x029b070e), QFC(0x2baa29ab),
QFC(0xed57da15), QFC(0xffdd4df1), QFC(0xfff05d1b), QFC(0x02f0d600),
QFC(0x2e2fe755), QFC(0xef9507d5), QFC(0x00009a60), QFC(0xffefac36),
QFC(0x0348fcbc), QFC(0x30a98c1c), QFC(0xf1bba8f2), QFC(0x001eed4c),
QFC(0xffef0b8b), QFC(0x03a22bd2), QFC(0x3314a372), QFC(0xf3cb53d5),
QFC(0x0038684e), QFC(0xffeef3e0), QFC(0x03fbd58b), QFC(0x356de4ab),
QFC(0xf5c263c0), QFC(0x004d55d0), QFC(0xffef3cd8), QFC(0x0454a637),
QFC(0x37b13672), QFC(0xf79e7feb), QFC(0x005dd461), QFC(0xfff01619),
QFC(0x04abb9c0), QFC(0x39dc5c00), QFC(0xf95f9279), QFC(0x006a5b4d),
QFC(0xfff178d2), QFC(0x04fff3cb), QFC(0x3beca455), QFC(0xfb04e050),
QFC(0x007328ca), QFC(0xfff390f0), QFC(0x054fa1dc), QFC(0x3ddd668e),
QFC(0xfc8c7550), QFC(0x00788f16), QFC(0xfff64f40), QFC(0x0599ae6b),
QFC(0x3fad90c7), QFC(0xfdf72485), QFC(0x007b013c), QFC(0xfff9abe4),
QFC(0x05dcdec0), QFC(0x415aa155), QFC(0xff44c284), QFC(0x007ad0dd),
QFC(0xfffe0c37), QFC(0x06177d87), QFC(0x42e02f00), QFC(0x0073cf14),
QFC(0x007850b2), QFC(0x000314dd), QFC(0x0647fe8b), QFC(0x443e0472),
QFC(0x0185ddb7), QFC(0x00741328), QFC(0x0008cbce), QFC(0x066d40eb),
QFC(0x45722655), QFC(0x027b5093), QFC(0x006e15d2), QFC(0x000f67a8),
QFC(0x0684f772), QFC(0x46789539), QFC(0x03537bc9), QFC(0x0066c76d),
QFC(0x001696f2), QFC(0x068e247c), QFC(0x47520855), QFC(0x04104399),
QFC(0x005e76a0), QFC(0x001e5ed7), QFC(0x06874760), QFC(0x47fd3e55),
QFC(0x04b27f90), QFC(0x0055a663), QFC(0x0027012b), QFC(0x066e03f9),
QFC(0x487700c7), QFC(0x0539eefc), QFC(0x004c58b7), QFC(0x0030042f),
QFC(0x0641b0ab), QFC(0x48c0afc7), QFC(0x05a90172), QFC(0x0042c9e7),
QFC(0x00393d16), QFC(0x0600e435), QFC(0x48da3400), QFC(0x0600e435),
QFC(0x00393d16), QFC(0xfede1298), QFC(0xe12e5c80), QFC(0x1ed1a380),
QFC(0x0121ed68), QFC(0x00000000),
};
RAM_ALIGN
LNK_SECTION_CONSTDATA
const FIXP_QTW qmf_phaseshift_cos24[] = {
QTC(0x7fded530), QTC(0x7ed5e5c6), QTC(0x7cc62bdf), QTC(0x79b3ece0),
QTC(0x75a585cf), QTC(0x70a35e25), QTC(0x6ab7d663), QTC(0x63ef3290),
QTC(0x5c5780d3), QTC(0x54007c51), QTC(0x4afb6c98), QTC(0x415b01ce),
QTC(0x37332dfd), QTC(0x2c98fbba), QTC(0x21a26295), QTC(0x1666198d),
QTC(0x0afb6805), QTC(0xff79f587), QTC(0xf3f998c0), QTC(0xe8922622),
QTC(0xdd5b3e7b), QTC(0xd26c1e08), QTC(0xc7db6c50), QTC(0xbdbf0d2f),
};
RAM_ALIGN
LNK_SECTION_CONSTDATA
const FIXP_QTW qmf_phaseshift_sin24[] = {
QTC(0x05c1f4e7), QTC(0x1139f0cf), QTC(0x1c8e3bbe), QTC(0x27a75c95),
QTC(0x326e54c7), QTC(0x3cccd004), QTC(0x46ad5278), QTC(0x4ffb654d),
QTC(0x58a3c118), QTC(0x609475c3), QTC(0x67bd0fbd), QTC(0x6e0eba0c),
QTC(0x737c5d0b), QTC(0x77fab989), QTC(0x7b808015), QTC(0x7e06644c),
QTC(0x7f872bf3), QTC(0x7fffb9d1), QTC(0x7f6f141f), QTC(0x7dd6668f),
QTC(0x7b38ffde), QTC(0x779c4afc), QTC(0x7307c3d0), QTC(0x6d84e7b7),
};
/* qmf_pfilt640 is used with stride 2 instead of qmf_pfilt320[] */
RAM_ALIGN
LNK_SECTION_CONSTDATA
const FIXP_QTW qmf_phaseshift_cos32[] = {
QTC(0x7fe9cbc0), QTC(0x7f3857f6), QTC(0x7dd6668f), QTC(0x7bc5e290),
QTC(0x7909a92d), QTC(0x75a585cf), QTC(0x719e2cd2), QTC(0x6cf934fc),
QTC(0x67bd0fbd), QTC(0x61f1003f), QTC(0x5b9d1154), QTC(0x54ca0a4b),
QTC(0x4d8162c4), QTC(0x45cd358f), QTC(0x3db832a6), QTC(0x354d9057),
QTC(0x2c98fbba), QTC(0x23a6887f), QTC(0x1a82a026), QTC(0x1139f0cf),
QTC(0x07d95b9e), QTC(0xfe6de2e0), QTC(0xf50497fb), QTC(0xebaa894f),
QTC(0xe26cb01b), QTC(0xd957de7a), QTC(0xd078ad9e), QTC(0xc7db6c50),
QTC(0xbf8c0de3), QTC(0xb796199b), QTC(0xb0049ab3), QTC(0xa8e21106),
};
RAM_ALIGN
LNK_SECTION_CONSTDATA
const FIXP_QTW qmf_phaseshift_sin32[] = {
QTC(0x04b6195d), QTC(0x0e1bc2e4), QTC(0x176dd9de), QTC(0x209f701c),
QTC(0x29a3c485), QTC(0x326e54c7), QTC(0x3af2eeb7), QTC(0x4325c135),
QTC(0x4afb6c98), QTC(0x5269126e), QTC(0x59646498), QTC(0x5fe3b38d),
QTC(0x65ddfbd3), QTC(0x6b4af279), QTC(0x7023109a), QTC(0x745f9dd1),
QTC(0x77fab989), QTC(0x7aef6323), QTC(0x7d3980ec), QTC(0x7ed5e5c6),
QTC(0x7fc25596), QTC(0x7ffd885a), QTC(0x7f872bf3), QTC(0x7e5fe493),
QTC(0x7c894bde), QTC(0x7a05eead), QTC(0x76d94989), QTC(0x7307c3d0),
QTC(0x6e96a99d), QTC(0x698c246c), QTC(0x63ef3290), QTC(0x5dc79d7c),
};
RAM_ALIGN
LNK_SECTION_CONSTDATA
const FIXP_QTW qmf_phaseshift_cos_downsamp32[] = {
QTC(0x7fd8878e), QTC(0x7e9d55fc), QTC(0x7c29fbee), QTC(0x78848414),
QTC(0x73b5ebd1), QTC(0x6dca0d14), QTC(0x66cf8120), QTC(0x5ed77c8a),
QTC(0x55f5a4d2), QTC(0x4c3fdff4), QTC(0x41ce1e65), QTC(0x36ba2014),
QTC(0x2b1f34eb), QTC(0x1f19f97b), QTC(0x12c8106f), QTC(0x0647d97c),
QTC(0xf9b82684), QTC(0xed37ef91), QTC(0xe0e60685), QTC(0xd4e0cb15),
QTC(0xc945dfec), QTC(0xbe31e19b), QTC(0xb3c0200c), QTC(0xaa0a5b2e),
QTC(0xa1288376), QTC(0x99307ee0), QTC(0x9235f2ec), QTC(0x8c4a142f),
QTC(0x877b7bec), QTC(0x83d60412), QTC(0x8162aa04), QTC(0x80277872),
};
RAM_ALIGN
LNK_SECTION_CONSTDATA
const FIXP_QTW qmf_phaseshift_sin_downsamp32[] = {
QTC(0x0647d97c), QTC(0x12c8106f), QTC(0x1f19f97b), QTC(0x2b1f34eb),
QTC(0x36ba2014), QTC(0x41ce1e65), QTC(0x4c3fdff4), QTC(0x55f5a4d2),
QTC(0x5ed77c8a), QTC(0x66cf8120), QTC(0x6dca0d14), QTC(0x73b5ebd1),
QTC(0x78848414), QTC(0x7c29fbee), QTC(0x7e9d55fc), QTC(0x7fd8878e),
QTC(0x7fd8878e), QTC(0x7e9d55fc), QTC(0x7c29fbee), QTC(0x78848414),
QTC(0x73b5ebd1), QTC(0x6dca0d14), QTC(0x66cf8120), QTC(0x5ed77c8a),
QTC(0x55f5a4d2), QTC(0x4c3fdff4), QTC(0x41ce1e65), QTC(0x36ba2014),
QTC(0x2b1f34eb), QTC(0x1f19f97b), QTC(0x12c8106f), QTC(0x0647d97c),
};
RAM_ALIGN
LNK_SECTION_CONSTDATA
const FIXP_PFT qmf_pfilt640[] = {
QFC(0x00000000), QFC(0x01b2e41d), QFC(0x2e3a7532), QFC(0xd1c58ace),
QFC(0xfe4d1be3), QFC(0xffede50e), QFC(0x01d78bfc), QFC(0x2faa221c),
QFC(0xd3337b3d), QFC(0xfe70b8d1), QFC(0xffed978a), QFC(0x01fd3ba0),
QFC(0x311af3a4), QFC(0xd49fd55f), QFC(0xfe933dc0), QFC(0xffefc9b9),
QFC(0x02244a25), QFC(0x328cc6f0), QFC(0xd60a46e5), QFC(0xfeb48d0d),
QFC(0xfff0065d), QFC(0x024bf7a1), QFC(0x33ff670e), QFC(0xd7722f04),
QFC(0xfed4bec3), QFC(0xffeff6ca), QFC(0x0274ba43), QFC(0x3572ec70),
QFC(0xd8d7f21f), QFC(0xfef3f6ab), QFC(0xffef7b8b), QFC(0x029e35b4),
QFC(0x36e69691), QFC(0xda3b176a), QFC(0xff120d70), QFC(0xffeedfa4),
QFC(0x02c89901), QFC(0x385a49c4), QFC(0xdb9b5b12), QFC(0xff2ef725),
QFC(0xffee1650), QFC(0x02f3e48d), QFC(0x39ce0477), QFC(0xdcf898fb),
QFC(0xff4aabc8), QFC(0xffed651d), QFC(0x03201116), QFC(0x3b415115),
QFC(0xde529086), QFC(0xff6542d1), QFC(0xffecc31b), QFC(0x034d01f1),
QFC(0x3cb41219), QFC(0xdfa93ab5), QFC(0xff7ee3f1), QFC(0xffebe77b),
QFC(0x037ad438), QFC(0x3e25b17e), QFC(0xe0fc421e), QFC(0xff975c01),
QFC(0xffeb50b2), QFC(0x03a966bc), QFC(0x3f962fb8), QFC(0xe24b8f66),
QFC(0xffaea5d6), QFC(0xffea9192), QFC(0x03d8afe6), QFC(0x41058bc6),
QFC(0xe396a45d), QFC(0xffc4e365), QFC(0xffe9ca76), QFC(0x04083fec),
QFC(0x4272a385), QFC(0xe4de0cb0), QFC(0xffda17f2), QFC(0xffe940f4),
QFC(0x043889c6), QFC(0x43de620a), QFC(0xe620c476), QFC(0xffee183b),
QFC(0xffe88ba8), QFC(0x04694101), QFC(0x4547daeb), QFC(0xe75f8bb7),
QFC(0x0000e790), QFC(0xffe83a07), QFC(0x049aa82f), QFC(0x46aea856),
QFC(0xe89971b7), QFC(0x00131c75), QFC(0xffe79e16), QFC(0x04cc2fcf),
QFC(0x4812f848), QFC(0xe9cea84a), QFC(0x0023b989), QFC(0xffe7746e),
QFC(0x04fe20be), QFC(0x4973fef2), QFC(0xeafee7f1), QFC(0x0033b927),
QFC(0xffe6d466), QFC(0x05303f88), QFC(0x4ad237a2), QFC(0xec2a3f5f),
QFC(0x00426f36), QFC(0xffe6afed), QFC(0x05626209), QFC(0x4c2ca3df),
QFC(0xed50a31d), QFC(0x00504f41), QFC(0xffe65416), QFC(0x05950122),
QFC(0x4d83976d), QFC(0xee71b2fe), QFC(0x005d36df), QFC(0xffe681c6),
QFC(0x05c76fed), QFC(0x4ed62be3), QFC(0xef8d4d7b), QFC(0x006928a0),
QFC(0xffe66dd0), QFC(0x05f9c051), QFC(0x5024d70e), QFC(0xf0a3959f),
QFC(0x007400b8), QFC(0xffe66fab), QFC(0x062bf5ec), QFC(0x516eefb9),
QFC(0xf1b461ab), QFC(0x007e0393), QFC(0xffe69423), QFC(0x065dd56a),
QFC(0x52b449de), QFC(0xf2bf6ea4), QFC(0x00872c63), QFC(0xffe6fed4),
QFC(0x068f8b44), QFC(0x53f495aa), QFC(0xf3c4e887), QFC(0x008f87aa),
QFC(0xffe75361), QFC(0x06c0f0c0), QFC(0x552f8ff7), QFC(0xf4c473c5),
QFC(0x0096dcc2), QFC(0xffe80414), QFC(0x06f1825d), QFC(0x56654bdd),
QFC(0xf5be0fa9), QFC(0x009da526), QFC(0xffe85b4a), QFC(0x0721bf22),
QFC(0x579505f5), QFC(0xf6b1f3c3), QFC(0x00a3508f), QFC(0xffe954d0),
QFC(0x075112a2), QFC(0x58befacd), QFC(0xf79fa13a), QFC(0x00a85e94),
QFC(0xffea353a), QFC(0x077fedb3), QFC(0x59e2f69e), QFC(0xf887507c),
QFC(0x00acbd2f), QFC(0xffeb3849), QFC(0x07ad8c26), QFC(0x5b001db8),
QFC(0xf96916f5), QFC(0x00b06b68), QFC(0xffec8409), QFC(0x07da2b7f),
QFC(0x5c16d0ae), QFC(0xfa44a069), QFC(0x00b36acd), QFC(0xffedc418),
QFC(0x08061671), QFC(0x5d26be9b), QFC(0xfb19b7bd), QFC(0x00b58c8d),
QFC(0xffef2395), QFC(0x08303897), QFC(0x5e2f6367), QFC(0xfbe8f5bd),
QFC(0x00b73ab0), QFC(0xfff0e7ef), QFC(0x08594888), QFC(0x5f30ff5f),
QFC(0xfcb1d740), QFC(0x00b85f70), QFC(0xfff294c3), QFC(0x0880ffdd),
QFC(0x602b0c7f), QFC(0xfd7475d8), QFC(0x00b8c6b0), QFC(0xfff48700),
QFC(0x08a75da4), QFC(0x611d58a3), QFC(0xfe310657), QFC(0x00b8fe0d),
QFC(0xfff681d6), QFC(0x08cb4e23), QFC(0x6207f220), QFC(0xfee723c6),
QFC(0x00b8394b), QFC(0xfff91fc9), QFC(0x08edfeaa), QFC(0x62ea6474),
QFC(0xff96db8f), QFC(0x00b74c37), QFC(0xfffb42b0), QFC(0x090ec1fd),
QFC(0x63c45243), QFC(0x0040c497), QFC(0x00b5c867), QFC(0xfffdfa24),
QFC(0x092d7970), QFC(0x64964063), QFC(0x00e42fa2), QFC(0x00b3d15c),
QFC(0x00007134), QFC(0x0949eaac), QFC(0x655f63f2), QFC(0x01816e06),
QFC(0x00b1978d), QFC(0x00039609), QFC(0x0963ed46), QFC(0x661fd6b8),
QFC(0x02186a92), QFC(0x00af374c), QFC(0x0006b1cf), QFC(0x097c1ee9),
QFC(0x66d76725), QFC(0x02a99097), QFC(0x00abe79e), QFC(0x0009aa3f),
QFC(0x099140a7), QFC(0x6785c24d), QFC(0x03343534), QFC(0x00a8739d),
QFC(0x000d31b5), QFC(0x09a3e163), QFC(0x682b39a4), QFC(0x03b8f8dc),
QFC(0x00a520bb), QFC(0x0010bc63), QFC(0x09b3d780), QFC(0x68c7269c),
QFC(0x0437fb0a), QFC(0x00a1039c), QFC(0x001471f8), QFC(0x09c0e59f),
QFC(0x6959709d), QFC(0x04b0adcb), QFC(0x009d10bf), QFC(0x0018703f),
QFC(0x09cab9f2), QFC(0x69e29784), QFC(0x05237f9d), QFC(0x0098b855),
QFC(0x001c3549), QFC(0x09d19ca9), QFC(0x6a619c5e), QFC(0x0590a67d),
QFC(0x009424c6), QFC(0x002064f8), QFC(0x09d52709), QFC(0x6ad73e8e),
QFC(0x05f7fb90), QFC(0x008f4bfd), QFC(0x0024dd50), QFC(0x09d5560b),
QFC(0x6b42a864), QFC(0x06593912), QFC(0x008a7dd7), QFC(0x00293718),
QFC(0x09d1fa23), QFC(0x6ba4629f), QFC(0x06b559c3), QFC(0x0085c217),
QFC(0x002d8e42), QFC(0x09caeb0f), QFC(0x6bfbdd98), QFC(0x070bbf58),
QFC(0x00807994), QFC(0x00329ab6), QFC(0x09c018cf), QFC(0x6c492217),
QFC(0x075ca90c), QFC(0x007b3875), QFC(0x003745f9), QFC(0x09b18a1d),
QFC(0x6c8c4c7a), QFC(0x07a8127d), QFC(0x0075fded), QFC(0x003c1fa4),
QFC(0x099ec3dc), QFC(0x6cc59bab), QFC(0x07ee507c), QFC(0x0070c8a5),
QFC(0x004103f5), QFC(0x09881dc5), QFC(0x6cf4073e), QFC(0x082f552e),
QFC(0x006b47fa), QFC(0x00465348), QFC(0x096d0e22), QFC(0x6d18520e),
QFC(0x086b1eec), QFC(0x0065fde5), QFC(0x004b6c46), QFC(0x094d7ec2),
QFC(0x6d32730f), QFC(0x08a24899), QFC(0x006090c4), QFC(0x0050b177),
QFC(0x09299ead), QFC(0x6d41d964), QFC(0x08d3e41b), QFC(0x005b5371),
QFC(0x0055dba1), QFC(0x09015651), QFC(0x6d474e1d), QFC(0x09015651),
QFC(0x0055dba1), QFC(0xfe4d1be3), QFC(0xd1c58ace), QFC(0x2e3a7532),
QFC(0x01b2e41d), QFC(0x00000000),
};
/* This variant of the table above is used on platforms, that have vectorized
access to the table reading 4 filter sets (each of 5 coefficients) in a
block. Format: 1st row flt[0] of 4 sets (e.g. set 0, 1, 2, 3) 2nd row
flt[1] of 4 sets (e.g. set 0, 1, 2, 3) 3rd row flt[2] of 4 sets (e.g. set
0, 1, 2, 3) 4th row flt[3] of 4 sets (e.g. set 0, 1, 2, 3) 5th row
flt[4] of 4 sets (e.g. set 0, 1, 2, 3) There are 32 blocks of 20
coefficients, in total 640. Each of the rows must be at least 64-bit aligned
(see: RAM_ALIGN).
*/
RAM_ALIGN
LNK_SECTION_CONSTDATA
const FIXP_PFT qmf_pfilt640_vector[] = {
/*------------- 1 .. 4 ---------------*/
QFC(0xFFEDE50E),
QFC(0xFFED978A),
QFC(0xFFEFC9B9),
QFC(0xFFF0065D),
QFC(0x01D78BFC),
QFC(0x01FD3BA0),
QFC(0x02244A25),
QFC(0x024BF7A1),
QFC(0x2FAA221C),
QFC(0x311AF3A4),
QFC(0x328CC6F0),
QFC(0x33FF670E),
QFC(0xD3337B3D),
QFC(0xD49FD55F),
QFC(0xD60A46E5),
QFC(0xD7722F04),
QFC(0xFE70B8D1),
QFC(0xFE933DC0),
QFC(0xFEB48D0D),
QFC(0xFED4BEC3),
/*------------- 5 .. 8 ---------------*/
QFC(0xFFEFF6CA),
QFC(0xFFEF7B8B),
QFC(0xFFEEDFA4),
QFC(0xFFEE1650),
QFC(0x0274BA43),
QFC(0x029E35B4),
QFC(0x02C89901),
QFC(0x02F3E48D),
QFC(0x3572EC70),
QFC(0x36E69691),
QFC(0x385A49C4),
QFC(0x39CE0477),
QFC(0xD8D7F21F),
QFC(0xDA3B176A),
QFC(0xDB9B5B12),
QFC(0xDCF898FB),
QFC(0xFEF3F6AB),
QFC(0xFF120D70),
QFC(0xFF2EF725),
QFC(0xFF4AABC8),
/*------------- 9 .. 12 ---------------*/
QFC(0xFFED651D),
QFC(0xFFECC31B),
QFC(0xFFEBE77B),
QFC(0xFFEB50B2),
QFC(0x03201116),
QFC(0x034D01F1),
QFC(0x037AD438),
QFC(0x03A966BC),
QFC(0x3B415115),
QFC(0x3CB41219),
QFC(0x3E25B17E),
QFC(0x3F962FB8),
QFC(0xDE529086),
QFC(0xDFA93AB5),
QFC(0xE0FC421E),
QFC(0xE24B8F66),
QFC(0xFF6542D1),
QFC(0xFF7EE3F1),
QFC(0xFF975C01),
QFC(0xFFAEA5D6),
/*------------- 13 .. 16 ---------------*/
QFC(0xFFEA9192),
QFC(0xFFE9CA76),
QFC(0xFFE940F4),
QFC(0xFFE88BA8),
QFC(0x03D8AFE6),
QFC(0x04083FEC),
QFC(0x043889C6),
QFC(0x04694101),
QFC(0x41058BC6),
QFC(0x4272A385),
QFC(0x43DE620A),
QFC(0x4547DAEB),
QFC(0xE396A45D),
QFC(0xE4DE0CB0),
QFC(0xE620C476),
QFC(0xE75F8BB7),
QFC(0xFFC4E365),
QFC(0xFFDA17F2),
QFC(0xFFEE183B),
QFC(0x0000E790),
/*------------- 17 .. 20 ---------------*/
QFC(0xFFE83A07),
QFC(0xFFE79E16),
QFC(0xFFE7746E),
QFC(0xFFE6D466),
QFC(0x049AA82F),
QFC(0x04CC2FCF),
QFC(0x04FE20BE),
QFC(0x05303F88),
QFC(0x46AEA856),
QFC(0x4812F848),
QFC(0x4973FEF2),
QFC(0x4AD237A2),
QFC(0xE89971B7),
QFC(0xE9CEA84A),
QFC(0xEAFEE7F1),
QFC(0xEC2A3F5F),
QFC(0x00131C75),
QFC(0x0023B989),
QFC(0x0033B927),
QFC(0x00426F36),
/*------------- 21 .. 24 ---------------*/
QFC(0xFFE6AFED),
QFC(0xFFE65416),
QFC(0xFFE681C6),
QFC(0xFFE66DD0),
QFC(0x05626209),
QFC(0x05950122),
QFC(0x05C76FED),
QFC(0x05F9C051),
QFC(0x4C2CA3DF),
QFC(0x4D83976D),
QFC(0x4ED62BE3),
QFC(0x5024D70E),
QFC(0xED50A31D),
QFC(0xEE71B2FE),
QFC(0xEF8D4D7B),
QFC(0xF0A3959F),
QFC(0x00504F41),
QFC(0x005D36DF),
QFC(0x006928A0),
QFC(0x007400B8),
/*------------- 25 .. 28 ---------------*/
QFC(0xFFE66FAB),
QFC(0xFFE69423),
QFC(0xFFE6FED4),
QFC(0xFFE75361),
QFC(0x062BF5EC),
QFC(0x065DD56A),
QFC(0x068F8B44),
QFC(0x06C0F0C0),
QFC(0x516EEFB9),
QFC(0x52B449DE),
QFC(0x53F495AA),
QFC(0x552F8FF7),
QFC(0xF1B461AB),
QFC(0xF2BF6EA4),
QFC(0xF3C4E887),
QFC(0xF4C473C5),
QFC(0x007E0393),
QFC(0x00872C63),
QFC(0x008F87AA),
QFC(0x0096DCC2),
/*------------- 29 .. 32 ---------------*/
QFC(0xFFE80414),
QFC(0xFFE85B4A),
QFC(0xFFE954D0),
QFC(0xFFEA353A),
QFC(0x06F1825D),
QFC(0x0721BF22),
QFC(0x075112A2),
QFC(0x077FEDB3),
QFC(0x56654BDD),
QFC(0x579505F5),
QFC(0x58BEFACD),
QFC(0x59E2F69E),
QFC(0xF5BE0FA9),
QFC(0xF6B1F3C3),
QFC(0xF79FA13A),
QFC(0xF887507C),
QFC(0x009DA526),
QFC(0x00A3508F),
QFC(0x00A85E94),
QFC(0x00ACBD2F),
/*------------- 33 .. 36 ---------------*/
QFC(0xFFEB3849),
QFC(0xFFEC8409),
QFC(0xFFEDC418),
QFC(0xFFEF2395),
QFC(0x07AD8C26),
QFC(0x07DA2B7F),
QFC(0x08061671),
QFC(0x08303897),
QFC(0x5B001DB8),
QFC(0x5C16D0AE),
QFC(0x5D26BE9B),
QFC(0x5E2F6367),
QFC(0xF96916F5),
QFC(0xFA44A069),
QFC(0xFB19B7BD),
QFC(0xFBE8F5BD),
QFC(0x00B06B68),
QFC(0x00B36ACD),
QFC(0x00B58C8D),
QFC(0x00B73AB0),
/*------------- 37 .. 40 ---------------*/
QFC(0xFFF0E7EF),
QFC(0xFFF294C3),
QFC(0xFFF48700),
QFC(0xFFF681D6),
QFC(0x08594888),
QFC(0x0880FFDD),
QFC(0x08A75DA4),
QFC(0x08CB4E23),
QFC(0x5F30FF5F),
QFC(0x602B0C7F),
QFC(0x611D58A3),
QFC(0x6207F220),
QFC(0xFCB1D740),
QFC(0xFD7475D8),
QFC(0xFE310657),
QFC(0xFEE723C6),
QFC(0x00B85F70),
QFC(0x00B8C6B0),
QFC(0x00B8FE0D),
QFC(0x00B8394B),
/*------------- 41 .. 44 ---------------*/
QFC(0xFFF91FC9),
QFC(0xFFFB42B0),
QFC(0xFFFDFA24),
QFC(0x00007134),
QFC(0x08EDFEAA),
QFC(0x090EC1FD),
QFC(0x092D7970),
QFC(0x0949EAAC),
QFC(0x62EA6474),
QFC(0x63C45243),
QFC(0x64964063),
QFC(0x655F63F2),
QFC(0xFF96DB8F),
QFC(0x0040C497),
QFC(0x00E42FA2),
QFC(0x01816E06),
QFC(0x00B74C37),
QFC(0x00B5C867),
QFC(0x00B3D15C),
QFC(0x00B1978D),
/*------------- 45 .. 48 ---------------*/
QFC(0x00039609),
QFC(0x0006B1CF),
QFC(0x0009AA3F),
QFC(0x000D31B5),
QFC(0x0963ED46),
QFC(0x097C1EE9),
QFC(0x099140A7),
QFC(0x09A3E163),
QFC(0x661FD6B8),
QFC(0x66D76725),
QFC(0x6785C24D),
QFC(0x682B39A4),
QFC(0x02186A92),
QFC(0x02A99097),
QFC(0x03343534),
QFC(0x03B8F8DC),
QFC(0x00AF374C),
QFC(0x00ABE79E),
QFC(0x00A8739D),
QFC(0x00A520BB),
/*------------- 49 .. 52 ---------------*/
QFC(0x0010BC63),
QFC(0x001471F8),
QFC(0x0018703F),
QFC(0x001C3549),
QFC(0x09B3D780),
QFC(0x09C0E59F),
QFC(0x09CAB9F2),
QFC(0x09D19CA9),
QFC(0x68C7269C),
QFC(0x6959709D),
QFC(0x69E29784),
QFC(0x6A619C5E),
QFC(0x0437FB0A),
QFC(0x04B0ADCB),
QFC(0x05237F9D),
QFC(0x0590A67D),
QFC(0x00A1039C),
QFC(0x009D10BF),
QFC(0x0098B855),
QFC(0x009424C6),
/*------------- 53 .. 56 ---------------*/
QFC(0x002064F8),
QFC(0x0024DD50),
QFC(0x00293718),
QFC(0x002D8E42),
QFC(0x09D52709),
QFC(0x09D5560B),
QFC(0x09D1FA23),
QFC(0x09CAEB0F),
QFC(0x6AD73E8E),
QFC(0x6B42A864),
QFC(0x6BA4629F),
QFC(0x6BFBDD98),
QFC(0x05F7FB90),
QFC(0x06593912),
QFC(0x06B559C3),
QFC(0x070BBF58),
QFC(0x008F4BFD),
QFC(0x008A7DD7),
QFC(0x0085C217),
QFC(0x00807994),
/*------------- 57 .. 60 ---------------*/
QFC(0x00329AB6),
QFC(0x003745F9),
QFC(0x003C1FA4),
QFC(0x004103F5),
QFC(0x09C018CF),
QFC(0x09B18A1D),
QFC(0x099EC3DC),
QFC(0x09881DC5),
QFC(0x6C492217),
QFC(0x6C8C4C7A),
QFC(0x6CC59BAB),
QFC(0x6CF4073E),
QFC(0x075CA90C),
QFC(0x07A8127D),
QFC(0x07EE507C),
QFC(0x082F552E),
QFC(0x007B3875),
QFC(0x0075FDED),
QFC(0x0070C8A5),
QFC(0x006B47FA),
/*------------- 61 .. 64 ---------------*/
QFC(0x00465348),
QFC(0x004B6C46),
QFC(0x0050B177),
QFC(0x0055DBA1),
QFC(0x096D0E22),
QFC(0x094D7EC2),
QFC(0x09299EAD),
QFC(0x09015651),
QFC(0x6D18520E),
QFC(0x6D32730F),
QFC(0x6D41D964),
QFC(0x6D474E1D),
QFC(0x086B1EEC),
QFC(0x08A24899),
QFC(0x08D3E41B),
QFC(0x09015651),
QFC(0x0065FDE5),
QFC(0x006090C4),
QFC(0x005B5371),
QFC(0x0055DBA1),
/*------------- 63 .. 60 ---------------*/
QFC(0x005B5371),
QFC(0x006090C4),
QFC(0x0065FDE5),
QFC(0x006B47FA),
QFC(0x08D3E41B),
QFC(0x08A24899),
QFC(0x086B1EEC),
QFC(0x082F552E),
QFC(0x6D41D964),
QFC(0x6D32730F),
QFC(0x6D18520E),
QFC(0x6CF4073E),
QFC(0x09299EAD),
QFC(0x094D7EC2),
QFC(0x096D0E22),
QFC(0x09881DC5),
QFC(0x0050B177),
QFC(0x004B6C46),
QFC(0x00465348),
QFC(0x004103F5),
/*------------- 59 .. 56 ---------------*/
QFC(0x0070C8A5),
QFC(0x0075FDED),
QFC(0x007B3875),
QFC(0x00807994),
QFC(0x07EE507C),
QFC(0x07A8127D),
QFC(0x075CA90C),
QFC(0x070BBF58),
QFC(0x6CC59BAB),
QFC(0x6C8C4C7A),
QFC(0x6C492217),
QFC(0x6BFBDD98),
QFC(0x099EC3DC),
QFC(0x09B18A1D),
QFC(0x09C018CF),
QFC(0x09CAEB0F),
QFC(0x003C1FA4),
QFC(0x003745F9),
QFC(0x00329AB6),
QFC(0x002D8E42),
/*------------- 55 .. 52 ---------------*/
QFC(0x0085C217),
QFC(0x008A7DD7),
QFC(0x008F4BFD),
QFC(0x009424C6),
QFC(0x06B559C3),
QFC(0x06593912),
QFC(0x05F7FB90),
QFC(0x0590A67D),
QFC(0x6BA4629F),
QFC(0x6B42A864),
QFC(0x6AD73E8E),
QFC(0x6A619C5E),
QFC(0x09D1FA23),
QFC(0x09D5560B),
QFC(0x09D52709),
QFC(0x09D19CA9),
QFC(0x00293718),
QFC(0x0024DD50),
QFC(0x002064F8),
QFC(0x001C3549),
/*------------- 51 .. 48 ---------------*/
QFC(0x0098B855),
QFC(0x009D10BF),
QFC(0x00A1039C),
QFC(0x00A520BB),
QFC(0x05237F9D),
QFC(0x04B0ADCB),
QFC(0x0437FB0A),
QFC(0x03B8F8DC),
QFC(0x69E29784),
QFC(0x6959709D),
QFC(0x68C7269C),
QFC(0x682B39A4),
QFC(0x09CAB9F2),
QFC(0x09C0E59F),
QFC(0x09B3D780),
QFC(0x09A3E163),
QFC(0x0018703F),
QFC(0x001471F8),
QFC(0x0010BC63),
QFC(0x000D31B5),
/*------------- 47 .. 44 ---------------*/
QFC(0x00A8739D),
QFC(0x00ABE79E),
QFC(0x00AF374C),
QFC(0x00B1978D),
QFC(0x03343534),
QFC(0x02A99097),
QFC(0x02186A92),
QFC(0x01816E06),
QFC(0x6785C24D),
QFC(0x66D76725),
QFC(0x661FD6B8),
QFC(0x655F63F2),
QFC(0x099140A7),
QFC(0x097C1EE9),
QFC(0x0963ED46),
QFC(0x0949EAAC),
QFC(0x0009AA3F),
QFC(0x0006B1CF),
QFC(0x00039609),
QFC(0x00007134),
/*------------- 43 .. 40 ---------------*/
QFC(0x00B3D15C),
QFC(0x00B5C867),
QFC(0x00B74C37),
QFC(0x00B8394B),
QFC(0x00E42FA2),
QFC(0x0040C497),
QFC(0xFF96DB8F),
QFC(0xFEE723C6),
QFC(0x64964063),
QFC(0x63C45243),
QFC(0x62EA6474),
QFC(0x6207F220),
QFC(0x092D7970),
QFC(0x090EC1FD),
QFC(0x08EDFEAA),
QFC(0x08CB4E23),
QFC(0xFFFDFA24),
QFC(0xFFFB42B0),
QFC(0xFFF91FC9),
QFC(0xFFF681D6),
/*------------- 39 .. 36 ---------------*/
QFC(0x00B8FE0D),
QFC(0x00B8C6B0),
QFC(0x00B85F70),
QFC(0x00B73AB0),
QFC(0xFE310657),
QFC(0xFD7475D8),
QFC(0xFCB1D740),
QFC(0xFBE8F5BD),
QFC(0x611D58A3),
QFC(0x602B0C7F),
QFC(0x5F30FF5F),
QFC(0x5E2F6367),
QFC(0x08A75DA4),
QFC(0x0880FFDD),
QFC(0x08594888),
QFC(0x08303897),
QFC(0xFFF48700),
QFC(0xFFF294C3),
QFC(0xFFF0E7EF),
QFC(0xFFEF2395),
/*------------- 35 .. 32 ---------------*/
QFC(0x00B58C8D),
QFC(0x00B36ACD),
QFC(0x00B06B68),
QFC(0x00ACBD2F),
QFC(0xFB19B7BD),
QFC(0xFA44A069),
QFC(0xF96916F5),
QFC(0xF887507C),
QFC(0x5D26BE9B),
QFC(0x5C16D0AE),
QFC(0x5B001DB8),
QFC(0x59E2F69E),
QFC(0x08061671),
QFC(0x07DA2B7F),
QFC(0x07AD8C26),
QFC(0x077FEDB3),
QFC(0xFFEDC418),
QFC(0xFFEC8409),
QFC(0xFFEB3849),
QFC(0xFFEA353A),
/*------------- 31 .. 28 ---------------*/
QFC(0x00A85E94),
QFC(0x00A3508F),
QFC(0x009DA526),
QFC(0x0096DCC2),
QFC(0xF79FA13A),
QFC(0xF6B1F3C3),
QFC(0xF5BE0FA9),
QFC(0xF4C473C5),
QFC(0x58BEFACD),
QFC(0x579505F5),
QFC(0x56654BDD),
QFC(0x552F8FF7),
QFC(0x075112A2),
QFC(0x0721BF22),
QFC(0x06F1825D),
QFC(0x06C0F0C0),
QFC(0xFFE954D0),
QFC(0xFFE85B4A),
QFC(0xFFE80414),
QFC(0xFFE75361),
/*------------- 27 .. 24 ---------------*/
QFC(0x008F87AA),
QFC(0x00872C63),
QFC(0x007E0393),
QFC(0x007400B8),
QFC(0xF3C4E887),
QFC(0xF2BF6EA4),
QFC(0xF1B461AB),
QFC(0xF0A3959F),
QFC(0x53F495AA),
QFC(0x52B449DE),
QFC(0x516EEFB9),
QFC(0x5024D70E),
QFC(0x068F8B44),
QFC(0x065DD56A),
QFC(0x062BF5EC),
QFC(0x05F9C051),
QFC(0xFFE6FED4),
QFC(0xFFE69423),
QFC(0xFFE66FAB),
QFC(0xFFE66DD0),
/*------------- 23 .. 20 ---------------*/
QFC(0x006928A0),
QFC(0x005D36DF),
QFC(0x00504F41),
QFC(0x00426F36),
QFC(0xEF8D4D7B),
QFC(0xEE71B2FE),
QFC(0xED50A31D),
QFC(0xEC2A3F5F),
QFC(0x4ED62BE3),
QFC(0x4D83976D),
QFC(0x4C2CA3DF),
QFC(0x4AD237A2),
QFC(0x05C76FED),
QFC(0x05950122),
QFC(0x05626209),
QFC(0x05303F88),
QFC(0xFFE681C6),
QFC(0xFFE65416),
QFC(0xFFE6AFED),
QFC(0xFFE6D466),
/*------------- 19 .. 16 ---------------*/
QFC(0x0033B927),
QFC(0x0023B989),
QFC(0x00131C75),
QFC(0x0000E790),
QFC(0xEAFEE7F1),
QFC(0xE9CEA84A),
QFC(0xE89971B7),
QFC(0xE75F8BB7),
QFC(0x4973FEF2),
QFC(0x4812F848),
QFC(0x46AEA856),
QFC(0x4547DAEB),
QFC(0x04FE20BE),
QFC(0x04CC2FCF),
QFC(0x049AA82F),
QFC(0x04694101),
QFC(0xFFE7746E),
QFC(0xFFE79E16),
QFC(0xFFE83A07),
QFC(0xFFE88BA8),
/*------------- 15 .. 12 ---------------*/
QFC(0xFFEE183B),
QFC(0xFFDA17F2),
QFC(0xFFC4E365),
QFC(0xFFAEA5D6),
QFC(0xE620C476),
QFC(0xE4DE0CB0),
QFC(0xE396A45D),
QFC(0xE24B8F66),
QFC(0x43DE620A),
QFC(0x4272A385),
QFC(0x41058BC6),
QFC(0x3F962FB8),
QFC(0x043889C6),
QFC(0x04083FEC),
QFC(0x03D8AFE6),
QFC(0x03A966BC),
QFC(0xFFE940F4),
QFC(0xFFE9CA76),
QFC(0xFFEA9192),
QFC(0xFFEB50B2),
/*------------- 11 .. 8 ---------------*/
QFC(0xFF975C01),
QFC(0xFF7EE3F1),
QFC(0xFF6542D1),
QFC(0xFF4AABC8),
QFC(0xE0FC421E),
QFC(0xDFA93AB5),
QFC(0xDE529086),
QFC(0xDCF898FB),
QFC(0x3E25B17E),
QFC(0x3CB41219),
QFC(0x3B415115),
QFC(0x39CE0477),
QFC(0x037AD438),
QFC(0x034D01F1),
QFC(0x03201116),
QFC(0x02F3E48D),
QFC(0xFFEBE77B),
QFC(0xFFECC31B),
QFC(0xFFED651D),
QFC(0xFFEE1650),
/*------------- 7 .. 4 ---------------*/
QFC(0xFF2EF725),
QFC(0xFF120D70),
QFC(0xFEF3F6AB),
QFC(0xFED4BEC3),
QFC(0xDB9B5B12),
QFC(0xDA3B176A),
QFC(0xD8D7F21F),
QFC(0xD7722F04),
QFC(0x385A49C4),
QFC(0x36E69691),
QFC(0x3572EC70),
QFC(0x33FF670E),
QFC(0x02C89901),
QFC(0x029E35B4),
QFC(0x0274BA43),
QFC(0x024BF7A1),
QFC(0xFFEEDFA4),
QFC(0xFFEF7B8B),
QFC(0xFFEFF6CA),
QFC(0xFFF0065D),
/*------------- 3 .. 0 ---------------*/
QFC(0xFEB48D0D),
QFC(0xFE933DC0),
QFC(0xFE70B8D1),
QFC(0xFE4D1BE3),
QFC(0xD60A46E5),
QFC(0xD49FD55F),
QFC(0xD3337B3D),
QFC(0xD1C58ACE),
QFC(0x328CC6F0),
QFC(0x311AF3A4),
QFC(0x2FAA221C),
QFC(0x2E3A7532),
QFC(0x02244A25),
QFC(0x01FD3BA0),
QFC(0x01D78BFC),
QFC(0x01B2E41D),
QFC(0xFFEFC9B9),
QFC(0xFFED978A),
QFC(0xFFEDE50E),
QFC(0x00000000),
};
RAM_ALIGN
LNK_SECTION_CONSTDATA
const FIXP_QTW qmf_phaseshift_cos64[] = {
QTC(0x7ff62182), QTC(0x7fa736b4), QTC(0x7f0991c4), QTC(0x7e1d93ea),
QTC(0x7ce3ceb2), QTC(0x7b5d039e), QTC(0x798a23b1), QTC(0x776c4edb),
QTC(0x7504d345), QTC(0x72552c85), QTC(0x6f5f02b2), QTC(0x6c242960),
QTC(0x68a69e81), QTC(0x64e88926), QTC(0x60ec3830), QTC(0x5cb420e0),
QTC(0x5842dd54), QTC(0x539b2af0), QTC(0x4ebfe8a5), QTC(0x49b41533),
QTC(0x447acd50), QTC(0x3f1749b8), QTC(0x398cdd32), QTC(0x33def287),
QTC(0x2e110a62), QTC(0x2826b928), QTC(0x2223a4c5), QTC(0x1c0b826a),
QTC(0x15e21445), QTC(0x0fab272b), QTC(0x096a9049), QTC(0x03242abf),
QTC(0xfcdbd541), QTC(0xf6956fb7), QTC(0xf054d8d5), QTC(0xea1debbb),
QTC(0xe3f47d96), QTC(0xdddc5b3b), QTC(0xd7d946d8), QTC(0xd1eef59e),
QTC(0xcc210d79), QTC(0xc67322ce), QTC(0xc0e8b648), QTC(0xbb8532b0),
QTC(0xb64beacd), QTC(0xb140175b), QTC(0xac64d510), QTC(0xa7bd22ac),
QTC(0xa34bdf20), QTC(0x9f13c7d0), QTC(0x9b1776da), QTC(0x9759617f),
QTC(0x93dbd6a0), QTC(0x90a0fd4e), QTC(0x8daad37b), QTC(0x8afb2cbb),
QTC(0x8893b125), QTC(0x8675dc4f), QTC(0x84a2fc62), QTC(0x831c314e),
QTC(0x81e26c16), QTC(0x80f66e3c), QTC(0x8058c94c), QTC(0x8009de7e),
};
RAM_ALIGN
LNK_SECTION_CONSTDATA
const FIXP_QTW qmf_phaseshift_sin64[] = {
QTC(0x03242abf), QTC(0x096a9049), QTC(0x0fab272b), QTC(0x15e21445),
QTC(0x1c0b826a), QTC(0x2223a4c5), QTC(0x2826b928), QTC(0x2e110a62),
QTC(0x33def287), QTC(0x398cdd32), QTC(0x3f1749b8), QTC(0x447acd50),
QTC(0x49b41533), QTC(0x4ebfe8a5), QTC(0x539b2af0), QTC(0x5842dd54),
QTC(0x5cb420e0), QTC(0x60ec3830), QTC(0x64e88926), QTC(0x68a69e81),
QTC(0x6c242960), QTC(0x6f5f02b2), QTC(0x72552c85), QTC(0x7504d345),
QTC(0x776c4edb), QTC(0x798a23b1), QTC(0x7b5d039e), QTC(0x7ce3ceb2),
QTC(0x7e1d93ea), QTC(0x7f0991c4), QTC(0x7fa736b4), QTC(0x7ff62182),
QTC(0x7ff62182), QTC(0x7fa736b4), QTC(0x7f0991c4), QTC(0x7e1d93ea),
QTC(0x7ce3ceb2), QTC(0x7b5d039e), QTC(0x798a23b1), QTC(0x776c4edb),
QTC(0x7504d345), QTC(0x72552c85), QTC(0x6f5f02b2), QTC(0x6c242960),
QTC(0x68a69e81), QTC(0x64e88926), QTC(0x60ec3830), QTC(0x5cb420e0),
QTC(0x5842dd54), QTC(0x539b2af0), QTC(0x4ebfe8a5), QTC(0x49b41533),
QTC(0x447acd50), QTC(0x3f1749b8), QTC(0x398cdd32), QTC(0x33def287),
QTC(0x2e110a62), QTC(0x2826b928), QTC(0x2223a4c5), QTC(0x1c0b826a),
QTC(0x15e21445), QTC(0x0fab272b), QTC(0x096a9049), QTC(0x03242abf),
};
/*
* Low Delay QMF aka CLDFB
*/
#if defined(QMF_COEFF_16BIT)
#define QTCFLLD(x) FL2FXCONST_SGL(x / (float)(1 << QMF_CLDFB_PFT_SCALE))
#define QTCFLLDT(x) FL2FXCONST_SGL(x)
#else
#define QTCFLLD(x) FL2FXCONST_DBL(x / (float)(1 << QMF_CLDFB_PFT_SCALE))
#define QTCFLLDT(x) FL2FXCONST_DBL(x)
#endif
#ifndef LOW_POWER_SBR_ONLY
/*!
\name QMF-Twiddle
\brief QMF twiddle factors
L=32, gain=2.0, angle = 0.75
*/
/* sin/cos (angle) / 2 */
const FIXP_QTW qmf_phaseshift_cos32_cldfb_ana[32] = {
/* analysis twiddle table */
QTCFLLDT(-7.071067e-01), QTCFLLDT(7.071070e-01), QTCFLLDT(7.071064e-01),
QTCFLLDT(-7.071073e-01), QTCFLLDT(-7.071061e-01), QTCFLLDT(7.071076e-01),
QTCFLLDT(7.071058e-01), QTCFLLDT(-7.071080e-01), QTCFLLDT(-7.071055e-01),
QTCFLLDT(7.071083e-01), QTCFLLDT(7.071052e-01), QTCFLLDT(-7.071086e-01),
QTCFLLDT(-7.071049e-01), QTCFLLDT(7.071089e-01), QTCFLLDT(7.071046e-01),
QTCFLLDT(-7.071092e-01), QTCFLLDT(-7.071042e-01), QTCFLLDT(7.071095e-01),
QTCFLLDT(7.071039e-01), QTCFLLDT(-7.071098e-01), QTCFLLDT(-7.071036e-01),
QTCFLLDT(7.071101e-01), QTCFLLDT(7.071033e-01), QTCFLLDT(-7.071104e-01),
QTCFLLDT(-7.071030e-01), QTCFLLDT(7.071107e-01), QTCFLLDT(7.071027e-01),
QTCFLLDT(-7.071111e-01), QTCFLLDT(-7.071024e-01), QTCFLLDT(7.071114e-01),
QTCFLLDT(7.071021e-01), QTCFLLDT(-7.071117e-01),
};
const FIXP_QTW qmf_phaseshift_cos32_cldfb_syn[32] = {
/* synthesis twiddle table */
QTCFLLDT(7.071067e-01), QTCFLLDT(-7.071070e-01), QTCFLLDT(-7.071064e-01),
QTCFLLDT(7.071073e-01), QTCFLLDT(7.071061e-01), QTCFLLDT(-7.071076e-01),
QTCFLLDT(-7.071058e-01), QTCFLLDT(7.071080e-01), QTCFLLDT(7.071055e-01),
QTCFLLDT(-7.071083e-01), QTCFLLDT(-7.071052e-01), QTCFLLDT(7.071086e-01),
QTCFLLDT(7.071049e-01), QTCFLLDT(-7.071089e-01), QTCFLLDT(-7.071046e-01),
QTCFLLDT(7.071092e-01), QTCFLLDT(7.071042e-01), QTCFLLDT(-7.071095e-01),
QTCFLLDT(-7.071039e-01), QTCFLLDT(7.071098e-01), QTCFLLDT(7.071036e-01),
QTCFLLDT(-7.071101e-01), QTCFLLDT(-7.071033e-01), QTCFLLDT(7.071104e-01),
QTCFLLDT(7.071030e-01), QTCFLLDT(-7.071107e-01), QTCFLLDT(-7.071027e-01),
QTCFLLDT(7.071111e-01), QTCFLLDT(7.071024e-01), QTCFLLDT(-7.071114e-01),
QTCFLLDT(-7.071021e-01), QTCFLLDT(7.071117e-01),
};
const FIXP_QTW qmf_phaseshift_sin32_cldfb[32] = {
QTCFLLDT(7.071068e-01), QTCFLLDT(7.071065e-01), QTCFLLDT(-7.071072e-01),
QTCFLLDT(-7.071062e-01), QTCFLLDT(7.071075e-01), QTCFLLDT(7.071059e-01),
QTCFLLDT(-7.071078e-01), QTCFLLDT(-7.071056e-01), QTCFLLDT(7.071081e-01),
QTCFLLDT(7.071053e-01), QTCFLLDT(-7.071084e-01), QTCFLLDT(-7.071050e-01),
QTCFLLDT(7.071087e-01), QTCFLLDT(7.071047e-01), QTCFLLDT(-7.071090e-01),
QTCFLLDT(-7.071044e-01), QTCFLLDT(7.071093e-01), QTCFLLDT(7.071041e-01),
QTCFLLDT(-7.071096e-01), QTCFLLDT(-7.071038e-01), QTCFLLDT(7.071099e-01),
QTCFLLDT(7.071034e-01), QTCFLLDT(-7.071103e-01), QTCFLLDT(-7.071031e-01),
QTCFLLDT(7.071106e-01), QTCFLLDT(7.071028e-01), QTCFLLDT(-7.071109e-01),
QTCFLLDT(-7.071025e-01), QTCFLLDT(7.071112e-01), QTCFLLDT(7.071022e-01),
QTCFLLDT(-7.071115e-01), QTCFLLDT(-7.071019e-01),
};
/* twiddles for X=(8,16) band qmf are copied from float simpleplayer
* implementation: qmf_phaseshift_cosX_cldfb_ana =
* QMFlib_twiddle3RealX_SBRLD_A qmf_phaseshift_cosX_cldfb_syn =
* -(QMFlib_twiddle3RealX_SBRLD_A) qmf_phaseshift_sinX_cldfb =
* QMFlib_twiddle3ImagX_SBRLD_A
*/
/* cos ((n + 0.5)*pi*angle/L) , order = 159, L=16 */
const FIXP_QTW qmf_phaseshift_cos16_cldfb_ana[16] = {
QTCFLLDT(-0.7071067812), QTCFLLDT(0.7071067812), QTCFLLDT(0.7071067812),
QTCFLLDT(-0.7071067812), QTCFLLDT(-0.7071067812), QTCFLLDT(0.7071067812),
QTCFLLDT(0.7071067812), QTCFLLDT(-0.7071067812), QTCFLLDT(-0.7071067812),
QTCFLLDT(0.7071067812), QTCFLLDT(0.7071067812), QTCFLLDT(-0.7071067812),
QTCFLLDT(-0.7071067812), QTCFLLDT(0.7071067812), QTCFLLDT(0.7071067812),
QTCFLLDT(-0.7071067812),
};
/* cos ((n + 0.5)*pi*angle/L) , order = 159, L=16 */
const FIXP_QTW qmf_phaseshift_cos16_cldfb_syn[16] = {
QTCFLLDT(0.7071067812), QTCFLLDT(-0.7071067812), QTCFLLDT(-0.7071067812),
QTCFLLDT(0.7071067812), QTCFLLDT(0.7071067812), QTCFLLDT(-0.7071067812),
QTCFLLDT(-0.7071067812), QTCFLLDT(0.7071067812), QTCFLLDT(0.7071067812),
QTCFLLDT(-0.7071067812), QTCFLLDT(-0.7071067812), QTCFLLDT(0.7071067812),
QTCFLLDT(0.7071067812), QTCFLLDT(-0.7071067812), QTCFLLDT(-0.7071067812),
QTCFLLDT(0.7071067812),
};
/* sin ((n + 0.5)*pi*angle/L) , order = 159, L=16 */
const FIXP_QTW qmf_phaseshift_sin16_cldfb[16] = {
QTCFLLDT(0.7071067812), QTCFLLDT(0.7071067812), QTCFLLDT(-0.7071067812),
QTCFLLDT(-0.7071067812), QTCFLLDT(0.7071067812), QTCFLLDT(0.7071067812),
QTCFLLDT(-0.7071067812), QTCFLLDT(-0.7071067812), QTCFLLDT(0.7071067812),
QTCFLLDT(0.7071067812), QTCFLLDT(-0.7071067812), QTCFLLDT(-0.7071067812),
QTCFLLDT(0.7071067812), QTCFLLDT(0.7071067812), QTCFLLDT(-0.7071067812),
QTCFLLDT(-0.7071067812),
};
/* cos ((n + 0.5)*pi*angle/L) , order = 79, L=8 */
const FIXP_QTW qmf_phaseshift_cos8_cldfb_ana[8] = {
QTCFLLDT(-0.7071067812), QTCFLLDT(0.7071067812), QTCFLLDT(0.7071067812),
QTCFLLDT(-0.7071067812), QTCFLLDT(-0.7071067812), QTCFLLDT(0.7071067812),
QTCFLLDT(0.7071067812), QTCFLLDT(-0.7071067812),
};
const FIXP_QTW qmf_phaseshift_cos8_cldfb_syn[8] = {
QTCFLLDT(0.7071067812), QTCFLLDT(-0.7071067812), QTCFLLDT(-0.7071067812),
QTCFLLDT(0.7071067812), QTCFLLDT(0.7071067812), QTCFLLDT(-0.7071067812),
QTCFLLDT(-0.7071067812), QTCFLLDT(0.7071067812),
};
/* sin ((n + 0.5)*pi*angle/L) , order = 79, L=8 */
const FIXP_QTW qmf_phaseshift_sin8_cldfb[8] = {
QTCFLLDT(0.7071067812), QTCFLLDT(0.7071067812), QTCFLLDT(-0.7071067812),
QTCFLLDT(-0.7071067812), QTCFLLDT(0.7071067812), QTCFLLDT(0.7071067812),
QTCFLLDT(-0.7071067812), QTCFLLDT(-0.7071067812),
};
/* sin/cos (angle) / 128 */
const FIXP_QTW qmf_phaseshift_cos64_cldfb[64] = {
QTCFLLDT(7.071068e-01), QTCFLLDT(-7.071066e-01), QTCFLLDT(-7.071070e-01),
QTCFLLDT(7.071065e-01), QTCFLLDT(7.071072e-01), QTCFLLDT(-7.071063e-01),
QTCFLLDT(-7.071074e-01), QTCFLLDT(7.071061e-01), QTCFLLDT(7.071075e-01),
QTCFLLDT(-7.071059e-01), QTCFLLDT(-7.071078e-01), QTCFLLDT(7.071057e-01),
QTCFLLDT(7.071080e-01), QTCFLLDT(-7.071055e-01), QTCFLLDT(-7.071081e-01),
QTCFLLDT(7.071053e-01), QTCFLLDT(7.071083e-01), QTCFLLDT(-7.071052e-01),
QTCFLLDT(-7.071085e-01), QTCFLLDT(7.071050e-01), QTCFLLDT(7.071087e-01),
QTCFLLDT(-7.071048e-01), QTCFLLDT(-7.071089e-01), QTCFLLDT(7.071046e-01),
QTCFLLDT(7.071090e-01), QTCFLLDT(-7.071044e-01), QTCFLLDT(-7.071092e-01),
QTCFLLDT(7.071042e-01), QTCFLLDT(7.071095e-01), QTCFLLDT(-7.071040e-01),
QTCFLLDT(-7.071096e-01), QTCFLLDT(7.071038e-01), QTCFLLDT(7.071098e-01),
QTCFLLDT(-7.071037e-01), QTCFLLDT(-7.071100e-01), QTCFLLDT(7.071035e-01),
QTCFLLDT(7.071102e-01), QTCFLLDT(-7.071033e-01), QTCFLLDT(-7.071103e-01),
QTCFLLDT(7.071031e-01), QTCFLLDT(7.071105e-01), QTCFLLDT(-7.071030e-01),
QTCFLLDT(-7.071107e-01), QTCFLLDT(7.071028e-01), QTCFLLDT(7.071109e-01),
QTCFLLDT(-7.071025e-01), QTCFLLDT(-7.071111e-01), QTCFLLDT(7.071024e-01),
QTCFLLDT(7.071113e-01), QTCFLLDT(-7.071022e-01), QTCFLLDT(-7.071115e-01),
QTCFLLDT(7.071020e-01), QTCFLLDT(7.071117e-01), QTCFLLDT(-7.071018e-01),
QTCFLLDT(-7.071118e-01), QTCFLLDT(7.071016e-01), QTCFLLDT(7.071120e-01),
QTCFLLDT(-7.071015e-01), QTCFLLDT(-7.071122e-01), QTCFLLDT(7.071013e-01),
QTCFLLDT(7.071124e-01), QTCFLLDT(-7.071011e-01), QTCFLLDT(-7.071126e-01),
QTCFLLDT(7.071009e-01),
};
const FIXP_QTW qmf_phaseshift_sin64_cldfb[64] = {
QTCFLLDT(7.071067e-01), QTCFLLDT(7.071069e-01), QTCFLLDT(-7.071065e-01),
QTCFLLDT(-7.071071e-01), QTCFLLDT(7.071064e-01), QTCFLLDT(7.071073e-01),
QTCFLLDT(-7.071062e-01), QTCFLLDT(-7.071075e-01), QTCFLLDT(7.071060e-01),
QTCFLLDT(7.071077e-01), QTCFLLDT(-7.071058e-01), QTCFLLDT(-7.071078e-01),
QTCFLLDT(7.071056e-01), QTCFLLDT(7.071080e-01), QTCFLLDT(-7.071055e-01),
QTCFLLDT(-7.071082e-01), QTCFLLDT(7.071053e-01), QTCFLLDT(7.071084e-01),
QTCFLLDT(-7.071050e-01), QTCFLLDT(-7.071086e-01), QTCFLLDT(7.071049e-01),
QTCFLLDT(7.071088e-01), QTCFLLDT(-7.071047e-01), QTCFLLDT(-7.071090e-01),
QTCFLLDT(7.071045e-01), QTCFLLDT(7.071092e-01), QTCFLLDT(-7.071043e-01),
QTCFLLDT(-7.071093e-01), QTCFLLDT(7.071041e-01), QTCFLLDT(7.071095e-01),
QTCFLLDT(-7.071040e-01), QTCFLLDT(-7.071097e-01), QTCFLLDT(7.071038e-01),
QTCFLLDT(7.071099e-01), QTCFLLDT(-7.071036e-01), QTCFLLDT(-7.071100e-01),
QTCFLLDT(7.071034e-01), QTCFLLDT(7.071103e-01), QTCFLLDT(-7.071032e-01),
QTCFLLDT(-7.071105e-01), QTCFLLDT(7.071030e-01), QTCFLLDT(7.071106e-01),
QTCFLLDT(-7.071028e-01), QTCFLLDT(-7.071108e-01), QTCFLLDT(7.071027e-01),
QTCFLLDT(7.071110e-01), QTCFLLDT(-7.071025e-01), QTCFLLDT(-7.071112e-01),
QTCFLLDT(7.071023e-01), QTCFLLDT(7.071114e-01), QTCFLLDT(-7.071021e-01),
QTCFLLDT(-7.071115e-01), QTCFLLDT(7.071019e-01), QTCFLLDT(7.071117e-01),
QTCFLLDT(-7.071017e-01), QTCFLLDT(-7.071120e-01), QTCFLLDT(7.071015e-01),
QTCFLLDT(7.071121e-01), QTCFLLDT(-7.071013e-01), QTCFLLDT(-7.071123e-01),
QTCFLLDT(7.071012e-01), QTCFLLDT(7.071125e-01), QTCFLLDT(-7.071010e-01),
QTCFLLDT(-7.071127e-01),
};
//@}
#endif /* #ifdef LOW_POWER_SBR_ONLY */
/*!
\name QMF
\brief QMF-Table
64 channels, N = 640, optimized by PE 010516
The coeffs are rearranged compared with the reference in the following
way:
sbr_qmf_64[0] = sbr_qmf_64_reference[0];
sbr_qmf_64[1] = sbr_qmf_64_reference[128];
sbr_qmf_64[2] = sbr_qmf_64_reference[256];
sbr_qmf_64[3] = sbr_qmf_64_reference[384];
sbr_qmf_64[4] = sbr_qmf_64_reference[512];
sbr_qmf_64[5] = sbr_qmf_64_reference[1];
sbr_qmf_64[6] = sbr_qmf_64_reference[129];
sbr_qmf_64[7] = sbr_qmf_64_reference[257];
sbr_qmf_64[8] = sbr_qmf_64_reference[385];
sbr_qmf_64[9] = sbr_qmf_64_reference[513];
.
.
.
sbr_qmf_64[635] = sbr_qmf_64_reference[127]
sbr_qmf_64[636] = sbr_qmf_64_reference[255];
sbr_qmf_64[637] = sbr_qmf_64_reference[383];
sbr_qmf_64[638] = sbr_qmf_64_reference[511];
sbr_qmf_64[639] = sbr_qmf_64_reference[639];
Symmetric properties of qmf coeffs:
Use point symmetry:
sbr_qmf_64_640_qmf[320..634] = p_64_640_qmf[314..0]
Max sum of all FIR filter absolute coefficients is: 0x7FF5B201
thus, the filter output is not required to be scaled.
\showinitializer
*/
//@{
LNK_SECTION_CONSTDATA_L1
RAM_ALIGN
const FIXP_PFT qmf_cldfb_640[QMF640_CLDFB_PFT_TABLE_SIZE] = {
QTCFLLD(6.571760e-07), QTCFLLD(-8.010079e-06), QTCFLLD(-1.250743e-03),
QTCFLLD(8.996371e-03), QTCFLLD(5.128557e-01), QTCFLLD(4.118360e-07),
QTCFLLD(-1.469933e-05), QTCFLLD(-1.194743e-03), QTCFLLD(9.640299e-03),
QTCFLLD(5.299510e-01), QTCFLLD(8.109952e-07), QTCFLLD(4.840578e-06),
QTCFLLD(-1.151796e-03), QTCFLLD(1.033126e-02), QTCFLLD(5.470652e-01),
QTCFLLD(7.099633e-07), QTCFLLD(7.167101e-06), QTCFLLD(-1.099001e-03),
QTCFLLD(1.106959e-02), QTCFLLD(5.641523e-01), QTCFLLD(6.834210e-07),
QTCFLLD(1.088325e-05), QTCFLLD(-1.047655e-03), QTCFLLD(1.186211e-02),
QTCFLLD(5.811993e-01), QTCFLLD(4.292862e-07), QTCFLLD(1.013260e-05),
QTCFLLD(-9.862027e-04), QTCFLLD(1.270747e-02), QTCFLLD(5.981877e-01),
QTCFLLD(-5.426597e-09), QTCFLLD(5.869707e-06), QTCFLLD(-9.294665e-04),
QTCFLLD(1.361072e-02), QTCFLLD(6.151031e-01), QTCFLLD(6.355303e-08),
QTCFLLD(1.125135e-05), QTCFLLD(-9.767709e-04), QTCFLLD(1.456209e-02),
QTCFLLD(6.319284e-01), QTCFLLD(5.490570e-07), QTCFLLD(2.015445e-05),
QTCFLLD(-1.040598e-03), QTCFLLD(1.557759e-02), QTCFLLD(6.486438e-01),
QTCFLLD(1.620171e-06), QTCFLLD(2.800456e-05), QTCFLLD(-1.146268e-03),
QTCFLLD(1.665188e-02), QTCFLLD(6.652304e-01), QTCFLLD(-6.025110e-10),
QTCFLLD(8.975978e-06), QTCFLLD(-1.292866e-03), QTCFLLD(1.778249e-02),
QTCFLLD(6.816668e-01), QTCFLLD(-6.325664e-10), QTCFLLD(8.563820e-06),
QTCFLLD(-1.196638e-03), QTCFLLD(1.897506e-02), QTCFLLD(6.979337e-01),
QTCFLLD(-4.013525e-09), QTCFLLD(1.168895e-05), QTCFLLD(-9.726699e-04),
QTCFLLD(2.023525e-02), QTCFLLD(7.140087e-01), QTCFLLD(-4.244091e-09),
QTCFLLD(7.300589e-06), QTCFLLD(-8.029620e-04), QTCFLLD(2.156305e-02),
QTCFLLD(7.298746e-01), QTCFLLD(-1.846548e-08), QTCFLLD(3.965364e-06),
QTCFLLD(-6.754936e-04), QTCFLLD(2.296471e-02), QTCFLLD(7.455112e-01),
QTCFLLD(-3.870537e-09), QTCFLLD(1.374896e-06), QTCFLLD(-5.791145e-04),
QTCFLLD(2.443434e-02), QTCFLLD(7.609051e-01), QTCFLLD(-8.883499e-10),
QTCFLLD(3.798520e-07), QTCFLLD(-4.733148e-04), QTCFLLD(2.597957e-02),
QTCFLLD(7.760386e-01), QTCFLLD(5.303528e-08), QTCFLLD(4.469729e-06),
QTCFLLD(-2.998740e-04), QTCFLLD(2.760091e-02), QTCFLLD(7.908995e-01),
QTCFLLD(7.391974e-08), QTCFLLD(2.461877e-05), QTCFLLD(7.882620e-05),
QTCFLLD(2.931526e-02), QTCFLLD(8.054701e-01), QTCFLLD(1.723217e-09),
QTCFLLD(4.005269e-05), QTCFLLD(4.708010e-04), QTCFLLD(3.110861e-02),
QTCFLLD(8.197387e-01), QTCFLLD(2.443085e-07), QTCFLLD(5.272982e-05),
QTCFLLD(8.089812e-04), QTCFLLD(3.298151e-02), QTCFLLD(8.336864e-01),
QTCFLLD(1.387567e-08), QTCFLLD(4.939392e-05), QTCFLLD(1.127142e-03),
QTCFLLD(3.493300e-02), QTCFLLD(8.472987e-01), QTCFLLD(-5.690531e-06),
QTCFLLD(-4.256442e-05), QTCFLLD(1.417367e-03), QTCFLLD(3.696343e-02),
QTCFLLD(8.605543e-01), QTCFLLD(3.629067e-06), QTCFLLD(6.582328e-05),
QTCFLLD(1.725030e-03), QTCFLLD(3.907138e-02), QTCFLLD(8.734367e-01),
QTCFLLD(-5.393556e-08), QTCFLLD(6.481921e-05), QTCFLLD(1.948069e-03),
QTCFLLD(4.125570e-02), QTCFLLD(8.859232e-01), QTCFLLD(1.349944e-07),
QTCFLLD(3.367998e-05), QTCFLLD(2.033465e-03), QTCFLLD(4.355568e-02),
QTCFLLD(8.979959e-01), QTCFLLD(7.326611e-09), QTCFLLD(4.694252e-05),
QTCFLLD(2.239143e-03), QTCFLLD(4.599068e-02), QTCFLLD(9.096311e-01),
QTCFLLD(2.399696e-07), QTCFLLD(6.904415e-05), QTCFLLD(2.470456e-03),
QTCFLLD(4.849285e-02), QTCFLLD(9.208195e-01), QTCFLLD(3.330982e-07),
QTCFLLD(5.643103e-05), QTCFLLD(2.630472e-03), QTCFLLD(5.105621e-02),
QTCFLLD(9.315442e-01), QTCFLLD(4.767794e-07), QTCFLLD(7.095887e-05),
QTCFLLD(2.703019e-03), QTCFLLD(5.368313e-02), QTCFLLD(9.417976e-01),
QTCFLLD(3.428661e-07), QTCFLLD(7.872593e-05), QTCFLLD(2.729137e-03),
QTCFLLD(5.637219e-02), QTCFLLD(9.515675e-01), QTCFLLD(8.676848e-06),
QTCFLLD(2.666445e-04), QTCFLLD(2.719749e-03), QTCFLLD(5.911363e-02),
QTCFLLD(9.608520e-01), QTCFLLD(2.722296e-05), QTCFLLD(5.822201e-04),
QTCFLLD(2.530907e-03), QTCFLLD(6.192693e-02), QTCFLLD(9.696426e-01),
QTCFLLD(3.575651e-07), QTCFLLD(7.870355e-05), QTCFLLD(2.225524e-03),
QTCFLLD(6.480449e-02), QTCFLLD(9.779405e-01), QTCFLLD(6.293002e-07),
QTCFLLD(7.245096e-05), QTCFLLD(1.891972e-03), QTCFLLD(6.771675e-02),
QTCFLLD(9.857388e-01), QTCFLLD(1.070243e-06), QTCFLLD(7.194151e-05),
QTCFLLD(1.557112e-03), QTCFLLD(7.064948e-02), QTCFLLD(9.930380e-01),
QTCFLLD(-3.225913e-07), QTCFLLD(-7.679955e-05), QTCFLLD(1.194731e-03),
QTCFLLD(7.360559e-02), QTCFLLD(9.998286e-01), QTCFLLD(-9.597516e-09),
QTCFLLD(-6.093373e-05), QTCFLLD(6.415402e-04), QTCFLLD(7.657650e-02),
QTCFLLD(1.006109e+00), QTCFLLD(-8.908041e-08), QTCFLLD(-1.721347e-05),
QTCFLLD(1.092526e-04), QTCFLLD(7.955571e-02), QTCFLLD(1.011868e+00),
QTCFLLD(-2.285563e-05), QTCFLLD(-8.882305e-05), QTCFLLD(2.934876e-04),
QTCFLLD(8.251962e-02), QTCFLLD(1.017100e+00), QTCFLLD(1.013575e-05),
QTCFLLD(6.418658e-05), QTCFLLD(5.721223e-04), QTCFLLD(8.547716e-02),
QTCFLLD(1.021799e+00), QTCFLLD(-1.706941e-05), QTCFLLD(1.769262e-04),
QTCFLLD(6.976561e-04), QTCFLLD(8.841813e-02), QTCFLLD(1.025967e+00),
QTCFLLD(1.356728e-06), QTCFLLD(2.206341e-05), QTCFLLD(7.376101e-04),
QTCFLLD(9.133591e-02), QTCFLLD(1.029601e+00), QTCFLLD(-1.398913e-08),
QTCFLLD(-6.538879e-06), QTCFLLD(7.154124e-04), QTCFLLD(9.421624e-02),
QTCFLLD(1.032713e+00), QTCFLLD(3.552992e-08), QTCFLLD(-1.052707e-05),
QTCFLLD(7.139920e-04), QTCFLLD(9.705240e-02), QTCFLLD(1.035312e+00),
QTCFLLD(4.211177e-07), QTCFLLD(-9.075431e-06), QTCFLLD(6.944123e-04),
QTCFLLD(9.982958e-02), QTCFLLD(1.037422e+00), QTCFLLD(5.433719e-07),
QTCFLLD(-1.748285e-05), QTCFLLD(6.766320e-04), QTCFLLD(1.025398e-01),
QTCFLLD(1.039062e+00), QTCFLLD(8.226600e-08), QTCFLLD(-3.498286e-05),
QTCFLLD(6.887784e-04), QTCFLLD(1.051642e-01), QTCFLLD(1.040262e+00),
QTCFLLD(1.272705e-07), QTCFLLD(-4.489491e-05), QTCFLLD(6.673250e-04),
QTCFLLD(1.076972e-01), QTCFLLD(1.041043e+00), QTCFLLD(2.542598e-07),
QTCFLLD(-5.449816e-05), QTCFLLD(5.970697e-04), QTCFLLD(1.101216e-01),
QTCFLLD(1.041434e+00), QTCFLLD(6.322770e-07), QTCFLLD(-5.874199e-05),
QTCFLLD(4.749931e-04), QTCFLLD(1.124296e-01), QTCFLLD(1.041443e+00),
QTCFLLD(2.801882e-08), QTCFLLD(-7.934510e-05), QTCFLLD(3.189336e-04),
QTCFLLD(1.146042e-01), QTCFLLD(1.041087e+00), QTCFLLD(5.891904e-07),
QTCFLLD(-8.039232e-05), QTCFLLD(1.218226e-04), QTCFLLD(1.166399e-01),
QTCFLLD(1.040350e+00), QTCFLLD(7.301957e-07), QTCFLLD(-9.907631e-05),
QTCFLLD(-1.324292e-04), QTCFLLD(1.185243e-01), QTCFLLD(1.039228e+00),
QTCFLLD(-4.518603e-06), QTCFLLD(-2.217025e-04), QTCFLLD(-4.268575e-04),
QTCFLLD(1.202546e-01), QTCFLLD(1.037683e+00), QTCFLLD(-3.561585e-06),
QTCFLLD(-2.415166e-04), QTCFLLD(-7.804546e-04), QTCFLLD(1.218184e-01),
QTCFLLD(1.035694e+00), QTCFLLD(-1.074717e-07), QTCFLLD(-2.123672e-04),
QTCFLLD(-1.156680e-03), QTCFLLD(1.232132e-01), QTCFLLD(1.033206e+00),
QTCFLLD(1.323268e-06), QTCFLLD(-2.078299e-04), QTCFLLD(-1.525819e-03),
QTCFLLD(1.244270e-01), QTCFLLD(1.030199e+00), QTCFLLD(3.377815e-06),
QTCFLLD(-1.885286e-04), QTCFLLD(-1.914115e-03), QTCFLLD(1.254605e-01),
QTCFLLD(1.026616e+00), QTCFLLD(5.161607e-06), QTCFLLD(-1.728673e-04),
QTCFLLD(-2.292814e-03), QTCFLLD(1.262996e-01), QTCFLLD(1.022470e+00),
QTCFLLD(5.924001e-06), QTCFLLD(-1.744842e-04), QTCFLLD(-2.658042e-03),
QTCFLLD(1.269416e-01), QTCFLLD(1.017729e+00), QTCFLLD(6.310208e-06),
QTCFLLD(-1.784193e-04), QTCFLLD(-3.000423e-03), QTCFLLD(1.273648e-01),
QTCFLLD(1.012508e+00), QTCFLLD(3.357219e-06), QTCFLLD(-2.131406e-04),
QTCFLLD(-3.318858e-03), QTCFLLD(1.275561e-01), QTCFLLD(1.006893e+00),
QTCFLLD(5.189087e-06), QTCFLLD(-2.078886e-04), QTCFLLD(-3.597476e-03),
QTCFLLD(1.274568e-01), QTCFLLD(1.001463e+00), QTCFLLD(4.178050e-06),
QTCFLLD(-4.663778e-05), QTCFLLD(-3.870852e-03), QTCFLLD(1.273591e-01),
QTCFLLD(9.927544e-01), QTCFLLD(5.364807e-06), QTCFLLD(-5.889277e-06),
QTCFLLD(-4.135130e-03), QTCFLLD(1.272499e-01), QTCFLLD(9.807692e-01),
QTCFLLD(4.083719e-06), QTCFLLD(-1.774108e-05), QTCFLLD(-4.351668e-03),
QTCFLLD(1.268281e-01), QTCFLLD(9.690017e-01), QTCFLLD(3.567581e-06),
QTCFLLD(-2.599468e-08), QTCFLLD(-4.517190e-03), QTCFLLD(1.261262e-01),
QTCFLLD(9.568886e-01), QTCFLLD(3.262754e-06), QTCFLLD(1.260640e-05),
QTCFLLD(-4.636228e-03), QTCFLLD(1.251477e-01), QTCFLLD(9.443803e-01),
QTCFLLD(2.041128e-06), QTCFLLD(2.364519e-05), QTCFLLD(-4.704321e-03),
QTCFLLD(1.238869e-01), QTCFLLD(9.313874e-01), QTCFLLD(-2.567965e-08),
QTCFLLD(2.806963e-05), QTCFLLD(-4.722568e-03), QTCFLLD(1.223371e-01),
QTCFLLD(9.179666e-01), QTCFLLD(2.714879e-07), QTCFLLD(4.493916e-05),
QTCFLLD(-4.663276e-03), QTCFLLD(1.204854e-01), QTCFLLD(9.041286e-01),
QTCFLLD(2.150884e-06), QTCFLLD(5.408155e-05), QTCFLLD(-4.554811e-03),
QTCFLLD(1.183233e-01), QTCFLLD(8.899474e-01), QTCFLLD(5.818595e-06),
QTCFLLD(3.759630e-05), QTCFLLD(-4.369554e-03), QTCFLLD(1.158359e-01),
QTCFLLD(8.754641e-01), QTCFLLD(-1.686137e-09), QTCFLLD(2.515118e-05),
QTCFLLD(-4.091033e-03), QTCFLLD(1.130180e-01), QTCFLLD(8.607492e-01),
QTCFLLD(-1.775191e-09), QTCFLLD(2.406517e-05), QTCFLLD(-3.794425e-03),
QTCFLLD(1.098551e-01), QTCFLLD(8.458450e-01), QTCFLLD(-2.222072e-09),
QTCFLLD(3.628511e-05), QTCFLLD(-3.460363e-03), QTCFLLD(1.063455e-01),
QTCFLLD(8.308040e-01), QTCFLLD(-1.280675e-08), QTCFLLD(2.241546e-05),
QTCFLLD(-3.064311e-03), QTCFLLD(1.024805e-01), QTCFLLD(8.156523e-01),
QTCFLLD(-6.977078e-08), QTCFLLD(1.499170e-05), QTCFLLD(-2.621537e-03),
QTCFLLD(9.826251e-02), QTCFLLD(8.004165e-01), QTCFLLD(-1.409927e-08),
QTCFLLD(5.009913e-06), QTCFLLD(-2.124648e-03), QTCFLLD(9.368652e-02),
QTCFLLD(7.851012e-01), QTCFLLD(-2.986489e-09), QTCFLLD(1.277184e-06),
QTCFLLD(-1.594861e-03), QTCFLLD(8.875756e-02), QTCFLLD(7.697093e-01),
QTCFLLD(1.876022e-07), QTCFLLD(1.580189e-05), QTCFLLD(-1.061499e-03),
QTCFLLD(8.347151e-02), QTCFLLD(7.542294e-01), QTCFLLD(1.737277e-07),
QTCFLLD(5.533953e-05), QTCFLLD(-6.169855e-04), QTCFLLD(7.783300e-02),
QTCFLLD(7.386515e-01), QTCFLLD(3.818589e-09), QTCFLLD(8.870182e-05),
QTCFLLD(-2.004823e-04), QTCFLLD(7.184074e-02), QTCFLLD(7.229599e-01),
QTCFLLD(5.143615e-07), QTCFLLD(1.035783e-04), QTCFLLD(2.048499e-04),
QTCFLLD(6.550209e-02), QTCFLLD(7.071448e-01), QTCFLLD(2.820292e-08),
QTCFLLD(9.990758e-05), QTCFLLD(5.621721e-04), QTCFLLD(5.881297e-02),
QTCFLLD(6.911982e-01), QTCFLLD(4.677016e-06), QTCFLLD(1.181078e-04),
QTCFLLD(9.373975e-04), QTCFLLD(5.177965e-02), QTCFLLD(6.751199e-01),
QTCFLLD(3.361682e-06), QTCFLLD(2.126365e-05), QTCFLLD(1.344657e-03),
QTCFLLD(4.439684e-02), QTCFLLD(6.589149e-01), QTCFLLD(-4.880845e-08),
QTCFLLD(5.861800e-05), QTCFLLD(1.812176e-03), QTCFLLD(3.666943e-02),
QTCFLLD(6.425940e-01), QTCFLLD(2.267731e-07), QTCFLLD(5.021906e-05),
QTCFLLD(2.172866e-03), QTCFLLD(2.857528e-02), QTCFLLD(6.261725e-01),
QTCFLLD(5.158213e-09), QTCFLLD(4.150075e-05), QTCFLLD(1.985825e-03),
QTCFLLD(2.012237e-02), QTCFLLD(6.096690e-01), QTCFLLD(-2.066962e-07),
QTCFLLD(3.799972e-05), QTCFLLD(1.697653e-03), QTCFLLD(1.132324e-02),
QTCFLLD(5.930982e-01), QTCFLLD(4.883305e-07), QTCFLLD(6.606462e-05),
QTCFLLD(1.471167e-03), QTCFLLD(2.184257e-03), QTCFLLD(5.764735e-01),
QTCFLLD(8.254430e-07), QTCFLLD(9.755685e-05), QTCFLLD(1.232134e-03),
QTCFLLD(-7.298198e-03), QTCFLLD(5.598052e-01), QTCFLLD(9.464783e-07),
QTCFLLD(1.831121e-04), QTCFLLD(8.990256e-04), QTCFLLD(-1.711324e-02),
QTCFLLD(5.430990e-01), QTCFLLD(-1.232693e-05), QTCFLLD(-5.901618e-07),
QTCFLLD(6.150317e-04), QTCFLLD(-2.726484e-02), QTCFLLD(5.263554e-01),
QTCFLLD(3.867483e-05), QTCFLLD(-3.595054e-04), QTCFLLD(6.307841e-04),
QTCFLLD(-3.775928e-02), QTCFLLD(5.095721e-01), QTCFLLD(-9.870548e-07),
QTCFLLD(-1.815837e-04), QTCFLLD(4.366447e-04), QTCFLLD(-4.859006e-02),
QTCFLLD(4.927464e-01), QTCFLLD(-1.089501e-06), QTCFLLD(-9.204876e-05),
QTCFLLD(1.498232e-04), QTCFLLD(-5.973742e-02), QTCFLLD(4.758754e-01),
QTCFLLD(-1.569003e-06), QTCFLLD(-5.192444e-05), QTCFLLD(-9.099723e-05),
QTCFLLD(-7.120357e-02), QTCFLLD(4.589583e-01), QTCFLLD(-2.778618e-07),
QTCFLLD(6.487880e-05), QTCFLLD(-3.337967e-04), QTCFLLD(-8.298103e-02),
QTCFLLD(4.420014e-01), QTCFLLD(6.757015e-09), QTCFLLD(5.397065e-05),
QTCFLLD(-5.599348e-04), QTCFLLD(-9.506967e-02), QTCFLLD(4.250144e-01),
QTCFLLD(1.496436e-07), QTCFLLD(2.472024e-05), QTCFLLD(-7.677634e-04),
QTCFLLD(-1.074631e-01), QTCFLLD(4.080155e-01), QTCFLLD(2.068297e-05),
QTCFLLD(9.711682e-05), QTCFLLD(-9.730460e-04), QTCFLLD(-1.201629e-01),
QTCFLLD(3.910244e-01), QTCFLLD(-9.388963e-06), QTCFLLD(5.144969e-05),
QTCFLLD(-1.131860e-03), QTCFLLD(-1.331545e-01), QTCFLLD(3.740644e-01),
QTCFLLD(-1.402925e-05), QTCFLLD(-1.039264e-04), QTCFLLD(-1.283281e-03),
QTCFLLD(-1.464389e-01), QTCFLLD(3.571528e-01), QTCFLLD(-2.757611e-06),
QTCFLLD(2.853437e-06), QTCFLLD(-1.480543e-03), QTCFLLD(-1.600062e-01),
QTCFLLD(3.403074e-01), QTCFLLD(2.945239e-08), QTCFLLD(1.334091e-05),
QTCFLLD(-1.699161e-03), QTCFLLD(-1.738542e-01), QTCFLLD(3.235299e-01),
QTCFLLD(-7.873304e-08), QTCFLLD(2.443161e-05), QTCFLLD(-1.924845e-03),
QTCFLLD(-1.879712e-01), QTCFLLD(3.068187e-01), QTCFLLD(-9.897194e-07),
QTCFLLD(3.568555e-05), QTCFLLD(-2.152380e-03), QTCFLLD(-2.023548e-01),
QTCFLLD(2.901491e-01), QTCFLLD(-1.922074e-06), QTCFLLD(6.193370e-05),
QTCFLLD(-2.396404e-03), QTCFLLD(-2.169926e-01), QTCFLLD(2.734977e-01),
QTCFLLD(-2.765650e-07), QTCFLLD(1.176237e-04), QTCFLLD(-2.653819e-03),
QTCFLLD(-2.318815e-01), QTCFLLD(2.568176e-01), QTCFLLD(-4.636105e-07),
QTCFLLD(1.635906e-04), QTCFLLD(-2.927159e-03), QTCFLLD(-2.470098e-01),
QTCFLLD(2.400768e-01), QTCFLLD(-9.607069e-07), QTCFLLD(2.060394e-04),
QTCFLLD(-3.209093e-03), QTCFLLD(-2.623749e-01), QTCFLLD(2.232277e-01),
QTCFLLD(-1.907927e-06), QTCFLLD(2.346981e-04), QTCFLLD(-3.505531e-03),
QTCFLLD(-2.779638e-01), QTCFLLD(2.062605e-01), QTCFLLD(-1.551251e-08),
QTCFLLD(2.520607e-04), QTCFLLD(-3.811612e-03), QTCFLLD(-2.937725e-01),
QTCFLLD(1.891590e-01), QTCFLLD(-1.653464e-06), QTCFLLD(2.556450e-04),
QTCFLLD(-4.133640e-03), QTCFLLD(-3.097862e-01), QTCFLLD(1.719726e-01),
QTCFLLD(-2.043464e-06), QTCFLLD(3.157664e-04), QTCFLLD(-4.448993e-03),
QTCFLLD(-3.259994e-01), QTCFLLD(1.547461e-01), QTCFLLD(1.622786e-05),
QTCFLLD(6.205676e-04), QTCFLLD(-4.754192e-03), QTCFLLD(-3.423942e-01),
QTCFLLD(1.376150e-01), QTCFLLD(1.395221e-05), QTCFLLD(7.847840e-04),
QTCFLLD(-5.063851e-03), QTCFLLD(-3.589627e-01), QTCFLLD(1.206924e-01),
QTCFLLD(4.591010e-07), QTCFLLD(9.019129e-04), QTCFLLD(-5.394570e-03),
QTCFLLD(-3.756822e-01), QTCFLLD(1.042033e-01), QTCFLLD(-6.261944e-06),
QTCFLLD(1.054963e-03), QTCFLLD(-5.741103e-03), QTCFLLD(-3.925409e-01),
QTCFLLD(8.829745e-02), QTCFLLD(-1.606051e-05), QTCFLLD(1.089429e-03),
QTCFLLD(-6.109179e-03), QTCFLLD(-4.095160e-01), QTCFLLD(7.325979e-02),
QTCFLLD(-2.464228e-05), QTCFLLD(1.122503e-03), QTCFLLD(-6.500503e-03),
QTCFLLD(-4.265950e-01), QTCFLLD(5.918678e-02), QTCFLLD(-2.976824e-05),
QTCFLLD(1.177515e-03), QTCFLLD(-6.925141e-03), QTCFLLD(-4.437530e-01),
QTCFLLD(4.634696e-02), QTCFLLD(-3.177468e-05), QTCFLLD(1.226113e-03),
QTCFLLD(-7.380544e-03), QTCFLLD(-4.609829e-01), QTCFLLD(3.450719e-02),
QTCFLLD(-4.373302e-05), QTCFLLD(1.263569e-03), QTCFLLD(-7.876393e-03),
QTCFLLD(-4.782650e-01), QTCFLLD(2.353060e-02), QTCFLLD(-3.299004e-05),
QTCFLLD(1.287819e-03), QTCFLLD(-8.407749e-03), QTCFLLD(-4.956175e-01),
QTCFLLD(1.129580e-02),
};
RAM_ALIGN
const FIXP_PFT qmf_cldfb_320[QMF320_CLDFB_PFT_TABLE_SIZE] = {
QTCFLLD(5.345060e-07), QTCFLLD(-1.135471e-05), QTCFLLD(-1.222743e-03),
QTCFLLD(9.318335e-03), QTCFLLD(5.214033e-01), QTCFLLD(7.604792e-07),
QTCFLLD(6.003839e-06), QTCFLLD(-1.125398e-03), QTCFLLD(1.070043e-02),
QTCFLLD(5.556087e-01), QTCFLLD(5.563536e-07), QTCFLLD(1.050792e-05),
QTCFLLD(-1.016929e-03), QTCFLLD(1.228479e-02), QTCFLLD(5.896935e-01),
QTCFLLD(2.906322e-08), QTCFLLD(8.560527e-06), QTCFLLD(-9.531187e-04),
QTCFLLD(1.408640e-02), QTCFLLD(6.235157e-01), QTCFLLD(1.084614e-06),
QTCFLLD(2.407951e-05), QTCFLLD(-1.093433e-03), QTCFLLD(1.611474e-02),
QTCFLLD(6.569371e-01), QTCFLLD(-6.175387e-10), QTCFLLD(8.769899e-06),
QTCFLLD(-1.244752e-03), QTCFLLD(1.837877e-02), QTCFLLD(6.898003e-01),
QTCFLLD(-4.128808e-09), QTCFLLD(9.494767e-06), QTCFLLD(-8.878160e-04),
QTCFLLD(2.089915e-02), QTCFLLD(7.219416e-01), QTCFLLD(-1.116801e-08),
QTCFLLD(2.670130e-06), QTCFLLD(-6.273041e-04), QTCFLLD(2.369952e-02),
QTCFLLD(7.532082e-01), QTCFLLD(2.607347e-08), QTCFLLD(2.424790e-06),
QTCFLLD(-3.865944e-04), QTCFLLD(2.679024e-02), QTCFLLD(7.834691e-01),
QTCFLLD(3.782148e-08), QTCFLLD(3.233573e-05), QTCFLLD(2.748136e-04),
QTCFLLD(3.021193e-02), QTCFLLD(8.126044e-01), QTCFLLD(1.290921e-07),
QTCFLLD(5.106187e-05), QTCFLLD(9.680615e-04), QTCFLLD(3.395726e-02),
QTCFLLD(8.404925e-01), QTCFLLD(-1.030732e-06), QTCFLLD(1.162943e-05),
QTCFLLD(1.571198e-03), QTCFLLD(3.801740e-02), QTCFLLD(8.669955e-01),
QTCFLLD(4.052940e-08), QTCFLLD(4.924960e-05), QTCFLLD(1.990767e-03),
QTCFLLD(4.240569e-02), QTCFLLD(8.919595e-01), QTCFLLD(1.236481e-07),
QTCFLLD(5.799333e-05), QTCFLLD(2.354800e-03), QTCFLLD(4.724177e-02),
QTCFLLD(9.152253e-01), QTCFLLD(4.049388e-07), QTCFLLD(6.369496e-05),
QTCFLLD(2.666746e-03), QTCFLLD(5.236967e-02), QTCFLLD(9.366709e-01),
QTCFLLD(4.509857e-06), QTCFLLD(1.726852e-04), QTCFLLD(2.724443e-03),
QTCFLLD(5.774291e-02), QTCFLLD(9.562097e-01), QTCFLLD(1.379026e-05),
QTCFLLD(3.304619e-04), QTCFLLD(2.378216e-03), QTCFLLD(6.336571e-02),
QTCFLLD(9.737916e-01), QTCFLLD(8.497715e-07), QTCFLLD(7.219624e-05),
QTCFLLD(1.724542e-03), QTCFLLD(6.918311e-02), QTCFLLD(9.893883e-01),
QTCFLLD(-1.660944e-07), QTCFLLD(-6.886664e-05), QTCFLLD(9.181354e-04),
QTCFLLD(7.509105e-02), QTCFLLD(1.002969e+00), QTCFLLD(-1.147235e-05),
QTCFLLD(-5.301826e-05), QTCFLLD(2.013701e-04), QTCFLLD(8.103766e-02),
QTCFLLD(1.014484e+00), QTCFLLD(-3.466829e-06), QTCFLLD(1.205564e-04),
QTCFLLD(6.348892e-04), QTCFLLD(8.694765e-02), QTCFLLD(1.023883e+00),
QTCFLLD(6.713692e-07), QTCFLLD(7.762268e-06), QTCFLLD(7.265112e-04),
QTCFLLD(9.277608e-02), QTCFLLD(1.031157e+00), QTCFLLD(2.283238e-07),
QTCFLLD(-9.801253e-06), QTCFLLD(7.042022e-04), QTCFLLD(9.844099e-02),
QTCFLLD(1.036367e+00), QTCFLLD(3.128189e-07), QTCFLLD(-2.623285e-05),
QTCFLLD(6.827052e-04), QTCFLLD(1.038520e-01), QTCFLLD(1.039662e+00),
QTCFLLD(1.907652e-07), QTCFLLD(-4.969654e-05), QTCFLLD(6.321974e-04),
QTCFLLD(1.089094e-01), QTCFLLD(1.041239e+00), QTCFLLD(3.301479e-07),
QTCFLLD(-6.904354e-05), QTCFLLD(3.969634e-04), QTCFLLD(1.135169e-01),
QTCFLLD(1.041265e+00), QTCFLLD(6.596931e-07), QTCFLLD(-8.973431e-05),
QTCFLLD(-5.303260e-06), QTCFLLD(1.175821e-01), QTCFLLD(1.039789e+00),
QTCFLLD(-4.040094e-06), QTCFLLD(-2.316096e-04), QTCFLLD(-6.036561e-04),
QTCFLLD(1.210365e-01), QTCFLLD(1.036689e+00), QTCFLLD(6.078980e-07),
QTCFLLD(-2.100985e-04), QTCFLLD(-1.341249e-03), QTCFLLD(1.238201e-01),
QTCFLLD(1.031702e+00), QTCFLLD(4.269711e-06), QTCFLLD(-1.806979e-04),
QTCFLLD(-2.103464e-03), QTCFLLD(1.258800e-01), QTCFLLD(1.024543e+00),
QTCFLLD(6.117105e-06), QTCFLLD(-1.764517e-04), QTCFLLD(-2.829232e-03),
QTCFLLD(1.271532e-01), QTCFLLD(1.015119e+00), QTCFLLD(4.273153e-06),
QTCFLLD(-2.105146e-04), QTCFLLD(-3.458167e-03), QTCFLLD(1.275064e-01),
QTCFLLD(1.004178e+00), QTCFLLD(4.771428e-06), QTCFLLD(-2.626353e-05),
QTCFLLD(-4.002991e-03), QTCFLLD(1.273045e-01), QTCFLLD(9.867618e-01),
QTCFLLD(3.825650e-06), QTCFLLD(-8.883540e-06), QTCFLLD(-4.434429e-03),
QTCFLLD(1.264771e-01), QTCFLLD(9.629451e-01), QTCFLLD(2.651941e-06),
QTCFLLD(1.812579e-05), QTCFLLD(-4.670274e-03), QTCFLLD(1.245173e-01),
QTCFLLD(9.378839e-01), QTCFLLD(1.229041e-07), QTCFLLD(3.650440e-05),
QTCFLLD(-4.692922e-03), QTCFLLD(1.214113e-01), QTCFLLD(9.110476e-01),
QTCFLLD(3.984739e-06), QTCFLLD(4.583892e-05), QTCFLLD(-4.462183e-03),
QTCFLLD(1.170796e-01), QTCFLLD(8.827057e-01), QTCFLLD(-1.730664e-09),
QTCFLLD(2.460818e-05), QTCFLLD(-3.942729e-03), QTCFLLD(1.114366e-01),
QTCFLLD(8.532971e-01), QTCFLLD(-7.514413e-09), QTCFLLD(2.935029e-05),
QTCFLLD(-3.262337e-03), QTCFLLD(1.044130e-01), QTCFLLD(8.232281e-01),
QTCFLLD(-4.193503e-08), QTCFLLD(1.000081e-05), QTCFLLD(-2.373092e-03),
QTCFLLD(9.597452e-02), QTCFLLD(7.927589e-01), QTCFLLD(9.230786e-08),
QTCFLLD(8.539538e-06), QTCFLLD(-1.328180e-03), QTCFLLD(8.611453e-02),
QTCFLLD(7.619694e-01), QTCFLLD(8.877312e-08), QTCFLLD(7.202067e-05),
QTCFLLD(-4.087339e-04), QTCFLLD(7.483687e-02), QTCFLLD(7.308058e-01),
QTCFLLD(2.712822e-07), QTCFLLD(1.017429e-04), QTCFLLD(3.835110e-04),
QTCFLLD(6.215753e-02), QTCFLLD(6.991715e-01), QTCFLLD(4.019349e-06),
QTCFLLD(6.968570e-05), QTCFLLD(1.141027e-03), QTCFLLD(4.808825e-02),
QTCFLLD(6.670174e-01), QTCFLLD(8.898233e-08), QTCFLLD(5.441853e-05),
QTCFLLD(1.992521e-03), QTCFLLD(3.262236e-02), QTCFLLD(6.343833e-01),
QTCFLLD(-1.007690e-07), QTCFLLD(3.975024e-05), QTCFLLD(1.841739e-03),
QTCFLLD(1.572281e-02), QTCFLLD(6.013836e-01), QTCFLLD(6.568868e-07),
QTCFLLD(8.181074e-05), QTCFLLD(1.351651e-03), QTCFLLD(-2.556970e-03),
QTCFLLD(5.681393e-01), QTCFLLD(-5.690228e-06), QTCFLLD(9.126098e-05),
QTCFLLD(7.570286e-04), QTCFLLD(-2.218904e-02), QTCFLLD(5.347272e-01),
QTCFLLD(1.884389e-05), QTCFLLD(-2.705446e-04), QTCFLLD(5.337144e-04),
QTCFLLD(-4.317467e-02), QTCFLLD(5.011593e-01), QTCFLLD(-1.329252e-06),
QTCFLLD(-7.198660e-05), QTCFLLD(2.941296e-05), QTCFLLD(-6.547049e-02),
QTCFLLD(4.674168e-01), QTCFLLD(-1.355524e-07), QTCFLLD(5.942472e-05),
QTCFLLD(-4.468657e-04), QTCFLLD(-8.902535e-02), QTCFLLD(4.335079e-01),
QTCFLLD(1.041631e-05), QTCFLLD(6.091853e-05), QTCFLLD(-8.704047e-04),
QTCFLLD(-1.138130e-01), QTCFLLD(3.995200e-01), QTCFLLD(-1.170911e-05),
QTCFLLD(-2.623833e-05), QTCFLLD(-1.207570e-03), QTCFLLD(-1.397967e-01),
QTCFLLD(3.656086e-01), QTCFLLD(-1.364079e-06), QTCFLLD(8.097173e-06),
QTCFLLD(-1.589852e-03), QTCFLLD(-1.669302e-01), QTCFLLD(3.319187e-01),
QTCFLLD(-5.342262e-07), QTCFLLD(3.005858e-05), QTCFLLD(-2.038612e-03),
QTCFLLD(-1.951630e-01), QTCFLLD(2.984839e-01), QTCFLLD(-1.099320e-06),
QTCFLLD(8.977871e-05), QTCFLLD(-2.525111e-03), QTCFLLD(-2.244371e-01),
QTCFLLD(2.651577e-01), QTCFLLD(-7.121587e-07), QTCFLLD(1.848150e-04),
QTCFLLD(-3.068126e-03), QTCFLLD(-2.546924e-01), QTCFLLD(2.316523e-01),
QTCFLLD(-9.617199e-07), QTCFLLD(2.433794e-04), QTCFLLD(-3.658572e-03),
QTCFLLD(-2.858681e-01), QTCFLLD(1.977098e-01), QTCFLLD(-1.848464e-06),
QTCFLLD(2.857057e-04), QTCFLLD(-4.291316e-03), QTCFLLD(-3.178928e-01),
QTCFLLD(1.633594e-01), QTCFLLD(1.509004e-05), QTCFLLD(7.026758e-04),
QTCFLLD(-4.909021e-03), QTCFLLD(-3.506784e-01), QTCFLLD(1.291537e-01),
QTCFLLD(-2.901422e-06), QTCFLLD(9.784381e-04), QTCFLLD(-5.567837e-03),
QTCFLLD(-3.841116e-01), QTCFLLD(9.625038e-02), QTCFLLD(-2.035140e-05),
QTCFLLD(1.105966e-03), QTCFLLD(-6.304841e-03), QTCFLLD(-4.180555e-01),
QTCFLLD(6.622328e-02), QTCFLLD(-3.077146e-05), QTCFLLD(1.201814e-03),
QTCFLLD(-7.152842e-03), QTCFLLD(-4.523680e-01), QTCFLLD(4.042707e-02),
QTCFLLD(-3.836153e-05), QTCFLLD(1.275694e-03), QTCFLLD(-8.142071e-03),
QTCFLLD(-4.869413e-01), QTCFLLD(1.741320e-02),
};
RAM_ALIGN
const FIXP_PFT qmf_cldfb_160[QMF160_CLDFB_PFT_TABLE_SIZE] = {
QTCFLLD(6.114156e-07), QTCFLLD(-4.929378e-06), QTCFLLD(-1.173270e-03),
QTCFLLD(9.985781e-03), QTCFLLD(5.385081e-01), QTCFLLD(2.119298e-07),
QTCFLLD(8.001152e-06), QTCFLLD(-9.578346e-04), QTCFLLD(1.315910e-02),
QTCFLLD(6.066454e-01), QTCFLLD(8.097845e-07), QTCFLLD(1.849027e-05),
QTCFLLD(-1.219567e-03), QTCFLLD(1.721718e-02), QTCFLLD(6.734486e-01),
QTCFLLD(-1.135478e-08), QTCFLLD(5.632976e-06), QTCFLLD(-7.392278e-04),
QTCFLLD(2.226388e-02), QTCFLLD(7.376929e-01), QTCFLLD(6.347751e-08),
QTCFLLD(1.454425e-05), QTCFLLD(-1.105239e-04), QTCFLLD(2.845808e-02),
QTCFLLD(7.981848e-01), QTCFLLD(-2.838328e-06), QTCFLLD(3.414749e-06),
QTCFLLD(1.272254e-03), QTCFLLD(3.594821e-02), QTCFLLD(8.539265e-01),
QTCFLLD(7.116049e-08), QTCFLLD(4.031125e-05), QTCFLLD(2.136304e-03),
QTCFLLD(4.477318e-02), QTCFLLD(9.038135e-01), QTCFLLD(4.098227e-07),
QTCFLLD(7.484240e-05), QTCFLLD(2.716078e-03), QTCFLLD(5.502766e-02),
QTCFLLD(9.466825e-01), QTCFLLD(4.934327e-07), QTCFLLD(7.557725e-05),
QTCFLLD(2.058748e-03), QTCFLLD(6.626062e-02), QTCFLLD(9.818396e-01),
QTCFLLD(-4.933896e-08), QTCFLLD(-3.907360e-05), QTCFLLD(3.753964e-04),
QTCFLLD(7.806610e-02), QTCFLLD(1.008988e+00), QTCFLLD(-7.856341e-06),
QTCFLLD(9.949480e-05), QTCFLLD(7.176331e-04), QTCFLLD(8.987702e-02),
QTCFLLD(1.027784e+00), QTCFLLD(4.822448e-07), QTCFLLD(-1.327914e-05),
QTCFLLD(6.855222e-04), QTCFLLD(1.011847e-01), QTCFLLD(1.038242e+00),
QTCFLLD(4.432684e-07), QTCFLLD(-5.662008e-05), QTCFLLD(5.360314e-04),
QTCFLLD(1.112756e-01), QTCFLLD(1.041439e+00), QTCFLLD(-1.894204e-06),
QTCFLLD(-1.603894e-04), QTCFLLD(-2.796433e-04), QTCFLLD(1.193894e-01),
QTCFLLD(1.038456e+00), QTCFLLD(2.350541e-06), QTCFLLD(-1.981793e-04),
QTCFLLD(-1.719967e-03), QTCFLLD(1.249437e-01), QTCFLLD(1.028407e+00),
QTCFLLD(4.833713e-06), QTCFLLD(-1.957799e-04), QTCFLLD(-3.159640e-03),
QTCFLLD(1.274605e-01), QTCFLLD(1.009701e+00), QTCFLLD(4.724263e-06),
QTCFLLD(-1.181518e-05), QTCFLLD(-4.243399e-03), QTCFLLD(1.270390e-01),
QTCFLLD(9.748854e-01), QTCFLLD(1.007724e-06), QTCFLLD(2.585741e-05),
QTCFLLD(-4.713445e-03), QTCFLLD(1.231120e-01), QTCFLLD(9.246770e-01),
QTCFLLD(2.908454e-06), QTCFLLD(3.137374e-05), QTCFLLD(-4.230293e-03),
QTCFLLD(1.144269e-01), QTCFLLD(8.681067e-01), QTCFLLD(-4.128877e-08),
QTCFLLD(1.870358e-05), QTCFLLD(-2.842924e-03), QTCFLLD(1.003715e-01),
QTCFLLD(8.080344e-01), QTCFLLD(1.806649e-07), QTCFLLD(3.557071e-05),
QTCFLLD(-8.392422e-04), QTCFLLD(8.065225e-02), QTCFLLD(7.464405e-01),
QTCFLLD(2.352609e-06), QTCFLLD(1.090077e-04), QTCFLLD(7.497848e-04),
QTCFLLD(5.529631e-02), QTCFLLD(6.831591e-01), QTCFLLD(1.159657e-07),
QTCFLLD(4.585990e-05), QTCFLLD(2.079346e-03), QTCFLLD(2.434883e-02),
QTCFLLD(6.179208e-01), QTCFLLD(8.859606e-07), QTCFLLD(1.403345e-04),
QTCFLLD(1.065580e-03), QTCFLLD(-1.220572e-02), QTCFLLD(5.514521e-01),
QTCFLLD(-1.038278e-06), QTCFLLD(-1.368162e-04), QTCFLLD(2.932339e-04),
QTCFLLD(-5.416374e-02), QTCFLLD(4.843109e-01), QTCFLLD(7.820030e-08),
QTCFLLD(3.934544e-05), QTCFLLD(-6.638491e-04), QTCFLLD(-1.012664e-01),
QTCFLLD(4.165150e-01), QTCFLLD(-8.393432e-06), QTCFLLD(-5.053646e-05),
QTCFLLD(-1.381912e-03), QTCFLLD(-1.532225e-01), QTCFLLD(3.487301e-01),
QTCFLLD(-1.455897e-06), QTCFLLD(4.880962e-05), QTCFLLD(-2.274392e-03),
QTCFLLD(-2.096737e-01), QTCFLLD(2.818234e-01), QTCFLLD(-1.434317e-06),
QTCFLLD(2.203687e-04), QTCFLLD(-3.357312e-03), QTCFLLD(-2.701693e-01),
QTCFLLD(2.147441e-01), QTCFLLD(7.092199e-06), QTCFLLD(4.681670e-04),
QTCFLLD(-4.601593e-03), QTCFLLD(-3.341968e-01), QTCFLLD(1.461805e-01),
QTCFLLD(-1.116123e-05), QTCFLLD(1.072196e-03), QTCFLLD(-5.925141e-03),
QTCFLLD(-4.010285e-01), QTCFLLD(8.077862e-02), QTCFLLD(-3.775385e-05),
QTCFLLD(1.244841e-03), QTCFLLD(-7.628469e-03), QTCFLLD(-4.696240e-01),
QTCFLLD(2.901889e-02),
};
RAM_ALIGN
const FIXP_PFT qmf_cldfb_80[QMF80_CLDFB_PFT_TABLE_SIZE] = {
QTCFLLD(6.966921e-07), QTCFLLD(9.025176e-06), QTCFLLD(-1.073328e-03),
QTCFLLD(1.146585e-02), QTCFLLD(5.726758e-01), QTCFLLD(-2.323046e-09),
QTCFLLD(1.012638e-05), QTCFLLD(-1.084654e-03), QTCFLLD(1.960515e-02),
QTCFLLD(7.059712e-01), QTCFLLD(1.230159e-07), QTCFLLD(4.639126e-05),
QTCFLLD(6.398911e-04), QTCFLLD(3.204506e-02), QTCFLLD(8.267125e-01),
QTCFLLD(2.865339e-07), QTCFLLD(6.273759e-05), QTCFLLD(2.550464e-03),
QTCFLLD(4.977453e-02), QTCFLLD(9.261818e-01), QTCFLLD(3.738257e-07),
QTCFLLD(-2.429021e-06), QTCFLLD(1.375921e-03), QTCFLLD(7.212754e-02),
QTCFLLD(9.964333e-01), QTCFLLD(1.077039e-08), QTCFLLD(-8.532976e-06),
QTCFLLD(7.147022e-04), QTCFLLD(9.563432e-02), QTCFLLD(1.034012e+00),
QTCFLLD(3.086046e-07), QTCFLLD(-7.986870e-05), QTCFLLD(2.203781e-04),
QTCFLLD(1.156221e-01), QTCFLLD(1.040718e+00), QTCFLLD(5.542804e-06),
QTCFLLD(-1.736757e-04), QTCFLLD(-2.475428e-03), QTCFLLD(1.266206e-01),
QTCFLLD(1.020100e+00), QTCFLLD(3.415168e-06), QTCFLLD(6.290201e-06),
QTCFLLD(-4.576709e-03), QTCFLLD(1.256370e-01), QTCFLLD(9.506344e-01),
QTCFLLD(-1.998632e-09), QTCFLLD(3.017514e-05), QTCFLLD(-3.627394e-03),
QTCFLLD(1.081003e-01), QTCFLLD(8.383245e-01), QTCFLLD(2.590900e-07),
QTCFLLD(9.614004e-05), QTCFLLD(2.183786e-06), QTCFLLD(6.867141e-02),
QTCFLLD(7.150523e-01), QTCFLLD(1.408172e-07), QTCFLLD(5.203217e-05),
QTCFLLD(1.584410e-03), QTCFLLD(6.753749e-03), QTCFLLD(5.847858e-01),
QTCFLLD(-9.234326e-07), QTCFLLD(6.477183e-06), QTCFLLD(-2.123969e-04),
QTCFLLD(-7.709230e-02), QTCFLLD(4.504798e-01), QTCFLLD(-2.464033e-08),
QTCFLLD(1.888626e-05), QTCFLLD(-1.812003e-03), QTCFLLD(-1.809127e-01),
QTCFLLD(3.151743e-01), QTCFLLD(-8.344882e-07), QTCFLLD(2.538528e-04),
QTCFLLD(-3.972626e-03), QTCFLLD(-3.017793e-01), QTCFLLD(1.805658e-01),
QTCFLLD(-2.720526e-05), QTCFLLD(1.150009e-03), QTCFLLD(-6.712822e-03),
QTCFLLD(-4.351740e-01), QTCFLLD(5.276687e-02),
};
#if defined(QMF_COEFF_16BIT)
#define QTMFLLD(x) FL2FXCONST_SGL(x / (float)(1 << QMF_MPSLDFB_PFT_SCALE))
#define QTMFLLDT(x) FX_DBL2FXCONST_SGL(x)
#else
#define QTMFLLD(x) FL2FXCONST_DBL(x / (float)(1 << QMF_MPSLDFB_PFT_SCALE))
#define QTMFLLDT(x) (FIXP_DBL)(x)
#endif
/*!
\name QMF
\brief QMF-Table
32 channels, N = 320,
The coefficients are derived from the MPS Low Delay coefficient set
with 640 samples. The coefficients are interpolated and rearranged
in the following way compared to the reference:
qmf_mpsldfb_320[0] = (qmf_64_reference[ 0] + qmf_64_reference[ 1])/2.0;
qmf_mpsldfb_320[1] = (qmf_64_reference[128] + qmf_64_reference[129])/2.0;
qmf_mpsldfb_320[2] = (qmf_64_reference[256] + qmf_64_reference[257])/2.0;
qmf_mpsldfb_320[3] = (qmf_64_reference[384] + qmf_64_reference[385])/2.0;
qmf_mpsldfb_320[4] = (qmf_64_reference[512] + qmf_64_reference[513])/2.0;
qmf_mpsldfb_320[5] = (qmf_64_reference[ 2] + qmf_64_reference[ 3])/2.0;
qmf_mpsldfb_320[6] = (qmf_64_reference[130] + qmf_64_reference[131])/2.0;
qmf_mpsldfb_320[7] = (qmf_64_reference[258] + qmf_64_reference[259])/2.0;
qmf_mpsldfb_320[8] = (qmf_64_reference[386] + qmf_64_reference[387])/2.0;
qmf_mpsldfb_320[9] = (qmf_64_reference[514] + qmf_64_reference[515])/2.0;
.
.
.
qmf_mpsldfb_320[315] = (qmf_64_reference[126] + qmf_64_reference[127])/2.0;
qmf_mpsldfb_320[316] = (qmf_64_reference[254] + qmf_64_reference[255])/2.0;
qmf_mpsldfb_320[317] = (qmf_64_reference[382] + qmf_64_reference[383])/2.0;
qmf_mpsldfb_320[318] = (qmf_64_reference[510] + qmf_64_reference[511])/2.0;
qmf_mpsldfb_320[319] = (qmf_64_reference[638] + qmf_64_reference[639])/2.0;
The filter output is required to be scaled by 1 bit.
\showinitializer
*/
//@{
const FIXP_PFT qmf_mpsldfb_320[QMF320_MPSLDFB_PFT_TABLE_SIZE] = {
QTMFLLD(1.0777725402e-004), QTMFLLD(-9.4703806099e-004),
QTMFLLD(6.1286436394e-003), QTMFLLD(-9.0161964297e-002),
QTMFLLD(5.5554401875e-001), QTMFLLD(1.2731316383e-004),
QTMFLLD(-1.2311334722e-003), QTMFLLD(4.9468209036e-003),
QTMFLLD(-1.1305026710e-001), QTMFLLD(5.2990418673e-001),
QTMFLLD(1.1927412561e-004), QTMFLLD(-1.5128203668e-003),
QTMFLLD(3.5794533323e-003), QTMFLLD(-1.3681203127e-001),
QTMFLLD(5.0423312187e-001), QTMFLLD(1.0006380762e-004),
QTMFLLD(-1.7925058492e-003), QTMFLLD(2.0164034795e-003),
QTMFLLD(-1.6139641404e-001), QTMFLLD(4.7861024737e-001),
QTMFLLD(7.2826202086e-005), QTMFLLD(-2.0697340369e-003),
QTMFLLD(2.4838969694e-004), QTMFLLD(-1.8674756587e-001),
QTMFLLD(4.5311337709e-001), QTMFLLD(3.8808015233e-005),
QTMFLLD(-2.3429044522e-003), QTMFLLD(-1.7331546405e-003),
QTMFLLD(-2.1280488372e-001), QTMFLLD(4.2781800032e-001),
QTMFLLD(-5.4359588830e-007), QTMFLLD(-2.6112669148e-003),
QTMFLLD(-3.9357249625e-003), QTMFLLD(-2.3950359225e-001),
QTMFLLD(4.0279802680e-001), QTMFLLD(-4.3614549213e-005),
QTMFLLD(-2.8741455171e-003), QTMFLLD(-6.3655078411e-003),
QTMFLLD(-2.6677471399e-001), QTMFLLD(3.7812507153e-001),
QTMFLLD(-8.9040157036e-005), QTMFLLD(-3.1308881007e-003),
QTMFLLD(-9.0275555849e-003), QTMFLLD(-2.9454550147e-001),
QTMFLLD(3.5386830568e-001), QTMFLLD(-1.3519046479e-004),
QTMFLLD(-3.3808732405e-003), QTMFLLD(-1.1925406754e-002),
QTMFLLD(-3.2273942232e-001), QTMFLLD(3.3009397984e-001),
QTMFLLD(-1.8045579782e-004), QTMFLLD(-3.6236830056e-003),
QTMFLLD(-1.5061311424e-002), QTMFLLD(-3.5127705336e-001),
QTMFLLD(3.0686509609e-001), QTMFLLD(-2.2396800341e-004),
QTMFLLD(-3.8587960880e-003), QTMFLLD(-1.8435835838e-002),
QTMFLLD(-3.8007527590e-001), QTMFLLD(2.8424069285e-001),
QTMFLLD(-2.6416976471e-004), QTMFLLD(-4.0859002620e-003),
QTMFLLD(-2.2048022598e-002), QTMFLLD(-4.0904915333e-001),
QTMFLLD(2.6227575541e-001), QTMFLLD(-3.0001887353e-004),
QTMFLLD(-4.3045589700e-003), QTMFLLD(-2.5894984603e-002),
QTMFLLD(-4.3811064959e-001), QTMFLLD(2.4102044106e-001),
QTMFLLD(-3.3083156450e-004), QTMFLLD(-4.5145484619e-003),
QTMFLLD(-2.9972121119e-002), QTMFLLD(-4.6717000008e-001),
QTMFLLD(2.2052007914e-001), QTMFLLD(-3.5614447552e-004),
QTMFLLD(-4.7155953944e-003), QTMFLLD(-3.4272894263e-002),
QTMFLLD(-4.9613577127e-001), QTMFLLD(2.0081442595e-001),
QTMFLLD(-3.7579826312e-004), QTMFLLD(-4.9072988331e-003),
QTMFLLD(-3.8788780570e-002), QTMFLLD(-5.2491527796e-001),
QTMFLLD(1.8193808198e-001), QTMFLLD(-3.8993739872e-004),
QTMFLLD(-5.0893351436e-003), QTMFLLD(-4.3509010226e-002),
QTMFLLD(-5.5341482162e-001), QTMFLLD(1.6391974688e-001),
QTMFLLD(-3.9912899956e-004), QTMFLLD(-5.2615385503e-003),
QTMFLLD(-4.8421185464e-002), QTMFLLD(-5.8154034615e-001),
QTMFLLD(1.4678207040e-001), QTMFLLD(-4.0421969607e-004),
QTMFLLD(-5.4236799479e-003), QTMFLLD(-5.3510606289e-002),
QTMFLLD(-6.0919785500e-001), QTMFLLD(1.3054165244e-001),
QTMFLLD(-4.0645478293e-004), QTMFLLD(-5.5756671354e-003),
QTMFLLD(-5.8760054410e-002), QTMFLLD(-6.3629388809e-001),
QTMFLLD(1.1520925164e-001), QTMFLLD(-4.0720938705e-004),
QTMFLLD(-5.7173836976e-003), QTMFLLD(-6.4149998128e-002),
QTMFLLD(-6.6273581982e-001), QTMFLLD(1.0078965127e-001),
QTMFLLD(-4.0812738007e-004), QTMFLLD(-5.8488911018e-003),
QTMFLLD(-6.9658569992e-002), QTMFLLD(-6.8843221664e-001),
QTMFLLD(8.7281554937e-002), QTMFLLD(-4.1120912647e-004),
QTMFLLD(-5.9703430161e-003), QTMFLLD(-7.5261354446e-002),
QTMFLLD(-7.1329379082e-001), QTMFLLD(7.4678033590e-002),
QTMFLLD(-4.1838851757e-004), QTMFLLD(-6.0821287334e-003),
QTMFLLD(-8.0931767821e-002), QTMFLLD(-7.3723363876e-001),
QTMFLLD(6.2966249883e-002), QTMFLLD(-4.3148122495e-004),
QTMFLLD(-6.1847940087e-003), QTMFLLD(-8.6640790105e-002),
QTMFLLD(-7.6016783714e-001), QTMFLLD(5.2128262818e-002),
QTMFLLD(-4.5229538227e-004), QTMFLLD(-6.2791546807e-003),
QTMFLLD(-9.2357128859e-002), QTMFLLD(-7.8201586008e-001),
QTMFLLD(4.2139917612e-002), QTMFLLD(-4.8211280955e-004),
QTMFLLD(-6.3661932945e-003), QTMFLLD(-9.8047181964e-002),
QTMFLLD(-8.0270123482e-001), QTMFLLD(3.2972395420e-002),
QTMFLLD(-5.2196672186e-004), QTMFLLD(-6.4471233636e-003),
QTMFLLD(-1.0367526114e-001), QTMFLLD(-8.2215231657e-001),
QTMFLLD(2.4589803070e-002), QTMFLLD(-5.7247944642e-004),
QTMFLLD(-6.5232971683e-003), QTMFLLD(-1.0920339823e-001),
QTMFLLD(-8.4030228853e-001), QTMFLLD(1.6952158883e-002),
QTMFLLD(-6.3343788497e-004), QTMFLLD(-6.5963375382e-003),
QTMFLLD(-1.1459194124e-001), QTMFLLD(-8.5709118843e-001),
QTMFLLD(1.0006074794e-002), QTMFLLD(-7.0449430496e-004),
QTMFLLD(-6.6681848839e-003), QTMFLLD(-1.1979964375e-001),
QTMFLLD(-8.7246519327e-001), QTMFLLD(3.6968050990e-003),
QTMFLLD(-7.9609593377e-004), QTMFLLD(-6.7403013818e-003),
QTMFLLD(-1.2478165329e-001), QTMFLLD(-8.8632321358e-001),
QTMFLLD(-1.6344460892e-003), QTMFLLD(-9.0200459817e-004),
QTMFLLD(-6.8151149899e-003), QTMFLLD(-1.2949258089e-001),
QTMFLLD(-8.9860773087e-001), QTMFLLD(-5.9283543378e-003),
QTMFLLD(-1.0116943158e-003), QTMFLLD(-6.8955891766e-003),
QTMFLLD(-1.3388808072e-001), QTMFLLD(-9.0933418274e-001),
QTMFLLD(-9.6466485411e-003), QTMFLLD(-1.1244935449e-003),
QTMFLLD(-6.9835213944e-003), QTMFLLD(-1.3791990280e-001),
QTMFLLD(-9.1846722364e-001), QTMFLLD(-1.2838950381e-002),
QTMFLLD(-1.2393904617e-003), QTMFLLD(-7.0809246972e-003),
QTMFLLD(-1.4153905213e-001), QTMFLLD(-9.2597639561e-001),
QTMFLLD(-1.5539921820e-002), QTMFLLD(-1.3542033266e-003),
QTMFLLD(-7.1895248257e-003), QTMFLLD(-1.4469626546e-001),
QTMFLLD(-9.3183851242e-001), QTMFLLD(-1.7783239484e-002),
QTMFLLD(-1.4669501688e-003), QTMFLLD(-7.3110014200e-003),
QTMFLLD(-1.4734169841e-001), QTMFLLD(-9.3603670597e-001),
QTMFLLD(-1.9597738981e-002), QTMFLLD(-1.5753224725e-003),
QTMFLLD(-7.4466220103e-003), QTMFLLD(-1.4942565560e-001),
QTMFLLD(-9.3856132030e-001), QTMFLLD(-2.1011535078e-002),
QTMFLLD(-1.6771152150e-003), QTMFLLD(-7.5972955674e-003),
QTMFLLD(-1.5089863539e-001), QTMFLLD(-9.3940949440e-001),
QTMFLLD(-2.2049814463e-002), QTMFLLD(-1.7698677257e-003),
QTMFLLD(-7.7634919435e-003), QTMFLLD(-1.5171185136e-001),
QTMFLLD(-9.3858534098e-001), QTMFLLD(-2.2738276049e-002),
QTMFLLD(-1.8512960523e-003), QTMFLLD(-7.9450644553e-003),
QTMFLLD(-1.5181747079e-001), QTMFLLD(-9.3610012531e-001),
QTMFLLD(-2.3101080209e-002), QTMFLLD(-1.9192657201e-003),
QTMFLLD(-8.1413704902e-003), QTMFLLD(-1.5116891265e-001),
QTMFLLD(-9.3197190762e-001), QTMFLLD(-2.3163486272e-002),
QTMFLLD(-1.9716904499e-003), QTMFLLD(-8.3509404212e-003),
QTMFLLD(-1.4972095191e-001), QTMFLLD(-9.2622530460e-001),
QTMFLLD(-2.2950030863e-002), QTMFLLD(-2.0066620782e-003),
QTMFLLD(-8.5715763271e-003), QTMFLLD(-1.4743055403e-001),
QTMFLLD(-9.1889131069e-001), QTMFLLD(-2.2486699745e-002),
QTMFLLD(-2.0227057394e-003), QTMFLLD(-8.8005559519e-003),
QTMFLLD(-1.4425669611e-001), QTMFLLD(-9.1000711918e-001),
QTMFLLD(-2.1799135953e-002), QTMFLLD(-2.0185527392e-003),
QTMFLLD(-9.0341167524e-003), QTMFLLD(-1.4016106725e-001),
QTMFLLD(-8.9961612225e-001), QTMFLLD(-2.0914383233e-002),
QTMFLLD(-1.9932338037e-003), QTMFLLD(-9.2674419284e-003),
QTMFLLD(-1.3510815799e-001), QTMFLLD(-8.8776648045e-001),
QTMFLLD(-1.9859094173e-002), QTMFLLD(-1.9461065531e-003),
QTMFLLD(-9.4948727638e-003), QTMFLLD(-1.2906542420e-001),
QTMFLLD(-8.7451159954e-001), QTMFLLD(-1.8660902977e-002),
QTMFLLD(-1.8770052120e-003), QTMFLLD(-9.7100129351e-003),
QTMFLLD(-1.2200380862e-001), QTMFLLD(-8.5991013050e-001),
QTMFLLD(-1.7346922308e-002), QTMFLLD(-1.7859865911e-003),
QTMFLLD(-9.9056493491e-003), QTMFLLD(-1.1389782280e-001),
QTMFLLD(-8.4402561188e-001), QTMFLLD(-1.5944939107e-002),
QTMFLLD(-1.6734169330e-003), QTMFLLD(-1.0073989630e-002),
QTMFLLD(-1.0472598672e-001), QTMFLLD(-8.2692527771e-001),
QTMFLLD(-1.4481747523e-002), QTMFLLD(-1.5399802942e-003),
QTMFLLD(-1.0205906816e-002), QTMFLLD(-9.4470888376e-002),
QTMFLLD(-8.0868041515e-001), QTMFLLD(-1.2984249741e-002),
QTMFLLD(-1.3865872752e-003), QTMFLLD(-1.0291703977e-002),
QTMFLLD(-8.3119556308e-002), QTMFLLD(-7.8936588764e-001),
QTMFLLD(-1.1477986351e-002), QTMFLLD(-1.2144348584e-003),
QTMFLLD(-1.0320962407e-002), QTMFLLD(-7.0663399994e-002),
QTMFLLD(-7.6905936003e-001), QTMFLLD(-9.9884867668e-003),
QTMFLLD(-1.0248266626e-003), QTMFLLD(-1.0282764211e-002),
QTMFLLD(-5.7098604739e-002), QTMFLLD(-7.4784147739e-001),
QTMFLLD(-8.5393209010e-003), QTMFLLD(-8.1919803051e-004),
QTMFLLD(-1.0165717453e-002), QTMFLLD(-4.2426198721e-002),
QTMFLLD(-7.2579479218e-001), QTMFLLD(-7.1533406153e-003),
QTMFLLD(-5.9914286248e-004), QTMFLLD(-9.9579729140e-003),
QTMFLLD(-2.6652012020e-002), QTMFLLD(-7.0300412178e-001),
QTMFLLD(-5.8508114889e-003), QTMFLLD(-3.6626873771e-004),
QTMFLLD(-9.6475090832e-003), QTMFLLD(-9.7871217877e-003),
QTMFLLD(-6.7955517769e-001), QTMFLLD(-4.6512838453e-003),
QTMFLLD(-1.2227181287e-004), QTMFLLD(-9.2221321538e-003),
QTMFLLD(8.1523396075e-003), QTMFLLD(-6.5553492308e-001),
QTMFLLD(-3.5699680448e-003), QTMFLLD(1.3090072025e-004),
QTMFLLD(-8.6695179343e-003), QTMFLLD(2.7145106345e-002),
QTMFLLD(-6.3103044033e-001), QTMFLLD(-2.6181070134e-003),
QTMFLLD(3.9128778735e-004), QTMFLLD(-7.9773496836e-003),
QTMFLLD(4.7164849937e-002), QTMFLLD(-6.0613000393e-001),
QTMFLLD(-1.7908872105e-003), QTMFLLD(6.5761915175e-004),
QTMFLLD(-7.1337916888e-003), QTMFLLD(6.8181537092e-002),
QTMFLLD(-5.8092808723e-001), QTMFLLD(-1.0135001503e-003)};
/*!
\name QMF
\brief QMF-Table
64 channels, N = 640,
The coeffs are rearranged compared with the reference in the following
way:
qmf_64[0] = qmf_64_reference[0];
qmf_64[1] = qmf_64_reference[128];
qmf_64[2] = qmf_64_reference[256];
qmf_64[3] = qmf_64_reference[384];
qmf_64[4] = qmf_64_reference[512];
qmf_64[5] = qmf_64_reference[1];
qmf_64[6] = qmf_64_reference[129];
qmf_64[7] = qmf_64_reference[257];
qmf_64[8] = qmf_64_reference[385];
qmf_64[9] = qmf_64_reference[513];
.
.
.
qmf_64[635] = qmf_64_reference[127]
qmf_64[636] = qmf_64_reference[255];
qmf_64[637] = qmf_64_reference[383];
qmf_64[638] = qmf_64_reference[511];
qmf_64[639] = qmf_64_reference[639];
The filter output is required to be scaled by 1 bit.
\showinitializer
*/
//@{
LNK_SECTION_CONSTDATA_L1
RAM_ALIGN
const FIXP_PFT qmf_mpsldfb_640[QMF640_MPSLDFB_PFT_TABLE_SIZE] = {
QTMFLLD(9.3863010989e-005), QTMFLLD(-8.7536586216e-004),
QTMFLLD(6.4016343094e-003), QTMFLLD(-8.4552817047e-002),
QTMFLLD(5.6194400787e-001), QTMFLLD(1.2169149704e-004),
QTMFLLD(-1.0187102016e-003), QTMFLLD(5.8556534350e-003),
QTMFLLD(-9.5771118999e-002), QTMFLLD(5.4914402962e-001),
QTMFLLD(1.2793767382e-004), QTMFLLD(-1.1605311884e-003),
QTMFLLD(5.2649765275e-003), QTMFLLD(-1.0721673071e-001),
QTMFLLD(5.3632181883e-001), QTMFLLD(1.2668863928e-004),
QTMFLLD(-1.3017356396e-003), QTMFLLD(4.6286652796e-003),
QTMFLLD(-1.1888379604e-001), QTMFLLD(5.2348655462e-001),
QTMFLLD(1.2296593923e-004), QTMFLLD(-1.4426353155e-003),
QTMFLLD(3.9453012869e-003), QTMFLLD(-1.3076621294e-001),
QTMFLLD(5.1064836979e-001), QTMFLLD(1.1558231199e-004),
QTMFLLD(-1.5830053017e-003), QTMFLLD(3.2136053778e-003),
QTMFLLD(-1.4285783470e-001), QTMFLLD(4.9781781435e-001),
QTMFLLD(1.0582985124e-004), QTMFLLD(-1.7228506040e-003),
QTMFLLD(2.4323666003e-003), QTMFLLD(-1.5515175462e-001),
QTMFLLD(4.8500382900e-001), QTMFLLD(9.4297764008e-005),
QTMFLLD(-1.8621610943e-003), QTMFLLD(1.6004402423e-003),
QTMFLLD(-1.6764105856e-001), QTMFLLD(4.7221666574e-001),
QTMFLLD(8.0514568253e-005), QTMFLLD(-2.0008818246e-003),
QTMFLLD(7.1672687773e-004), QTMFLLD(-1.8031860888e-001),
QTMFLLD(4.5946595073e-001), QTMFLLD(6.5137835918e-005),
QTMFLLD(-2.1385864820e-003), QTMFLLD(-2.1994746930e-004),
QTMFLLD(-1.9317652285e-001), QTMFLLD(4.4676083326e-001),
QTMFLLD(4.8101064749e-005), QTMFLLD(-2.2751907818e-003),
QTMFLLD(-1.2104592752e-003), QTMFLLD(-2.0620720088e-001),
QTMFLLD(4.3411090970e-001), QTMFLLD(2.9514967537e-005),
QTMFLLD(-2.4106178898e-003), QTMFLLD(-2.2558500059e-003),
QTMFLLD(-2.1940255165e-001), QTMFLLD(4.2152509093e-001),
QTMFLLD(9.8814107332e-006), QTMFLLD(-2.5448307861e-003),
QTMFLLD(-3.3569468651e-003), QTMFLLD(-2.3275400698e-001),
QTMFLLD(4.0901294351e-001), QTMFLLD(-1.0968602510e-005),
QTMFLLD(-2.6777030434e-003), QTMFLLD(-4.5145032927e-003),
QTMFLLD(-2.4625316262e-001), QTMFLLD(3.9658311009e-001),
QTMFLLD(-3.2559255487e-005), QTMFLLD(-2.8091520071e-003),
QTMFLLD(-5.7292259298e-003), QTMFLLD(-2.5989097357e-001),
QTMFLLD(3.8424444199e-001), QTMFLLD(-5.4669842939e-005),
QTMFLLD(-2.9391390271e-003), QTMFLLD(-7.0017897524e-003),
QTMFLLD(-2.7365845442e-001), QTMFLLD(3.7200567126e-001),
QTMFLLD(-7.7506563684e-005), QTMFLLD(-3.0675258022e-003),
QTMFLLD(-8.3327051252e-003), QTMFLLD(-2.8754624724e-001),
QTMFLLD(3.5987523198e-001), QTMFLLD(-1.0057374311e-004),
QTMFLLD(-3.1942503992e-003), QTMFLLD(-9.7224051133e-003),
QTMFLLD(-3.0154475570e-001), QTMFLLD(3.4786140919e-001),
QTMFLLD(-1.2368557509e-004), QTMFLLD(-3.3192564733e-003),
QTMFLLD(-1.1171258055e-002), QTMFLLD(-3.1564420462e-001),
QTMFLLD(3.3597227931e-001), QTMFLLD(-1.4669535449e-004),
QTMFLLD(-3.4424900077e-003), QTMFLLD(-1.2679555453e-002),
QTMFLLD(-3.2983466983e-001), QTMFLLD(3.2421571016e-001),
QTMFLLD(-1.6928518016e-004), QTMFLLD(-3.5639149137e-003),
QTMFLLD(-1.4247507788e-002), QTMFLLD(-3.4410607815e-001),
QTMFLLD(3.1259948015e-001), QTMFLLD(-1.9162640092e-004),
QTMFLLD(-3.6834510975e-003), QTMFLLD(-1.5875114128e-002),
QTMFLLD(-3.5844799876e-001), QTMFLLD(3.0113074183e-001),
QTMFLLD(-2.1345751884e-004), QTMFLLD(-3.8009947166e-003),
QTMFLLD(-1.7562393099e-002), QTMFLLD(-3.7284970284e-001),
QTMFLLD(2.8981682658e-001), QTMFLLD(-2.3447850253e-004),
QTMFLLD(-3.9165974595e-003), QTMFLLD(-1.9309276715e-002),
QTMFLLD(-3.8730087876e-001), QTMFLLD(2.7866455913e-001),
QTMFLLD(-2.5462667691e-004), QTMFLLD(-4.0301652625e-003),
QTMFLLD(-2.1115457639e-002), QTMFLLD(-4.0179058909e-001),
QTMFLLD(2.6768052578e-001), QTMFLLD(-2.7371285250e-004),
QTMFLLD(-4.1416347958e-003), QTMFLLD(-2.2980585694e-002),
QTMFLLD(-4.1630774736e-001), QTMFLLD(2.5687095523e-001),
QTMFLLD(-2.9165804153e-004), QTMFLLD(-4.2509674095e-003),
QTMFLLD(-2.4904217571e-002), QTMFLLD(-4.3084129691e-001),
QTMFLLD(2.4624188244e-001), QTMFLLD(-3.0837973463e-004),
QTMFLLD(-4.3581505306e-003), QTMFLLD(-2.6885753497e-002),
QTMFLLD(-4.4538003206e-001), QTMFLLD(2.3579898477e-001),
QTMFLLD(-3.2378203468e-004), QTMFLLD(-4.4631510973e-003),
QTMFLLD(-2.8924530372e-002), QTMFLLD(-4.5991250873e-001),
QTMFLLD(2.2554755211e-001), QTMFLLD(-3.3788106521e-004),
QTMFLLD(-4.5659458265e-003), QTMFLLD(-3.1019711867e-002),
QTMFLLD(-4.7442746162e-001), QTMFLLD(2.1549259126e-001),
QTMFLLD(-3.5053401371e-004), QTMFLLD(-4.6664695255e-003),
QTMFLLD(-3.3170353621e-002), QTMFLLD(-4.8891320825e-001),
QTMFLLD(2.0563863218e-001), QTMFLLD(-3.6175493733e-004),
QTMFLLD(-4.7647207975e-003), QTMFLLD(-3.5375438631e-002),
QTMFLLD(-5.0335830450e-001), QTMFLLD(1.9599021971e-001),
QTMFLLD(-3.7159718340e-004), QTMFLLD(-4.8605888151e-003),
QTMFLLD(-3.7633713335e-002), QTMFLLD(-5.1775097847e-001),
QTMFLLD(1.8655113876e-001), QTMFLLD(-3.7999937194e-004),
QTMFLLD(-4.9540083855e-003), QTMFLLD(-3.9943847805e-002),
QTMFLLD(-5.3207957745e-001), QTMFLLD(1.7732504010e-001),
QTMFLLD(-3.8705617771e-004), QTMFLLD(-5.0450465642e-003),
QTMFLLD(-4.2304381728e-002), QTMFLLD(-5.4633224010e-001),
QTMFLLD(1.6831515729e-001), QTMFLLD(-3.9281861973e-004),
QTMFLLD(-5.1336232573e-003), QTMFLLD(-4.4713638723e-002),
QTMFLLD(-5.6049734354e-001), QTMFLLD(1.5952435136e-001),
QTMFLLD(-3.9737694897e-004), QTMFLLD(-5.2197398618e-003),
QTMFLLD(-4.7170232981e-002), QTMFLLD(-5.7456302643e-001),
QTMFLLD(1.5095503628e-001), QTMFLLD(-4.0088107926e-004),
QTMFLLD(-5.3033372387e-003), QTMFLLD(-4.9672137946e-002),
QTMFLLD(-5.8851766586e-001), QTMFLLD(1.4260910451e-001),
QTMFLLD(-4.0338383405e-004), QTMFLLD(-5.3843962960e-003),
QTMFLLD(-5.2217379212e-002), QTMFLLD(-6.0234934092e-001),
QTMFLLD(1.3448855281e-001), QTMFLLD(-4.0505555808e-004),
QTMFLLD(-5.4629631341e-003), QTMFLLD(-5.4803829640e-002),
QTMFLLD(-6.1604642868e-001), QTMFLLD(1.2659475207e-001),
QTMFLLD(-4.0614881436e-004), QTMFLLD(-5.5389581248e-003),
QTMFLLD(-5.7429198176e-002), QTMFLLD(-6.2959736586e-001),
QTMFLLD(1.1892842501e-001), QTMFLLD(-4.0676075150e-004),
QTMFLLD(-5.6123761460e-003), QTMFLLD(-6.0090914369e-002),
QTMFLLD(-6.4299046993e-001), QTMFLLD(1.1149007827e-001),
QTMFLLD(-4.0709332097e-004), QTMFLLD(-5.6832311675e-003),
QTMFLLD(-6.2786586583e-002), QTMFLLD(-6.5621429682e-001),
QTMFLLD(1.0428040475e-001), QTMFLLD(-4.0732545312e-004),
QTMFLLD(-5.7515366934e-003), QTMFLLD(-6.5513409674e-002),
QTMFLLD(-6.6925734282e-001), QTMFLLD(9.7298897803e-002),
QTMFLLD(-4.0770808118e-004), QTMFLLD(-5.8172862045e-003),
QTMFLLD(-6.8268470466e-002), QTMFLLD(-6.8210834265e-001),
QTMFLLD(9.0545162559e-002), QTMFLLD(-4.0854664985e-004),
QTMFLLD(-5.8804959990e-003), QTMFLLD(-7.1048669517e-002),
QTMFLLD(-6.9475615025e-001), QTMFLLD(8.4017947316e-002),
QTMFLLD(-4.1002241778e-004), QTMFLLD(-5.9412117116e-003),
QTMFLLD(-7.3850922287e-002), QTMFLLD(-7.0718955994e-001),
QTMFLLD(7.7716566622e-002), QTMFLLD(-4.1239586426e-004),
QTMFLLD(-5.9994738549e-003), QTMFLLD(-7.6671779156e-002),
QTMFLLD(-7.1939796209e-001), QTMFLLD(7.1639508009e-002),
QTMFLLD(-4.1594370850e-004), QTMFLLD(-6.0553550720e-003),
QTMFLLD(-7.9507902265e-002), QTMFLLD(-7.3137050867e-001),
QTMFLLD(6.5784148872e-002), QTMFLLD(-4.2083335575e-004),
QTMFLLD(-6.1089023948e-003), QTMFLLD(-8.2355625927e-002),
QTMFLLD(-7.4309676886e-001), QTMFLLD(6.0148354620e-002),
QTMFLLD(-4.2732476140e-004), QTMFLLD(-6.1602159403e-003),
QTMFLLD(-8.5211075842e-002), QTMFLLD(-7.5456637144e-001),
QTMFLLD(5.4730266333e-002), QTMFLLD(-4.3563771760e-004),
QTMFLLD(-6.2093720771e-003), QTMFLLD(-8.8070511818e-002),
QTMFLLD(-7.6576924324e-001), QTMFLLD(4.9526259303e-002),
QTMFLLD(-4.4600359979e-004), QTMFLLD(-6.2565426342e-003),
QTMFLLD(-9.0929701924e-002), QTMFLLD(-7.7669566870e-001),
QTMFLLD(4.4533081353e-002), QTMFLLD(-4.5858716476e-004),
QTMFLLD(-6.3017667271e-003), QTMFLLD(-9.3784548342e-002),
QTMFLLD(-7.8733605146e-001), QTMFLLD(3.9746750146e-002),
QTMFLLD(-4.7345875646e-004), QTMFLLD(-6.3452622853e-003),
QTMFLLD(-9.6630692482e-002), QTMFLLD(-7.9768097401e-001),
QTMFLLD(3.5163912922e-002), QTMFLLD(-4.9076689174e-004),
QTMFLLD(-6.3871243037e-003), QTMFLLD(-9.9463671446e-002),
QTMFLLD(-8.0772149563e-001), QTMFLLD(3.0780877918e-002),
QTMFLLD(-5.1067111781e-004), QTMFLLD(-6.4275567420e-003),
QTMFLLD(-1.0227891803e-001), QTMFLLD(-8.1744915247e-001),
QTMFLLD(2.6590615511e-002), QTMFLLD(-5.3326232592e-004),
QTMFLLD(-6.4666904509e-003), QTMFLLD(-1.0507161170e-001),
QTMFLLD(-8.2685548067e-001), QTMFLLD(2.2588992491e-002),
QTMFLLD(-5.5855646497e-004), QTMFLLD(-6.5047293901e-003),
QTMFLLD(-1.0783691704e-001), QTMFLLD(-8.3593225479e-001),
QTMFLLD(1.8772648647e-002), QTMFLLD(-5.8640236966e-004),
QTMFLLD(-6.5418654121e-003), QTMFLLD(-1.1056987941e-001),
QTMFLLD(-8.4467232227e-001), QTMFLLD(1.5131668188e-002),
QTMFLLD(-6.1692652525e-004), QTMFLLD(-6.5783206373e-003),
QTMFLLD(-1.1326543987e-001), QTMFLLD(-8.5306841135e-001),
QTMFLLD(1.1661184952e-002), QTMFLLD(-6.4994930290e-004),
QTMFLLD(-6.6143544391e-003), QTMFLLD(-1.1591844261e-001),
QTMFLLD(-8.6111402512e-001), QTMFLLD(8.3509646356e-003),
QTMFLLD(-6.8494328298e-004), QTMFLLD(-6.6502285190e-003),
QTMFLLD(-1.1852371693e-001), QTMFLLD(-8.6880439520e-001),
QTMFLLD(5.1832948811e-003), QTMFLLD(-7.2404538514e-004),
QTMFLLD(-6.6861407831e-003), QTMFLLD(-1.2107557058e-001),
QTMFLLD(-8.7612599134e-001), QTMFLLD(2.2103153169e-003),
QTMFLLD(-7.7061145566e-004), QTMFLLD(-6.7221261561e-003),
QTMFLLD(-1.2356808037e-001), QTMFLLD(-8.8305824995e-001),
QTMFLLD(-4.6855807886e-004), QTMFLLD(-8.2158041187e-004),
QTMFLLD(-6.7584766075e-003), QTMFLLD(-1.2599521875e-001),
QTMFLLD(-8.8958823681e-001), QTMFLLD(-2.8003340121e-003),
QTMFLLD(-8.7498105131e-004), QTMFLLD(-6.7957863212e-003),
QTMFLLD(-1.2835204601e-001), QTMFLLD(-8.9572954178e-001),
QTMFLLD(-4.9293786287e-003), QTMFLLD(-9.2902814504e-004),
QTMFLLD(-6.8344431929e-003), QTMFLLD(-1.3063311577e-001),
QTMFLLD(-9.0148586035e-001), QTMFLLD(-6.9273295812e-003),
QTMFLLD(-9.8383461591e-004), QTMFLLD(-6.8746237084e-003),
QTMFLLD(-1.3283239305e-001), QTMFLLD(-9.0685033798e-001),
QTMFLLD(-8.7857460603e-003), QTMFLLD(-1.0395538993e-003),
QTMFLLD(-6.9165546447e-003), QTMFLLD(-1.3494376838e-001),
QTMFLLD(-9.1181802750e-001), QTMFLLD(-1.0507551953e-002),
QTMFLLD(-1.0959620122e-003), QTMFLLD(-6.9604511373e-003),
QTMFLLD(-1.3696120679e-001), QTMFLLD(-9.1638565063e-001),
QTMFLLD(-1.2103702873e-002), QTMFLLD(-1.1530250777e-003),
QTMFLLD(-7.0065916516e-003), QTMFLLD(-1.3887859881e-001),
QTMFLLD(-9.2054879665e-001), QTMFLLD(-1.3574197888e-002),
QTMFLLD(-1.2105966453e-003), QTMFLLD(-7.0552495308e-003),
QTMFLLD(-1.4068968594e-001), QTMFLLD(-9.2430406809e-001),
QTMFLLD(-1.4923358336e-002), QTMFLLD(-1.2681842782e-003),
QTMFLLD(-7.1066003293e-003), QTMFLLD(-1.4238841832e-001),
QTMFLLD(-9.2764878273e-001), QTMFLLD(-1.6156485304e-002),
QTMFLLD(-1.3256429229e-003), QTMFLLD(-7.1608433500e-003),
QTMFLLD(-1.4396859705e-001), QTMFLLD(-9.3058031797e-001),
QTMFLLD(-1.7277117819e-002), QTMFLLD(-1.3827638468e-003),
QTMFLLD(-7.2182063013e-003), QTMFLLD(-1.4542391896e-001),
QTMFLLD(-9.3309664726e-001), QTMFLLD(-1.8289361149e-002),
QTMFLLD(-1.4391905861e-003), QTMFLLD(-7.2789187543e-003),
QTMFLLD(-1.4674818516e-001), QTMFLLD(-9.3519610167e-001),
QTMFLLD(-1.9195662811e-002), QTMFLLD(-1.4947097516e-003),
QTMFLLD(-7.3430840857e-003), QTMFLLD(-1.4793521166e-001),
QTMFLLD(-9.3687731028e-001), QTMFLLD(-1.9999813288e-002),
QTMFLLD(-1.5489540529e-003), QTMFLLD(-7.4108825065e-003),
QTMFLLD(-1.4897871017e-001), QTMFLLD(-9.3813979626e-001),
QTMFLLD(-2.0706148818e-002), QTMFLLD(-1.6016908921e-003),
QTMFLLD(-7.4823615141e-003), QTMFLLD(-1.4987260103e-001),
QTMFLLD(-9.3898290396e-001), QTMFLLD(-2.1316919476e-002),
QTMFLLD(-1.6526894178e-003), QTMFLLD(-7.5576924719e-003),
QTMFLLD(-1.5061059594e-001), QTMFLLD(-9.3940681219e-001),
QTMFLLD(-2.1835187450e-002), QTMFLLD(-1.7015410122e-003),
QTMFLLD(-7.6368991286e-003), QTMFLLD(-1.5118667483e-001),
QTMFLLD(-9.3941211700e-001), QTMFLLD(-2.2264443338e-002),
QTMFLLD(-1.7479787348e-003), QTMFLLD(-7.7200052328e-003),
QTMFLLD(-1.5159477293e-001), QTMFLLD(-9.3899971247e-001),
QTMFLLD(-2.2607907653e-002), QTMFLLD(-1.7917567166e-003),
QTMFLLD(-7.8069791198e-003), QTMFLLD(-1.5182891488e-001),
QTMFLLD(-9.3817096949e-001), QTMFLLD(-2.2868644446e-002),
QTMFLLD(-1.8325200072e-003), QTMFLLD(-7.8977877274e-003),
QTMFLLD(-1.5188319981e-001), QTMFLLD(-9.3692785501e-001),
QTMFLLD(-2.3049183190e-002), QTMFLLD(-1.8700722139e-003),
QTMFLLD(-7.9923402518e-003), QTMFLLD(-1.5175175667e-001),
QTMFLLD(-9.3527245522e-001), QTMFLLD(-2.3152977228e-002),
QTMFLLD(-1.9041235792e-003), QTMFLLD(-8.0905584618e-003),
QTMFLLD(-1.5142890811e-001), QTMFLLD(-9.3320751190e-001),
QTMFLLD(-2.3183524609e-002), QTMFLLD(-1.9344078610e-003),
QTMFLLD(-8.1921815872e-003), QTMFLLD(-1.5090890229e-001),
QTMFLLD(-9.3073624372e-001), QTMFLLD(-2.3143447936e-002),
QTMFLLD(-1.9606938586e-003), QTMFLLD(-8.2970457152e-003),
QTMFLLD(-1.5018628538e-001), QTMFLLD(-9.2786192894e-001),
QTMFLLD(-2.3035895079e-002), QTMFLLD(-1.9826870412e-003),
QTMFLLD(-8.4048351273e-003), QTMFLLD(-1.4925561845e-001),
QTMFLLD(-9.2458862066e-001), QTMFLLD(-2.2864164785e-002),
QTMFLLD(-2.0002126694e-003), QTMFLLD(-8.5152359679e-003),
QTMFLLD(-1.4811170101e-001), QTMFLLD(-9.2092043161e-001),
QTMFLLD(-2.2631708533e-002), QTMFLLD(-2.0131117199e-003),
QTMFLLD(-8.6279176176e-003), QTMFLLD(-1.4674940705e-001),
QTMFLLD(-9.1686213017e-001), QTMFLLD(-2.2341690958e-002),
QTMFLLD(-2.0211567171e-003), QTMFLLD(-8.7425475940e-003),
QTMFLLD(-1.4516362548e-001), QTMFLLD(-9.1241872311e-001),
QTMFLLD(-2.1996961907e-002), QTMFLLD(-2.0242547616e-003),
QTMFLLD(-8.8585643098e-003), QTMFLLD(-1.4334976673e-001),
QTMFLLD(-9.0759557486e-001), QTMFLLD(-2.1601308137e-002),
QTMFLLD(-2.0221893210e-003), QTMFLLD(-8.9755039662e-003),
QTMFLLD(-1.4130303264e-001), QTMFLLD(-9.0239852667e-001),
QTMFLLD(-2.1158147603e-002), QTMFLLD(-2.0149163902e-003),
QTMFLLD(-9.0927295387e-003), QTMFLLD(-1.3901908696e-001),
QTMFLLD(-8.9683371782e-001), QTMFLLD(-2.0670616999e-002),
QTMFLLD(-2.0022888202e-003), QTMFLLD(-9.2095714062e-003),
QTMFLLD(-1.3649365306e-001), QTMFLLD(-8.9090716839e-001),
QTMFLLD(-2.0142132416e-002), QTMFLLD(-1.9841785543e-003),
QTMFLLD(-9.3253115192e-003), QTMFLLD(-1.3372266293e-001),
QTMFLLD(-8.8462579250e-001), QTMFLLD(-1.9576057792e-002),
QTMFLLD(-1.9606270362e-003), QTMFLLD(-9.4392402098e-003),
QTMFLLD(-1.3070219755e-001), QTMFLLD(-8.7799650431e-001),
QTMFLLD(-1.8976125866e-002), QTMFLLD(-1.9315859536e-003),
QTMFLLD(-9.5505062491e-003), QTMFLLD(-1.2742865086e-001),
QTMFLLD(-8.7102663517e-001), QTMFLLD(-1.8345680088e-002),
QTMFLLD(-1.8970289966e-003), QTMFLLD(-9.6583357081e-003),
QTMFLLD(-1.2389861047e-001), QTMFLLD(-8.6372399330e-001),
QTMFLLD(-1.7687706277e-002), QTMFLLD(-1.8569815438e-003),
QTMFLLD(-9.7616901621e-003), QTMFLLD(-1.2010899931e-001),
QTMFLLD(-8.5609632730e-001), QTMFLLD(-1.7006140202e-002),
QTMFLLD(-1.8114587292e-003), QTMFLLD(-9.8597351462e-003),
QTMFLLD(-1.1605655402e-001), QTMFLLD(-8.4815198183e-001),
QTMFLLD(-1.6304368153e-002), QTMFLLD(-1.7605143366e-003),
QTMFLLD(-9.9515644833e-003), QTMFLLD(-1.1173909158e-001),
QTMFLLD(-8.3989918232e-001), QTMFLLD(-1.5585509129e-002),
QTMFLLD(-1.7042002873e-003), QTMFLLD(-1.0036026128e-002),
QTMFLLD(-1.0715358704e-001), QTMFLLD(-8.3134686947e-001),
QTMFLLD(-1.4853162691e-002), QTMFLLD(-1.6426335787e-003),
QTMFLLD(-1.0111952201e-002), QTMFLLD(-1.0229838639e-001),
QTMFLLD(-8.2250368595e-001), QTMFLLD(-1.4110331424e-002),
QTMFLLD(-1.5758809168e-003), QTMFLLD(-1.0178210214e-002),
QTMFLLD(-9.7171187401e-002), QTMFLLD(-8.1337898970e-001),
QTMFLLD(-1.3360806741e-002), QTMFLLD(-1.5040797880e-003),
QTMFLLD(-1.0233603418e-002), QTMFLLD(-9.1770596802e-002),
QTMFLLD(-8.0398184061e-001), QTMFLLD(-1.2607692741e-002),
QTMFLLD(-1.4273397392e-003), QTMFLLD(-1.0276827961e-002),
QTMFLLD(-8.6095176637e-002), QTMFLLD(-7.9432225227e-001),
QTMFLLD(-1.1853585951e-002), QTMFLLD(-1.3458349276e-003),
QTMFLLD(-1.0306579992e-002), QTMFLLD(-8.0143928528e-002),
QTMFLLD(-7.8440952301e-001), QTMFLLD(-1.1102385819e-002),
QTMFLLD(-1.2597256573e-003), QTMFLLD(-1.0321546346e-002),
QTMFLLD(-7.3915921152e-002), QTMFLLD(-7.7425378561e-001),
QTMFLLD(-1.0356968269e-002), QTMFLLD(-1.1691439431e-003),
QTMFLLD(-1.0320378467e-002), QTMFLLD(-6.7410878837e-002),
QTMFLLD(-7.6386493444e-001), QTMFLLD(-9.6200043336e-003),
QTMFLLD(-1.0743001476e-003), QTMFLLD(-1.0301630013e-002),
QTMFLLD(-6.0628447682e-002), QTMFLLD(-7.5325345993e-001),
QTMFLLD(-8.8949296623e-003), QTMFLLD(-9.7535311943e-004),
QTMFLLD(-1.0263898410e-002), QTMFLLD(-5.3568758070e-002),
QTMFLLD(-7.4242949486e-001), QTMFLLD(-8.1837112084e-003),
QTMFLLD(-8.7248592172e-004), QTMFLLD(-1.0205759667e-002),
QTMFLLD(-4.6232450753e-002), QTMFLLD(-7.3140352964e-001),
QTMFLLD(-7.4901022017e-003), QTMFLLD(-7.6591013931e-004),
QTMFLLD(-1.0125675239e-002), QTMFLLD(-3.8619950414e-002),
QTMFLLD(-7.2018599510e-001), QTMFLLD(-6.8165790290e-003),
QTMFLLD(-6.5580842784e-004), QTMFLLD(-1.0022218339e-002),
QTMFLLD(-3.0732547864e-002), QTMFLLD(-7.0878815651e-001),
QTMFLLD(-6.1642420478e-003), QTMFLLD(-5.4247735534e-004),
QTMFLLD(-9.8937284201e-003), QTMFLLD(-2.2571478039e-002),
QTMFLLD(-6.9722014666e-001), QTMFLLD(-5.5373813957e-003),
QTMFLLD(-4.2596619460e-004), QTMFLLD(-9.7389295697e-003),
QTMFLLD(-1.4138570987e-002), QTMFLLD(-6.8549299240e-001),
QTMFLLD(-4.9372608773e-003), QTMFLLD(-3.0657128082e-004),
QTMFLLD(-9.5560895279e-003), QTMFLLD(-5.4356725886e-003),
QTMFLLD(-6.7361742258e-001), QTMFLLD(-4.3653072789e-003),
QTMFLLD(-1.8451632059e-004), QTMFLLD(-9.3438196927e-003),
QTMFLLD(3.5346730147e-003), QTMFLLD(-6.6160440445e-001),
QTMFLLD(-3.8251809310e-003), QTMFLLD(-6.0027297877e-005),
QTMFLLD(-9.1004446149e-003), QTMFLLD(1.2770005502e-002),
QTMFLLD(-6.4946544170e-001), QTMFLLD(-3.3147553913e-003),
QTMFLLD(6.6618180426e-005), QTMFLLD(-8.8245263323e-003),
QTMFLLD(2.2267201915e-002), QTMFLLD(-6.3721030951e-001),
QTMFLLD(-2.8387091588e-003), QTMFLLD(1.9518326735e-004),
QTMFLLD(-8.5145104676e-003), QTMFLLD(3.2023012638e-002),
QTMFLLD(-6.2485051155e-001), QTMFLLD(-2.3975048680e-003),
QTMFLLD(3.2545044087e-004), QTMFLLD(-8.1687811762e-003),
QTMFLLD(4.2033810169e-002), QTMFLLD(-6.1239802837e-001),
QTMFLLD(-1.9807203207e-003), QTMFLLD(4.5712510473e-004),
QTMFLLD(-7.7859172598e-003), QTMFLLD(5.2295893431e-002),
QTMFLLD(-5.9986191988e-001), QTMFLLD(-1.6010539839e-003),
QTMFLLD(5.9015140869e-004), QTMFLLD(-7.3645371012e-003),
QTMFLLD(6.2805138528e-002), QTMFLLD(-5.8725595474e-001),
QTMFLLD(-1.2320743408e-003), QTMFLLD(7.2508689482e-004),
QTMFLLD(-6.9030462764e-003), QTMFLLD(7.3557935655e-002),
QTMFLLD(-5.7460016012e-001), QTMFLLD(-7.9492607620e-004)};
//@{
/*!
\name DCT_II twiddle factors, L=64
*/
/*! sin (3.14159265358979323 / (2*L) * n) , L=64*/
LNK_SECTION_CONSTDATA
RAM_ALIGN
const FIXP_WTP sin_twiddle_L64[] = {
WTCP(0x7fffffff, 0x00000000), WTCP(0x7ff62182, 0x03242abf),
WTCP(0x7fd8878e, 0x0647d97c), WTCP(0x7fa736b4, 0x096a9049),
WTCP(0x7f62368f, 0x0c8bd35e), WTCP(0x7f0991c4, 0x0fab272b),
WTCP(0x7e9d55fc, 0x12c8106f), WTCP(0x7e1d93ea, 0x15e21445),
WTCP(0x7d8a5f40, 0x18f8b83c), WTCP(0x7ce3ceb2, 0x1c0b826a),
WTCP(0x7c29fbee, 0x1f19f97b), WTCP(0x7b5d039e, 0x2223a4c5),
WTCP(0x7a7d055b, 0x25280c5e), WTCP(0x798a23b1, 0x2826b928),
WTCP(0x78848414, 0x2b1f34eb), WTCP(0x776c4edb, 0x2e110a62),
WTCP(0x7641af3d, 0x30fbc54d), WTCP(0x7504d345, 0x33def287),
WTCP(0x73b5ebd1, 0x36ba2014), WTCP(0x72552c85, 0x398cdd32),
WTCP(0x70e2cbc6, 0x3c56ba70), WTCP(0x6f5f02b2, 0x3f1749b8),
WTCP(0x6dca0d14, 0x41ce1e65), WTCP(0x6c242960, 0x447acd50),
WTCP(0x6a6d98a4, 0x471cece7), WTCP(0x68a69e81, 0x49b41533),
WTCP(0x66cf8120, 0x4c3fdff4), WTCP(0x64e88926, 0x4ebfe8a5),
WTCP(0x62f201ac, 0x5133cc94), WTCP(0x60ec3830, 0x539b2af0),
WTCP(0x5ed77c8a, 0x55f5a4d2), WTCP(0x5cb420e0, 0x5842dd54),
WTCP(0x5a82799a, 0x5a82799a), WTCP(0x5842dd54, 0x5cb420e0),
WTCP(0x55f5a4d2, 0x5ed77c8a), WTCP(0x539b2af0, 0x60ec3830),
WTCP(0x5133cc94, 0x62f201ac), WTCP(0x4ebfe8a5, 0x64e88926),
WTCP(0x4c3fdff4, 0x66cf8120), WTCP(0x49b41533, 0x68a69e81),
WTCP(0x471cece7, 0x6a6d98a4), WTCP(0x447acd50, 0x6c242960),
WTCP(0x41ce1e65, 0x6dca0d14), WTCP(0x3f1749b8, 0x6f5f02b2),
WTCP(0x3c56ba70, 0x70e2cbc6), WTCP(0x398cdd32, 0x72552c85),
WTCP(0x36ba2014, 0x73b5ebd1), WTCP(0x33def287, 0x7504d345),
WTCP(0x30fbc54d, 0x7641af3d), WTCP(0x2e110a62, 0x776c4edb),
WTCP(0x2b1f34eb, 0x78848414), WTCP(0x2826b928, 0x798a23b1),
WTCP(0x25280c5e, 0x7a7d055b), WTCP(0x2223a4c5, 0x7b5d039e),
WTCP(0x1f19f97b, 0x7c29fbee), WTCP(0x1c0b826a, 0x7ce3ceb2),
WTCP(0x18f8b83c, 0x7d8a5f40), WTCP(0x15e21445, 0x7e1d93ea),
WTCP(0x12c8106f, 0x7e9d55fc), WTCP(0x0fab272b, 0x7f0991c4),
WTCP(0x0c8bd35e, 0x7f62368f), WTCP(0x096a9049, 0x7fa736b4),
WTCP(0x0647d97c, 0x7fd8878e), WTCP(0x03242abf, 0x7ff62182)};
const USHORT sqrt_tab[49] = {
0x5a82, 0x5d4b, 0x6000, 0x62a1, 0x6531, 0x67b1, 0x6a21, 0x6c84, 0x6ed9,
0x7123, 0x7360, 0x7593, 0x77bb, 0x79da, 0x7bef, 0x7dfb, 0x8000, 0x81fc,
0x83f0, 0x85dd, 0x87c3, 0x89a3, 0x8b7c, 0x8d4e, 0x8f1b, 0x90e2, 0x92a4,
0x9460, 0x9617, 0x97ca, 0x9977, 0x9b20, 0x9cc4, 0x9e64, 0xa000, 0xa197,
0xa32b, 0xa4ba, 0xa646, 0xa7cf, 0xa953, 0xaad5, 0xac53, 0xadcd, 0xaf45,
0xb0b9, 0xb22b, 0xb399, 0xb504};
LNK_SECTION_CONSTDATA_L1
const FIXP_DBL invCount[80] = /* This could be 16-bit wide */
{0x00000000, 0x7fffffff, 0x40000000, 0x2aaaaaab, 0x20000000, 0x1999999a,
0x15555555, 0x12492492, 0x10000000, 0x0e38e38e, 0x0ccccccd, 0x0ba2e8ba,
0x0aaaaaab, 0x09d89d8a, 0x09249249, 0x08888889, 0x08000000, 0x07878788,
0x071c71c7, 0x06bca1af, 0x06666666, 0x06186186, 0x05d1745d, 0x0590b216,
0x05555555, 0x051eb852, 0x04ec4ec5, 0x04bda12f, 0x04924925, 0x0469ee58,
0x04444444, 0x04210842, 0x04000000, 0x03e0f83e, 0x03c3c3c4, 0x03a83a84,
0x038e38e4, 0x03759f23, 0x035e50d8, 0x03483483, 0x03333333, 0x031f3832,
0x030c30c3, 0x02fa0be8, 0x02e8ba2f, 0x02d82d83, 0x02c8590b, 0x02b93105,
0x02aaaaab, 0x029cbc15, 0x028f5c29, 0x02828283, 0x02762762, 0x026a439f,
0x025ed098, 0x0253c825, 0x02492492, 0x023ee090, 0x0234f72c, 0x022b63cc,
0x02222222, 0x02192e2a, 0x02108421, 0x02082082, 0x02000000, 0x01f81f82,
0x01f07c1f, 0x01e9131b, 0x01e1e1e2, 0x01dae607, 0x01d41d42, 0x01cd8569,
0x01c71c72, 0x01c0e070, 0x01bacf91, 0x01b4e81b, 0x01af286c, 0x01a98ef6,
0x01a41a42, 0x019ec8e9};
/*
* Bitstream data lists
*/
/*
* AOT {2,5,29}
* epConfig = -1
*/
static const rbd_id_t el_aac_sce[] = {
adtscrc_start_reg1, element_instance_tag, global_gain, ics_info,
section_data, scale_factor_data, pulse, tns_data_present, tns_data,
gain_control_data_present,
/* gain_control_data, */
spectral_data, adtscrc_end_reg1, end_of_sequence};
static const struct element_list node_aac_sce = {el_aac_sce, {NULL, NULL}};
/* CCE */
static const rbd_id_t el_aac_cce[] = {
adtscrc_start_reg1, element_instance_tag,
coupled_elements, /* CCE specific */
global_gain, ics_info, section_data, scale_factor_data, pulse,
tns_data_present, tns_data, gain_control_data_present,
/* gain_control_data, */
spectral_data, gain_element_lists, /* CCE specific */
adtscrc_end_reg1, end_of_sequence};
static const struct element_list node_aac_cce = {el_aac_cce, {NULL, NULL}};
static const rbd_id_t el_aac_cpe[] = {adtscrc_start_reg1, element_instance_tag,
common_window, link_sequence};
static const rbd_id_t el_aac_cpe0[] = {
/*common_window = 0*/
global_gain, ics_info, section_data, scale_factor_data, pulse,
tns_data_present, tns_data, gain_control_data_present,
/*gain_control_data,*/
spectral_data, next_channel,
adtscrc_start_reg2, global_gain, ics_info, section_data, scale_factor_data,
pulse, tns_data_present, tns_data, gain_control_data_present,
/*gain_control_data,*/
spectral_data, adtscrc_end_reg1, adtscrc_end_reg2, end_of_sequence};
static const rbd_id_t el_aac_cpe1[] = {
/* common_window = 1 */
ics_info, ms,
global_gain, section_data, scale_factor_data, pulse, tns_data_present,
tns_data, gain_control_data_present,
/*gain_control_data,*/
spectral_data, next_channel,
adtscrc_start_reg2, global_gain, section_data, scale_factor_data, pulse,
tns_data_present, tns_data, gain_control_data_present,
/*gain_control_data,*/
spectral_data, adtscrc_end_reg1, adtscrc_end_reg2, end_of_sequence};
static const struct element_list node_aac_cpe0 = {el_aac_cpe0, {NULL, NULL}};
static const struct element_list node_aac_cpe1 = {el_aac_cpe1, {NULL, NULL}};
static const element_list_t node_aac_cpe = {el_aac_cpe,
{&node_aac_cpe0, &node_aac_cpe1}};
/*
* AOT C- {17,23}
* epConfig = 0,1
*/
static const rbd_id_t el_aac_sce_epc0[] = {
element_instance_tag,
global_gain,
ics_info,
section_data,
scale_factor_data,
pulse,
tns_data_present,
gain_control_data_present,
gain_control_data,
esc1_hcr, /*length_of_rvlc_escapes, length_of_rvlc_sf */
esc2_rvlc, /* rvlc_cod_sf, rvlc_esc_sf */
tns_data,
spectral_data,
end_of_sequence};
static const struct element_list node_aac_sce_epc0 = {el_aac_sce_epc0,
{NULL, NULL}};
static const rbd_id_t el_aac_sce_epc1[] = {
element_instance_tag, global_gain, ics_info, section_data,
scale_factor_data, pulse, tns_data_present, gain_control_data_present,
/*gain_control_data,*/
esc1_hcr, /*length_of_rvlc_escapes, length_of_rvlc_sf */
esc2_rvlc, /* rvlc_cod_sf, rvlc_esc_sf */
tns_data, spectral_data, end_of_sequence};
static const struct element_list node_aac_sce_epc1 = {el_aac_sce_epc1,
{NULL, NULL}};
static const rbd_id_t el_aac_cpe_epc0[] = {element_instance_tag, common_window,
link_sequence};
static const rbd_id_t el_aac_cpe0_epc0[] = {
/* common_window = 0 */
/* ESC 1: */
global_gain, ics_info,
/* ltp_data_present,
ltp_data,
*/
section_data, scale_factor_data, pulse, tns_data_present,
gain_control_data_present,
/*gain_control_data,*/
esc1_hcr, /*length_of_rvlc_escapes, length_of_rvlc_sf */
/* ESC 2: */
esc2_rvlc, /* rvlc_cod_sf, rvlc_esc_sf */
/* ESC 3: */
tns_data,
/* ESC 4: */
spectral_data, next_channel,
/* ESC 1: */
global_gain, ics_info,
/* ltp_data_present,
ltp_data,
*/
section_data, scale_factor_data, pulse, tns_data_present,
gain_control_data_present,
/*gain_control_data,*/
esc1_hcr, /*length_of_rvlc_escapes, length_of_rvlc_sf */
/* ESC 2: */
esc2_rvlc, /* rvlc_cod_sf, rvlc_esc_sf */
/* ESC 3: */
tns_data,
/* ESC 4: */
spectral_data, end_of_sequence};
static const rbd_id_t el_aac_cpe1_epc0[] = {
/* common_window = 1 */
/* ESC 0: */
ics_info,
/* ltp_data_present,
ltp_data,
next_channel,
ltp_data_present,
ltp_data,
next_channel,
*/
ms,
/* ESC 1: */
global_gain, section_data, scale_factor_data, pulse, tns_data_present,
gain_control_data_present,
/*gain_control_data,*/
esc1_hcr, /* length_of_reordered_spectral_data, length_of_longest_codeword
*/
/* ESC 2: */
esc2_rvlc, /* rvlc_cod_sf, rvlc_esc_sf */
/* ESC 3: */
tns_data,
/* ESC 4: */
spectral_data, next_channel,
/* ESC 1: */
global_gain, section_data, scale_factor_data, pulse, tns_data_present,
gain_control_data_present,
/*gain_control_data,*/
esc1_hcr, /* length_of_reordered_spectral_data, length_of_longest_codeword
*/
/* ESC 2: */
esc2_rvlc, /* rvlc_cod_sf, rvlc_esc_sf */
/* ESC 3: */
tns_data,
/* ESC 4: */
spectral_data, end_of_sequence};
static const struct element_list node_aac_cpe0_epc0 = {el_aac_cpe0_epc0,
{NULL, NULL}};
static const struct element_list node_aac_cpe1_epc0 = {el_aac_cpe1_epc0,
{NULL, NULL}};
static const element_list_t node_aac_cpe_epc0 = {
el_aac_cpe_epc0, {&node_aac_cpe0_epc0, &node_aac_cpe1_epc0}};
static const rbd_id_t el_aac_cpe0_epc1[] = {
global_gain, ics_info, section_data, scale_factor_data, pulse,
tns_data_present, gain_control_data_present,
/*gain_control_data,*/
next_channel, global_gain, ics_info, section_data, scale_factor_data, pulse,
tns_data_present, gain_control_data_present,
/*gain_control_data,*/
next_channel, esc1_hcr, /*length_of_rvlc_escapes, length_of_rvlc_sf */
next_channel, esc1_hcr, /*length_of_rvlc_escapes, length_of_rvlc_sf */
next_channel, esc2_rvlc, /* rvlc_cod_sf, rvlc_esc_sf */
next_channel, esc2_rvlc, /* rvlc_cod_sf, rvlc_esc_sf */
next_channel, tns_data, next_channel, tns_data, next_channel, spectral_data,
next_channel, spectral_data, end_of_sequence};
static const rbd_id_t el_aac_cpe1_epc1[] = {
ics_info, ms, ltp_data_present,
/* ltp_data, */
global_gain, section_data, scale_factor_data, pulse, tns_data_present,
gain_control_data_present,
/*gain_control_data,*/
next_channel,
ltp_data_present,
/* ltp_data, */
global_gain, section_data, scale_factor_data, pulse, tns_data_present,
gain_control_data_present,
/*gain_control_data,*/
next_channel, esc1_hcr, /*length_of_rvlc_escapes, length_of_rvlc_sf */
next_channel, esc1_hcr, /*length_of_rvlc_escapes, length_of_rvlc_sf */
next_channel, esc2_rvlc, /* rvlc_cod_sf, rvlc_esc_sf */
next_channel, esc2_rvlc, /* rvlc_cod_sf, rvlc_esc_sf */
next_channel, tns_data, next_channel, tns_data, next_channel, spectral_data,
next_channel, spectral_data, end_of_sequence};
static const struct element_list node_aac_cpe0_epc1 = {el_aac_cpe0_epc1,
{NULL, NULL}};
static const struct element_list node_aac_cpe1_epc1 = {el_aac_cpe1_epc1,
{NULL, NULL}};
static const element_list_t node_aac_cpe_epc1 = {
el_aac_cpe, {&node_aac_cpe0_epc1, &node_aac_cpe1_epc1}};
/*
* AOT = 20
* epConfig = 0
*/
static const rbd_id_t el_scal_sce_epc0[] = {ics_info, /* ESC 1 */
tns_data_present, ltp_data_present,
/* ltp_data, */
global_gain, section_data,
scale_factor_data, esc1_hcr,
esc2_rvlc, /* ESC 2 */
tns_data, /* ESC 3 */
spectral_data, /* ESC 4 */
end_of_sequence};
static const struct element_list node_scal_sce_epc0 = {el_scal_sce_epc0,
{NULL, NULL}};
static const rbd_id_t el_scal_cpe_epc0[] = {
ics_info, /* ESC 0 */
ms, tns_data_present, /* ESC 1 (ch 0) */
ltp_data_present,
/* ltp_data, */
global_gain, section_data, scale_factor_data, esc1_hcr,
esc2_rvlc, /* ESC 2 (ch 0) */
tns_data, /* ESC 3 (ch 0) */
spectral_data, /* ESC 4 (ch 0) */
next_channel, tns_data_present, /* ESC 1 (ch 1) */
ltp_data_present, global_gain, section_data, scale_factor_data, esc1_hcr,
esc2_rvlc, /* ESC 2 (ch 1) */
tns_data, /* ESC 3 (ch 1) */
spectral_data, /* ESC 4 (ch 1) */
end_of_sequence};
static const struct element_list node_scal_cpe_epc0 = {el_scal_cpe_epc0,
{NULL, NULL}};
/*
* AOT = 20
* epConfig = 1
*/
static const rbd_id_t el_scal_sce_epc1[] = {
ics_info, tns_data_present, ltp_data_present,
/* ltp_data, */
global_gain, section_data, scale_factor_data, esc1_hcr, tns_data,
spectral_data, end_of_sequence};
static const struct element_list node_scal_sce_epc1 = {el_scal_sce_epc1,
{NULL, NULL}};
static const rbd_id_t el_scal_cpe_epc1[] = {
ics_info, ms, tns_data_present, ltp_data_present,
/* ltp_data, */
global_gain, section_data, scale_factor_data, esc1_hcr, next_channel,
tns_data_present, ltp_data_present,
/* ltp_data, */
global_gain, section_data, scale_factor_data, esc1_hcr, next_channel,
tns_data, next_channel, tns_data, next_channel, spectral_data, next_channel,
spectral_data, end_of_sequence};
static const struct element_list node_scal_cpe_epc1 = {el_scal_cpe_epc1,
{NULL, NULL}};
/*
* Pseudo AOT for DRM/DRM+ (similar to AOT 20)
*/
static const rbd_id_t el_drm_sce[] = {
drmcrc_start_reg, ics_info, tns_data_present, ltp_data_present,
/* ltp_data, */
global_gain, section_data, scale_factor_data, esc1_hcr, tns_data,
drmcrc_end_reg, spectral_data, end_of_sequence};
static const struct element_list node_drm_sce = {el_drm_sce, {NULL, NULL}};
static const rbd_id_t el_drm_cpe[] = {
drmcrc_start_reg, ics_info, ms, tns_data_present, ltp_data_present,
/* ltp_data, */
global_gain, section_data, scale_factor_data, esc1_hcr, next_channel,
tns_data_present, ltp_data_present,
/* ltp_data, */
global_gain, section_data, scale_factor_data, esc1_hcr, next_channel,
tns_data, next_channel, tns_data, drmcrc_end_reg, next_channel,
spectral_data, next_channel, spectral_data, end_of_sequence};
static const struct element_list node_drm_cpe = {el_drm_cpe, {NULL, NULL}};
/*
* AOT = 39
* epConfig = 0
*/
static const rbd_id_t el_eld_sce_epc0[] = {
global_gain, ics_info, section_data, scale_factor_data, tns_data_present,
tns_data, esc1_hcr, esc2_rvlc, spectral_data, end_of_sequence};
static const struct element_list node_eld_sce_epc0 = {el_eld_sce_epc0,
{NULL, NULL}};
#define node_eld_sce_epc1 node_eld_sce_epc0
static const rbd_id_t el_eld_cpe_epc0[] = {ics_info, ms,
global_gain, section_data,
scale_factor_data, tns_data_present,
tns_data, esc1_hcr,
esc2_rvlc, spectral_data,
next_channel, global_gain,
section_data, scale_factor_data,
tns_data_present, tns_data,
esc1_hcr, esc2_rvlc,
spectral_data, end_of_sequence};
static const rbd_id_t el_eld_cpe_epc1[] = {ics_info, ms,
global_gain, section_data,
scale_factor_data, tns_data_present,
next_channel, global_gain,
section_data, scale_factor_data,
tns_data_present, next_channel,
tns_data, next_channel,
tns_data, next_channel,
esc1_hcr, esc2_rvlc,
spectral_data, next_channel,
esc1_hcr, esc2_rvlc,
spectral_data, end_of_sequence};
static const struct element_list node_eld_cpe_epc0 = {el_eld_cpe_epc0,
{NULL, NULL}};
static const struct element_list node_eld_cpe_epc1 = {el_eld_cpe_epc1,
{NULL, NULL}};
/*
* AOT = 42
* epConfig = 0
*/
static const rbd_id_t el_usac_coremode[] = {core_mode, next_channel,
link_sequence};
static const rbd_id_t el_usac_sce0_epc0[] = {
tns_data_present,
/* fd_channel_stream */
global_gain, noise, ics_info, tw_data, scale_factor_data_usac, tns_data,
ac_spectral_data, fac_data, end_of_sequence};
static const rbd_id_t el_usac_lfe_epc0[] = {
/* fd_channel_stream */
global_gain, ics_info, scale_factor_data_usac,
ac_spectral_data, fac_data, end_of_sequence};
static const rbd_id_t el_usac_lpd_epc0[] = {lpd_channel_stream,
end_of_sequence};
static const struct element_list node_usac_sce0_epc0 = {el_usac_sce0_epc0,
{NULL, NULL}};
static const struct element_list node_usac_sce1_epc0 = {el_usac_lpd_epc0,
{NULL, NULL}};
static const struct element_list node_usac_sce_epc0 = {
el_usac_coremode, {&node_usac_sce0_epc0, &node_usac_sce1_epc0}};
static const rbd_id_t list_usac_cpe00_epc0[] = {tns_active, common_window,
link_sequence};
static const rbd_id_t el_usac_common_tw[] = {common_tw, link_sequence};
static const rbd_id_t list_usac_cpe0000_epc0[] = {
/* core_mode0 = 0 */
/* core_mode1 = 0 */
/* common_window = 0 */
/* common_tw = 0 */
tns_data_present_usac,
global_gain,
noise,
ics_info,
tw_data,
scale_factor_data_usac,
tns_data,
ac_spectral_data,
fac_data,
next_channel,
global_gain,
noise,
ics_info,
tw_data,
scale_factor_data_usac,
tns_data,
ac_spectral_data,
fac_data,
end_of_sequence};
static const rbd_id_t list_usac_cpe0001_epc0[] = {
/*
core_mode0 = 0
core_mode1 = 0
common_window = 0
common_tw = 1
*/
tw_data, tns_data_present_usac, global_gain, noise,
ics_info, scale_factor_data_usac, tns_data, ac_spectral_data,
fac_data, next_channel, global_gain, noise,
ics_info, scale_factor_data_usac, tns_data, ac_spectral_data,
fac_data, end_of_sequence};
static const rbd_id_t list_usac_cpe001_epc0[] = {
/* core_mode0 = 0 */
/* core_mode1 = 0 */
/* common_window = 1 */
ics_info, common_max_sfb, ms, common_tw, link_sequence};
static const rbd_id_t list_usac_cpe0010_epc0[] = {
/* core_mode0 = 0 */
/* core_mode1 = 0 */
/* common_window = 1 */
/* common_tw = 0 */
tns_data_present_usac,
global_gain,
noise,
tw_data,
scale_factor_data_usac,
tns_data,
ac_spectral_data,
fac_data,
next_channel,
global_gain,
noise,
tw_data,
scale_factor_data_usac,
tns_data,
ac_spectral_data,
fac_data,
end_of_sequence};
static const rbd_id_t list_usac_cpe0011_epc0[] = {
/* core_mode0 = 0 */
/* core_mode1 = 0 */
/* common_window = 1 */
/* common_tw = 1 */
tw_data,
tns_data_present_usac,
global_gain,
noise,
scale_factor_data_usac,
tns_data,
ac_spectral_data,
fac_data,
next_channel,
global_gain,
noise,
scale_factor_data_usac,
tns_data,
ac_spectral_data,
fac_data,
end_of_sequence};
static const rbd_id_t list_usac_cpe10_epc0[] = {
/* core_mode0 = 1 */
/* core_mode1 = 0 */
lpd_channel_stream,
next_channel,
tns_data_present,
global_gain,
noise,
ics_info,
tw_data,
scale_factor_data_usac,
tns_data,
ac_spectral_data,
fac_data,
end_of_sequence};
static const rbd_id_t list_usac_cpe01_epc0[] = {
/* core_mode0 = 0 */
/* core_mode1 = 1 */
tns_data_present,
global_gain,
noise,
ics_info,
tw_data,
scale_factor_data_usac,
tns_data,
ac_spectral_data,
fac_data,
next_channel,
lpd_channel_stream,
end_of_sequence};
static const rbd_id_t list_usac_cpe11_epc0[] = {
/* core_mode0 = 1 */
/* core_mode1 = 1 */
lpd_channel_stream, next_channel, lpd_channel_stream, end_of_sequence};
static const struct element_list node_usac_cpe0000_epc0 = {
/* core_mode0 = 0 */
/* core_mode1 = 0 */
/* common_window = 0 */
/* common_tw = 0 */
list_usac_cpe0000_epc0,
{NULL, NULL}};
static const struct element_list node_usac_cpe0010_epc0 = {
/* core_mode0 = 0 */
/* core_mode1 = 0 */
/* common_window = 1 */
/* common_tw = 0 */
list_usac_cpe0010_epc0,
{NULL, NULL}};
static const struct element_list node_usac_cpe0001_epc0 = {
/* core_mode0 = 0 */
/* core_mode1 = 0 */
/* common_window = 0 */
/* common_tw = 1 */
list_usac_cpe0001_epc0,
{NULL, NULL}};
static const struct element_list node_usac_cpe0011_epc0 = {
/* core_mode0 = 0 */
/* core_mode1 = 0 */
/* common_window = 1 */
/* common_tw = 1 */
list_usac_cpe0011_epc0,
{NULL, NULL}};
static const struct element_list node_usac_cpe000_epc0 = {
/* core_mode0 = 0 */
/* core_mode1 = 0 */
/* common_window = 0 */
el_usac_common_tw,
{&node_usac_cpe0000_epc0, &node_usac_cpe0001_epc0}};
static const struct element_list node_usac_cpe001_epc0 = {
list_usac_cpe001_epc0, {&node_usac_cpe0010_epc0, &node_usac_cpe0011_epc0}};
static const struct element_list node_usac_cpe00_epc0 = {
/* core_mode0 = 0 */
/* core_mode1 = 0 */
list_usac_cpe00_epc0,
{&node_usac_cpe000_epc0, &node_usac_cpe001_epc0}};
static const struct element_list node_usac_cpe10_epc0 = {
/* core_mode0 = 1 */
/* core_mode1 = 0 */
list_usac_cpe10_epc0,
{NULL, NULL}};
static const struct element_list node_usac_cpe01_epc0 = {list_usac_cpe01_epc0,
{NULL, NULL}};
static const struct element_list node_usac_cpe11_epc0 = {list_usac_cpe11_epc0,
{NULL, NULL}};
static const struct element_list node_usac_cpe0_epc0 = {
/* core_mode0 = 0 */
el_usac_coremode,
{&node_usac_cpe00_epc0, &node_usac_cpe01_epc0}};
static const struct element_list node_usac_cpe1_epc0 = {
/* core_mode0 = 1 */
el_usac_coremode,
{&node_usac_cpe10_epc0, &node_usac_cpe11_epc0}};
static const struct element_list node_usac_cpe_epc0 = {
el_usac_coremode, {&node_usac_cpe0_epc0, &node_usac_cpe1_epc0}};
static const struct element_list node_usac_lfe_epc0 = {el_usac_lfe_epc0,
{NULL, NULL}};
const element_list_t *getBitstreamElementList(AUDIO_OBJECT_TYPE aot,
SCHAR epConfig, UCHAR nChannels,
UCHAR layer, UINT elFlags) {
switch (aot) {
case AOT_AAC_LC:
case AOT_SBR:
case AOT_PS:
FDK_ASSERT(epConfig == -1);
if (elFlags & AC_EL_GA_CCE) {
return &node_aac_cce;
} else {
if (nChannels == 1) {
return &node_aac_sce;
} else {
return &node_aac_cpe;
}
}
case AOT_ER_AAC_LC:
case AOT_ER_AAC_LD:
if (nChannels == 1) {
if (epConfig == 0) {
return &node_aac_sce_epc0;
} else {
return &node_aac_sce_epc1;
}
} else {
if (epConfig == 0)
return &node_aac_cpe_epc0;
else
return &node_aac_cpe_epc1;
}
case AOT_USAC:
if (elFlags & AC_EL_USAC_LFE) {
FDK_ASSERT(nChannels == 1);
return &node_usac_lfe_epc0;
}
if (nChannels == 1) {
return &node_usac_sce_epc0;
} else {
return &node_usac_cpe_epc0;
}
case AOT_ER_AAC_SCAL:
if (nChannels == 1) {
if (epConfig <= 0)
return &node_scal_sce_epc0;
else
return &node_scal_sce_epc1;
} else {
if (epConfig <= 0)
return &node_scal_cpe_epc0;
else
return &node_scal_cpe_epc1;
}
case AOT_ER_AAC_ELD:
if (nChannels == 1) {
if (epConfig <= 0)
return &node_eld_sce_epc0;
else
return &node_eld_sce_epc1;
} else {
if (epConfig <= 0)
return &node_eld_cpe_epc0;
else
return &node_eld_cpe_epc1;
}
case AOT_DRM_AAC:
case AOT_DRM_SBR:
case AOT_DRM_MPEG_PS:
case AOT_DRM_SURROUND:
FDK_ASSERT(epConfig == 1);
if (nChannels == 1) {
return &node_drm_sce;
} else {
return &node_drm_cpe;
}
default:
break;
}
return NULL;
}
/* Inverse square root table for operands running from 0.5 to ~1.0 */
/* (INT) (0.5 + 1.0/sqrt((op)/FDKpow(2.0,31))); */
/* Note: First value is rnot rounded for accuracy reasons */
/* Implicit exponent is 1. */
/* Examples: 0x5A82799A = invSqrtNorm2 (0x4000.0000), exp=1 */
/* 0x5A82799A = invSqrtNorm2 (0x4000.0000), exp=1 */
LNK_SECTION_CONSTDATA_L1
const FIXP_DBL invSqrtTab[SQRT_VALUES] = {
0x5A827999, 0x5A287E03, 0x59CF8CBC, 0x5977A0AC, 0x5920B4DF, 0x58CAC480,
0x5875CADE, 0x5821C364, 0x57CEA99D, 0x577C7930, 0x572B2DE0, 0x56DAC38E,
0x568B3632, 0x563C81E0, 0x55EEA2C4, 0x55A19522, 0x55555555, 0x5509DFD0,
0x54BF311A, 0x547545D0, 0x542C1AA4, 0x53E3AC5B, 0x539BF7CD, 0x5354F9E7,
0x530EAFA5, 0x52C91618, 0x52842A5F, 0x523FE9AC, 0x51FC5140, 0x51B95E6B,
0x51770E8F, 0x51355F1A, 0x50F44D89, 0x50B3D768, 0x5073FA50, 0x5034B3E7,
0x4FF601E0, 0x4FB7E1FA, 0x4F7A5202, 0x4F3D4FCF, 0x4F00D944, 0x4EC4EC4F,
0x4E8986EA, 0x4E4EA718, 0x4E144AE9, 0x4DDA7073, 0x4DA115DA, 0x4D683948,
0x4D2FD8F4, 0x4CF7F31B, 0x4CC08605, 0x4C899000, 0x4C530F65, 0x4C1D0294,
0x4BE767F5, 0x4BB23DF9, 0x4B7D8317, 0x4B4935CF, 0x4B1554A6, 0x4AE1DE2A,
0x4AAED0F0, 0x4A7C2B93, 0x4A49ECB3, 0x4A1812FA, 0x49E69D16, 0x49B589BB,
0x4984D7A4, 0x49548592, 0x49249249, 0x48F4FC97, 0x48C5C34B, 0x4896E53D,
0x48686148, 0x483A364D, 0x480C6332, 0x47DEE6E1, 0x47B1C049, 0x4784EE60,
0x4758701C, 0x472C447C, 0x47006A81, 0x46D4E130, 0x46A9A794, 0x467EBCBA,
0x46541FB4, 0x4629CF98, 0x45FFCB80, 0x45D6128A, 0x45ACA3D5, 0x45837E88,
0x455AA1CB, 0x45320CC8, 0x4509BEB0, 0x44E1B6B4, 0x44B9F40B, 0x449275ED,
0x446B3B96, 0x44444444, 0x441D8F3B, 0x43F71BBF, 0x43D0E917, 0x43AAF68F,
0x43854374, 0x435FCF15, 0x433A98C6, 0x43159FDC, 0x42F0E3AE, 0x42CC6398,
0x42A81EF6, 0x42841527, 0x4260458E, 0x423CAF8D, 0x4219528B, 0x41F62DF2,
0x41D3412A, 0x41B08BA2, 0x418E0CC8, 0x416BC40D, 0x4149B0E5, 0x4127D2C3,
0x41062920, 0x40E4B374, 0x40C3713B, 0x40A261EF, 0x40818512, 0x4060DA22,
0x404060A1, 0x40201814, 0x40000000, 0x3FE017EC /* , 0x3FC05F61 */
};
/* number of channels of the formats */
const INT format_nchan[FDK_NFORMATS + 9 - 2] = {
0, /* any set-up, ChConfIdx = 0 */
1, /* mono ChConfIdx = 1 */
2, /* stereo ChConfIdx = 2 */
3, /* 3/0.0 ChConfIdx = 3 */
4, /* 3/1.0 ChConfIdx = 4 */
5, /* 3/2.0 ChConfIdx = 5 */
6, /* 5.1 ChConfIdx = 6 */
8, /* 5/2.1 ALT ChConfIdx = 7 */
0, /* Empty n.a. ChConfIdx = 8 */
3, /* 2/1.0 ChConfIdx = 9 */
4, /* 2/2.0 ChConfIdx = 10 */
7, /* 3/3.1 ChConfIdx = 11 */
8, /* 3/4.1 ChConfIdx = 12 */
24, /* 22.2 ChConfIdx = 13 */
8, /* 5/2.1 ChConfIdx = 14 */
12, /* 5/5.2 ChConfIdx = 15 */
10, /* 5/4.1 ChConfIdx = 16 */
12, /* 6/5.1 ChConfIdx = 17 */
14, /* 6/7.1 ChConfIdx = 18 */
12, /* 5/6.1 ChConfIdx = 19 */
14 /* 7/6.1 ChConfIdx = 20 */
};
| 54.017739 | 80 | 0.717869 | [
"shape"
] |
1b416c537e0284d2c0106da37c5414e2ed056a9d | 34,062 | cxx | C++ | PWG/muon/AliAnalysisTaskMuMu.cxx | maroozm/AliPhysics | 22ec256928cfdf8f800e05bfc1a6e124d90b6eaf | [
"BSD-3-Clause"
] | 114 | 2017-03-03T09:12:23.000Z | 2022-03-03T20:29:42.000Z | PWG/muon/AliAnalysisTaskMuMu.cxx | maroozm/AliPhysics | 22ec256928cfdf8f800e05bfc1a6e124d90b6eaf | [
"BSD-3-Clause"
] | 19,637 | 2017-01-16T12:34:41.000Z | 2022-03-31T22:02:40.000Z | PWG/muon/AliAnalysisTaskMuMu.cxx | maroozm/AliPhysics | 22ec256928cfdf8f800e05bfc1a6e124d90b6eaf | [
"BSD-3-Clause"
] | 1,021 | 2016-07-14T22:41:16.000Z | 2022-03-31T05:15:51.000Z | #include "AliAnalysisTaskMuMu.h"
#include "AliAnalysisManager.h"
#include "AliMultEstimator.h"
#include "AliAnalysisMuMuBase.h"
#include "AliAnalysisMuMuBinning.h"
#include "AliAnalysisMuMuCutCombination.h"
#include "AliAnalysisMuMuCutElement.h"
#include "AliAnalysisMuMuCutRegistry.h"
#include "AliAnalysisMuonUtility.h"
#include "AliAnalysisUtils.h"
#include "AliAODEvent.h"
#include "AliAODMCParticle.h"
#include "AliAODTrack.h"
#include "AliAODTZERO.h"
#include "AliCentrality.h"
#include "AliCodeTimer.h"
#include "AliCounterCollection.h"
#include "AliESDEvent.h"
#include "AliESDTZERO.h"
#include "AliInputEventHandler.h"
#include "AliAnalysisManager.h"
#include "AliLog.h"
#include "AliMCEvent.h"
#include "AliMCEventHandler.h"
#include "AliMergeableCollection.h"
#include "AliMultSelection.h"
#include "AliMuonTrackCuts.h"
#include "Riostream.h"
#include "TCanvas.h"
#include "TDatabasePDG.h"
#include "TFormula.h"
#include "TH1.h"
#include "TH2.h"
#include "THashList.h"
#include "TList.h"
#include "TMath.h"
#include "TObjString.h"
#include "TParameter.h"
#include "TPaveText.h"
#include "TProfile.h"
#include "TRegexp.h"
#include "TROOT.h"
#include <algorithm>
#include <cassert>
#include <set>
///
/// \ class AliAnalysisTaskMuMu
///
/// This class stores several analysis subclasses based on AliAnalysisMuMuBase.
/// The output contains an AliHistogramCollection and
/// an AliCounterCollection filled with tthe different subclasses.
///
/// \author: L. Aphecetche (Subatech)
///
/// This task must be configured a bit before being used. For instance
/// you can select various event cuts, single muon track cuts and
/// muon pairs cut, as well as defining various bins (for minv and mean pt
/// histograms) in pt,y,phi etc...
///
/// Note that it's also possible to disable some (or all) histograms
/// (to save speed/memory), using DisableHistograms() method. Also, this task can run both on single and mixed events.
/// In the case of mixed event, both the UserExec() and UserExecMix() are executed, but in the later case the AliCounterCollection is not filled.
///
/// For an example of such configuration, \see AddTaskMuMu.C
///
using std::cout;
using std::endl;
ClassImp(AliAnalysisTaskMuMu)
//_____________________________________________________________________________
AliAnalysisTaskMuMu::AliAnalysisTaskMuMu()
: AliAnalysisTaskSE("AliAnalysisTaskMuMu"),
fHistogramCollection(0),
fEventCounters(0),
fBinning(0x0),
fCutRegistry(0x0),
fCutRegistryMix(0x0),
fBeamYear(""),
fHistogramToDisable(0x0),
fSubAnalysisVector(0x0),
fCountInBins(kFALSE),
fbinWhat(""),
fbinQuantity(""),
fbinFlavor(""),
fDisableHistoLoop(kFALSE),
fLegacyCentrality(kFALSE),
fPool(0x0),
fMaxPoolSize(0),
fMix(kFALSE)
{
/// Constructor with a predefined list of triggers to consider
/// Note that we take ownership of cutRegister
///
// fBranchNames = "AOD:header,tracks,vertices,tracklets,AliAODTZERO,AliAODVZERO";
// Create the pool
fPool = new TObjArray(2);
fPool->SetOwner(kTRUE);
DefineOutput(1,AliMergeableCollection::Class());
DefineOutput(2,AliCounterCollection::Class());
DefineOutput(3,AliAnalysisMuMuBinning::Class());
}
//_____________________________________________________________________________
AliAnalysisTaskMuMu::~AliAnalysisTaskMuMu()
{
/// dtor
if (fHistogramCollection && ! AliAnalysisManager::GetAnalysisManager()->IsProofMode())
{
delete fHistogramCollection;
}
if (fEventCounters && ! AliAnalysisManager::GetAnalysisManager()->IsProofMode())
{
delete fEventCounters;
}
if (fBinning && ! AliAnalysisManager::GetAnalysisManager()->IsProofMode())
{
delete fBinning;
}
if (fPool) delete fPool;
delete fHistogramToDisable;
delete fCutRegistry;
delete fSubAnalysisVector;
}
//_____________________________________________________________________________
void AliAnalysisTaskMuMu::AdoptSubAnalysis(AliAnalysisMuMuBase* analysis)
{
if (!fSubAnalysisVector)
{
fSubAnalysisVector = new TObjArray;
fSubAnalysisVector->SetOwner(kTRUE);
}
if ( !fSubAnalysisVector->FindObject(analysis) )
{
fSubAnalysisVector->Add(analysis);
}
}
//_____________________________________________________________________________
AliAnalysisMuMuCutRegistry* AliAnalysisTaskMuMu::CutRegistry() const
{
/// Return (and create if not yet there) our cut registry
if (!fCutRegistry)
{
fCutRegistry = new AliAnalysisMuMuCutRegistry;
}
return fCutRegistry;
}
//_____________________________________________________________________________
AliAnalysisMuMuCutRegistry* AliAnalysisTaskMuMu::CutRegistryMix() const
{
/// Return (and create if not yet there) our cut registry
if (!fCutRegistryMix)
{
fCutRegistryMix = new AliAnalysisMuMuCutRegistry;
}
return fCutRegistryMix;
}
//_____________________________________________________________________________
const char*
AliAnalysisTaskMuMu::DefaultCentralityName() const
{
/// Get default centrality name
if ( !fBeamYear.Contains("pp") ) return "CENTX";
else return "PP";
}
//_____________________________________________________________________________
void AliAnalysisTaskMuMu::DisableHistograms(const char* pattern)
{
/// Disable the histogramming of all the histograms matching the pattern
TIter next(fSubAnalysisVector);
AliAnalysisMuMuBase* a;
while ( ( a = static_cast<AliAnalysisMuMuBase*>(next()) ) )
{
a->DisableHistograms(pattern);
}
}
//_____________________________________________________________________________
AliVEvent*
AliAnalysisTaskMuMu::Event() const
{
// some const-dirty-dancing
return const_cast<AliAnalysisTaskMuMu*>(this)->InputEvent();
}
//_____________________________________________________________________________
void AliAnalysisTaskMuMu::SetCountInBins( const char* binWhat, const char* binQuantity, const char* binFlavor, Bool_t disableHistoLoop )
{
/// fCountInBins serve to add a rubric for bins in the Event counter collection
/// Bin to count, can be set like in AliAnalysisMuMuBinning class, and has to be the same as one of the binnings we give to the task through this class
/// Only one kind of binning can be used in the counters, since otherwise the bin integrated counts will not be correct (events counted several times)
/// ONLY FOR EVENT PROPERTIES !
///
/// FIXME: make a new protection
if ( !fCountInBins) {
fCountInBins = kTRUE;
fbinWhat = binWhat;
fbinQuantity = binQuantity;
fbinFlavor = binFlavor;
fDisableHistoLoop = disableHistoLoop;
}
else AliFatal("Can't be called twice");
}
//_____________________________________________________________________________
void AliAnalysisTaskMuMu::SetPoolSize (Int_t size)
{
/// Create pool and set pool size.
fMix = kTRUE;
fMaxPoolSize = size;
}
//_____________________________________________________________________________
float AliAnalysisTaskMuMu::CentralityFromCentrality(const char* estimator) const
{
/// Estimate Centrality from old centrality framework
AliCentrality* centrality = Event()->GetCentrality();
if ( centrality ) return centrality->GetCentralityPercentile(estimator);
else {
AliWarning("Did not find Centrality !");
return -9999.0;
}
}
//_____________________________________________________________________________
float AliAnalysisTaskMuMu::CentralityFromMultSelection(const char* estimator) const
{
/// Estimate Centrality from new centrality framework
AliMultSelection* multSelection = static_cast<AliMultSelection*>(Event()->FindListObject("MultSelection"));
if ( multSelection ) return multSelection->GetMultiplicityPercentile(estimator);
else {
AliWarning("Did not find MultSelection !");
return -9999.0;
}
}
//_____________________________________________________________________________
void AliAnalysisTaskMuMu::CreateCentralityPools( const char* poolName ) const
{
/// Create pool according to binnging
AliInfo( "Creating pools" );
TObjArray* centralities = fBinning->CreateBinObjArray("centrality");
if( !centralities ) return;
Int_t PoolSize = centralities->GetEntries();
TObjArray* list = new TObjArray(PoolSize);
list->SetOwner(kTRUE);
list->SetName(poolName);
fPool->Add( list );
for( Int_t iPool = 0; iPool < PoolSize; ++iPool ){
TList* listbis = new TList();
listbis->SetOwner(kTRUE);
static_cast<TObjArray*>(fPool->FindObject(poolName))->Add( listbis );
}
}
//_____________________________________________________________________________
void AliAnalysisTaskMuMu::Fill(const char* eventSelection, const char* triggerClassName)
{
/// Fill one set of histograms (only called for events which pass the eventSelection cut) for a given trigger/event .
TString seventSelection(eventSelection);
seventSelection.ToLower();
// Fill counter collections (only for UserExec() )
FillCounters(seventSelection.Data(), triggerClassName, "ALL", fCurrentRunNumber);
TObjArray* centralities = fBinning->CreateBinObjArray("centrality");
TIter next(centralities);
AliAnalysisMuMuBinning::Range* r;
next.Reset();
while ( ( r = static_cast<AliAnalysisMuMuBinning::Range*>(next()) ) ){
Float_t fcent = -42.0;
TString estimator = r->Quantity();
if(estimator.Contains("V0MPLUS05")) estimator ="V0Mplus05";
if(estimator.Contains("V0MMINUS05")) estimator ="V0Mminus05";
Bool_t isPP(kFALSE);
// select centrality
if ( estimator.CompareTo("pp",TString::kIgnoreCase) == 0 ) isPP = kTRUE;
else {
if (fLegacyCentrality)fcent = CentralityFromCentrality(estimator.Data());
else fcent = CentralityFromMultSelection(estimator.Data());
}
// Fill histo
if ( isPP || r->IsInRange(fcent) ){
if ( !isPP && !r->IsInRange(fcent) ) continue;
FillHistos(eventSelection,triggerClassName,r->AsString(),fcent);
// FIXME: this filling of global centrality histo is misplaced somehow...
TH1* hcent = fHistogramCollection->Histo(Form("/%s/%s/V0M/Centrality",eventSelection,triggerClassName));
if (hcent) hcent->Fill(fcent);
}
}
delete centralities;
}
//_____________________________________________________________________________
void AliAnalysisTaskMuMu::FillPools(const char* eventSelection, const char* triggerClassName)
{
/// Fill the different centrality with event pools for each combination of eventSelection/triggerClassName
TString seventSelection(eventSelection);
seventSelection.ToLower();
TObjArray* centralities = fBinning->CreateBinObjArray("centrality");
TIter next(centralities);
AliAnalysisMuMuBinning::Range* r;
next.Reset();
while ( ( r = static_cast<AliAnalysisMuMuBinning::Range*>(next()) ) ){
Float_t fcent = -42.0;
TString estimator = r->Quantity();
Bool_t isPP(kFALSE);
// select centrality
if ( estimator.CompareTo("pp",TString::kIgnoreCase) == 0 ) isPP = kTRUE;
else {
if (fLegacyCentrality)fcent = CentralityFromCentrality(estimator.Data());
else fcent = CentralityFromMultSelection(estimator.Data());
}
// Fill histo
if ( isPP || r->IsInRange(fcent) ){
if ( !isPP && !r->IsInRange(fcent) ) continue;
FillPoolsWithTracks(eventSelection,triggerClassName,fcent);
}
}
delete centralities;
}
//_____________________________________________________________________________
void AliAnalysisTaskMuMu::FillHistos(const char* eventSelection,
const char* triggerClassName,
const char* centrality,
Float_t cent)
{
/// Fill histograms
// Fill counter collections (only for UserExec() )
FillCounters( eventSelection, triggerClassName, centrality, fCurrentRunNumber);
// timer
AliCodeTimerAuto(Form("/%s/%s/%s",eventSelection,triggerClassName,centrality),0);
// prepare iterators
TIter nextAnalysis(fSubAnalysisVector);
AliAnalysisMuMuBase* analysis;
TIter nextTrackCut(fCutRegistry->GetCutCombinations(AliAnalysisMuMuCutElement::kTrack));
TIter nextPairCut(fCutRegistry->GetCutCombinations(AliAnalysisMuMuCutElement::kTrackPair));
// Get number of tracks
Int_t nTracks = AliAnalysisMuonUtility::GetNTracks(Event());
// The main part, loop over subanalysis and fill histo
if ( !IsHistogrammingDisabled() && !fDisableHistoLoop ){
while ( ( analysis = static_cast<AliAnalysisMuMuBase*>(nextAnalysis()) ) )
{
// Create proxy for the Histogram collections
analysis->DefineHistogramCollection(eventSelection,triggerClassName,centrality,fMix);
if ( MCEvent() != 0x0 )
{
AliCodeTimerAuto(Form("%s (FillHistosForMCEvent)",analysis->ClassName()),1);
if(!fMix) analysis->FillHistosForMCEvent(eventSelection,triggerClassName,centrality);// Implemented in AliAnalysisMuMuNch and AliAnalysisMuMuMinv at the moment
}
AliCodeTimerAuto(Form("%s (FillHistosForEvent)",analysis->ClassName()),1);
analysis->FillHistosForEvent(eventSelection,triggerClassName,centrality); // Implemented in AliAnalysisMuMuNch at the moment
// --- Loop on all event tracks ---
for (Int_t i = 0; i < nTracks; ++i){
// Get track
AliVParticle* tracki = AliAnalysisMuonUtility::GetTrack(i,Event());
if (!AliAnalysisMuonUtility::IsMuonTrack(tracki) ) continue;
nextTrackCut.Reset();
AliAnalysisMuMuCutCombination* trackCut;
// Loop on all track selections and fill histos for track that pass it
while ( ( trackCut = static_cast<AliAnalysisMuMuCutCombination*>(nextTrackCut()) ) )
{
if ( trackCut->Pass(*tracki) )
{
AliCodeTimerAuto(Form("%s (FillHistosForTrack)",analysis->ClassName()),2);
analysis->FillHistosForTrack(eventSelection,triggerClassName,centrality,trackCut->GetName(),*tracki);
}
}
// --- loop on muon track pairs (no mix) ---
for (Int_t j = i+1; j < nTracks; ++j){
// Get track
AliVParticle * trackj = 0x0;
trackj = AliAnalysisMuonUtility::GetTrack(j,Event());
if (!AliAnalysisMuonUtility::IsMuonTrack(trackj) ) continue;
nextPairCut.Reset();
AliAnalysisMuMuCutCombination* pairCut;
// Fill pair histo
while ( ( pairCut = static_cast<AliAnalysisMuMuCutCombination*>(nextPairCut()) ) )
{
// Weither or not the pairs pass the tests
Bool_t testi = (pairCut->IsTrackCutter()) ? pairCut->Pass(*tracki) : kTRUE;
Bool_t testj = (pairCut->IsTrackCutter()) ? pairCut->Pass(*trackj) : kTRUE;
Bool_t testij = pairCut->Pass(*tracki,*trackj);
if ( ( testi && testj ) && testij )
{
AliCodeTimerAuto(Form("%s (FillHistosForPair)",analysis->ClassName()),3);
analysis->FillHistosForPair(eventSelection,triggerClassName,centrality,pairCut->GetName(),*tracki,*trackj,kFALSE);
}
}
}
// --- mix part ---
if(!fMix) continue;
TList* currentPool =0x0;
nextPairCut.Reset();
nextTrackCut.Reset();
AliAnalysisMuMuCutCombination* pairCut;
// Loop over pair cut
while ( ( pairCut = static_cast<AliAnalysisMuMuCutCombination*>(nextPairCut()) ) )
{
// Loop over single track cut from mixing configuration
while ( ( trackCut = static_cast<AliAnalysisMuMuCutCombination*>(nextTrackCut()) ) )
{
currentPool = FindPool(cent,Form("%s/%s/%s",eventSelection,triggerClassName,trackCut->GetName()));
if(!currentPool) continue;
for (Int_t iTrack2 = 0; iTrack2 < currentPool->GetSize(); ++iTrack2)
{
// Get track
AliVParticle * trackj = 0x0;
trackj = static_cast<AliVParticle*>(currentPool->At(iTrack2));
// Weither or not the pairs pass the tests
Bool_t testi = trackCut->Pass(*tracki);
Bool_t testj = trackCut->Pass(*trackj);
Bool_t testij = pairCut->Pass(*tracki,*trackj);
if ( testij && testi && testj ) analysis->FillHistosForPair(eventSelection,triggerClassName,centrality,pairCut->GetName(),*tracki,*trackj,fMix);
}
}
}
}
}
}
}
//_____________________________________________________________________________
void AliAnalysisTaskMuMu::FillPoolsWithTracks(const char* eventSelection,
const char* triggerClassName,
Float_t cent)
{
/// Fill Pools with event track
Int_t nTrackRemoved =0;
TIter nextTrackCut(fCutRegistryMix->GetCutCombinations(AliAnalysisMuMuCutElement::kTrack));
AliAnalysisMuMuCutCombination* trackCut;
// Get number of tracks
Int_t nTracks = AliAnalysisMuonUtility::GetNTracks(Event());
TList* currentPool(0x0);
for (Int_t j = 0; j < nTracks; ++j){
// Get track
AliVParticle * trackj = 0x0;
trackj = AliAnalysisMuonUtility::GetTrack(j,Event());
if( !AliAnalysisMuonUtility::IsMuonTrack(trackj) ) continue;
// Fill pools
nextTrackCut.Reset();
while ( ( trackCut = static_cast<AliAnalysisMuMuCutCombination*>(nextTrackCut()) ) ){
if(!trackCut->Pass(*trackj)) continue;
TString poolName = Form("%s/%s/%s",eventSelection,triggerClassName,trackCut->GetName());
if( !FindPool( cent,poolName.Data() ) ) CreateCentralityPools(poolName.Data());
currentPool = FindPool(cent,poolName.Data());
currentPool->AddFirst( trackj->Clone() );
// truncate pool if necessary
while( currentPool->GetSize() > fMaxPoolSize )
{
delete currentPool->Last();
currentPool->RemoveLast();
++nTrackRemoved;
}
}
}
}
//_____________________________________________________________________________
void AliAnalysisTaskMuMu::FillCounters(const char* eventSelection, const char* triggerClassName, const char* centrality, Int_t currentRun)
{
/// Fill the AliCounterCollection for a given event/trigger/centrality/run combination
/// The binning has to be an already existing event property or one (like i.e. <dNch/dEta>) which we can compute in the SetEvent() method and attach it to the event list
/// We can generalize this method (if needed), now it is only valid for multiplicity
AliCodeTimerAuto("",0);
if( fCountInBins ){
TParameter<Double_t>* p(0x0);
TObjArray* bin = fBinning->CreateBinObjArray(fbinWhat.Data(),fbinQuantity.Data(),fbinFlavor.Data());
TString sfbinQuantity(fbinQuantity);
TString parToFind("");
if ( !sfbinQuantity.CompareTo("ntrcorr") ) parToFind = "NtrCorr";
else if ( !sfbinQuantity.CompareTo("ntr") ) parToFind = "Ntr";
else if ( !sfbinQuantity.CompareTo("nch") ) parToFind = "Nch";
else if ( !sfbinQuantity.CompareTo("v0a") ) parToFind = "V0ARaw";
else if ( !sfbinQuantity.CompareTo("v0acorr") ) parToFind = "V0ACorr";
else if ( !sfbinQuantity.CompareTo("v0ccorr") ) parToFind = "V0CCorr";
else if ( !sfbinQuantity.CompareTo("v0mcorr") ) parToFind = "V0MCorr";
else AliError(Form("%s bin quantity not found in event",sfbinQuantity.Data())); //FIXME: Not all the possible binnings are implemented here
if ( !bin ) AliError(Form("%s,%s,%s binning does not exist",fbinWhat.Data(),fbinQuantity.Data(),fbinFlavor.Data()));
else{
TList* list = static_cast<TList*>(Event()->FindListObject("NCH"));
if (list){
Int_t i(-1);
Bool_t parFound(kFALSE);
while ( i < list->GetEntries() - 1 && !parFound ){
i++;
while ( list->At(i)->IsA() != TParameter<Double_t>::Class() && i < list->GetEntries() - 1 ) i++;// In case there is a diferent object, just to skip it
p = static_cast<TParameter<Double_t>*>(list->At(i));
if ( TString(p->GetName()).Contains(parToFind.Data()) )
parFound = kTRUE;
}
} else AliFatal("No multiplicity info on Event");
TIter next(bin);
AliAnalysisMuMuBinning::Range* r;
while ( ( r = static_cast<AliAnalysisMuMuBinning::Range*>(next()) ) ){
if ( r->IsInRange(p->GetVal()) )
fEventCounters->Count(Form("event:%s/trigger:%s/centrality:%s/run:%d/bin:%s",eventSelection, triggerClassName,centrality, currentRun,r->AsString().Data()));
}
delete bin;
}
} else fEventCounters->Count(Form("event:%s/trigger:%s/centrality:%s/run:%d", eventSelection, triggerClassName, centrality, currentRun));
}
//_____________________________________________________________________________
void AliAnalysisTaskMuMu::FinishTaskOutput()
{
/// prune empty histograms BEFORE mergin, in order to save some bytes...
if ( fHistogramCollection ) fHistogramCollection->PruneEmptyObjects();
}
//________________________________________________________________________
TList* AliAnalysisTaskMuMu::FindPool( Float_t cent, const char* poolName ) const
{
// define number of pools and boundary
// in principle one could also use vertex range
if(!fPool->FindObject(poolName)) return 0x0;
TObjArray* centralities = fBinning->CreateBinObjArray("centrality");
TIter next(centralities);
AliAnalysisMuMuBinning::Range* r;
next.Reset();
TList* o;
Int_t iPool =0;
while ( ( r = static_cast<AliAnalysisMuMuBinning::Range*>(next()) ) )
{
if( r->IsInRange(cent) && fPool->FindObject( poolName ) ){
o = static_cast<TList*>( fPool->FindObject( poolName ) );
return dynamic_cast<TList*>( o->At( iPool ) );
}
else ++iPool;
}
return 0x0;
}
//_____________________________________________________________________________
void AliAnalysisTaskMuMu::GetSelectedTrigClassesInEvent(const AliVEvent* event, TObjArray& array)
{
/// Fills the array with a list of TObjString of the trigger classes that the various
/// cuts accept for this event
array.Clear();
if (!event){
AliError("Will get a hard time selecting trigger classes with an empty event...");
return;
}
TString firedTriggerClasses = event->GetFiredTriggerClasses();
UInt_t l0 = event->GetHeader()->GetL0TriggerInputs();
UInt_t l1 = event->GetHeader()->GetL1TriggerInputs();
UInt_t l2 = event->GetHeader()->GetL2TriggerInputs();
std::set<std::string> tmpArray;
TIter nextCutCombination(CutRegistry()->GetCutCombinations(AliAnalysisMuMuCutElement::kTriggerClass));
AliAnalysisMuMuCutCombination* cutCombination;
while ( ( cutCombination = static_cast<AliAnalysisMuMuCutCombination*>(nextCutCombination()) ) ){
TString acceptedTriggerClasses;
if ( cutCombination->Pass(firedTriggerClasses,acceptedTriggerClasses,l0,l1,l2) ){
TObjArray* split = acceptedTriggerClasses.Tokenize(" ");
TIter next(split);
TObjString* str;
while ( ( str = static_cast<TObjString*>(next()) ) ) tmpArray.insert(str->String().Data());
delete split;
}
}
std::set<std::string>::const_iterator it;
for ( it = tmpArray.begin(); it != tmpArray.end(); ++it ) array.Add(new TObjString(it->c_str()));
}
//_____________________________________________________________________________
void AliAnalysisTaskMuMu::GetSelectedTrigClassesInEventMix(const AliVEvent* event, TObjArray& array)
{
/// Fills the array with a list of TObjString of the trigger classes that the various
/// cuts accept for this event
array.Clear();
if (!event){
AliError("Will get a hard time selecting trigger classes with an empty event...");
return;
}
TString firedTriggerClasses = event->GetFiredTriggerClasses();
UInt_t l0 = event->GetHeader()->GetL0TriggerInputs();
UInt_t l1 = event->GetHeader()->GetL1TriggerInputs();
UInt_t l2 = event->GetHeader()->GetL2TriggerInputs();
std::set<std::string> tmpArray;
TIter nextCutCombination(CutRegistryMix()->GetCutCombinations(AliAnalysisMuMuCutElement::kTriggerClass));
AliAnalysisMuMuCutCombination* cutCombination;
while ( ( cutCombination = static_cast<AliAnalysisMuMuCutCombination*>(nextCutCombination()) ) ){
TString acceptedTriggerClasses;
if ( cutCombination->Pass(firedTriggerClasses,acceptedTriggerClasses,l0,l1,l2) ){
TObjArray* split = acceptedTriggerClasses.Tokenize(" ");
TIter next(split);
TObjString* str;
while ( ( str = static_cast<TObjString*>(next()) ) ) tmpArray.insert(str->String().Data());
delete split;
}
}
std::set<std::string>::const_iterator it;
for ( it = tmpArray.begin(); it != tmpArray.end(); ++it ) array.Add(new TObjString(it->c_str()));
}
//_____________________________________________________________________________
Bool_t AliAnalysisTaskMuMu::IsHistogramDisabled(const char* hname) const
{
/// Whether or not a given histogram (identified by its name)
/// is disabled or not
TIter next(fSubAnalysisVector);
AliAnalysisMuMuBase* analysis;
while ( ( analysis = static_cast<AliAnalysisMuMuBase*>(next()) ) ){
if ( analysis->IsHistogramDisabled(hname) ) return kTRUE;
}
return kFALSE;
}
//_____________________________________________________________________________
Bool_t AliAnalysisTaskMuMu::IsHistogrammingDisabled() const
{
/// Whether or not *all* histograms are disabled
Bool_t disabled(kTRUE);
TIter next(fSubAnalysisVector);
AliAnalysisMuMuBase* analysis;
while ( ( analysis = static_cast<AliAnalysisMuMuBase*>(next()) ) ) disabled = disabled && analysis->IsHistogrammingDisabled();
return disabled;
}
//_____________________________________________________________________________
Bool_t AliAnalysisTaskMuMu::IsPP() const
{
/// whether we're dealing with proton proton collisions. Affect the centrality selection.
return fBeamYear.Contains("pp");
}
//_____________________________________________________________________________
void AliAnalysisTaskMuMu::NotifyRun()
{
/// Called at each change of run
AliDebug(1,Form("Run %09d File %s",fCurrentRunNumber,CurrentFileName()));
TIter next(fSubAnalysisVector);
AliAnalysisMuMuBase* analysis;
while ( ( analysis = static_cast<AliAnalysisMuMuBase*>(next()) ) ) analysis->SetRun(fInputHandler);
}
//_____________________________________________________________________________
void
AliAnalysisTaskMuMu::Print(Option_t* opt) const
{
/// Print the definition of this analysis
cout << ClassName() << " - " << GetName() << " - " << fBeamYear.Data() << endl;
TIter next(fSubAnalysisVector);
AliAnalysisMuMuBase* analysis;
while ( ( analysis = static_cast<AliAnalysisMuMuBase*>(next()) ) )analysis->Print(opt);
fCutRegistry->Print("ALL");
if ( fBinning ){
cout << "Binning" << endl;
fBinning->Print();
}
}
//_____________________________________________________________________________
void AliAnalysisTaskMuMu::PrintPools() const
{
/// Print the definition of this analysis
if(!fPool || fPool->IsEmpty())return;
printf("\n --- Centrality pools --- \n\n");
printf(" -> Number of pools : %d \n",fPool->GetEntries());
printf(" -------------------------- \n");
for (int i = 0; i < fPool->GetEntries(); ++i){
TObjArray* pool = static_cast<TObjArray*>(fPool->At(i));
printf(" ---> pool n°%i \n\n",i);
printf(" - name : %s\n",fPool->At(i)->GetName() );
for (int j = 0; j < pool->GetEntries(); ++j){
TList* list = static_cast<TList*>(pool->At(j));
printf(" - number of muons stored in centrality bins n°%d : %d\n",j, list->GetEntries() );
}
printf("\n");
}
}
//_____________________________________________________________________________
void
AliAnalysisTaskMuMu::Terminate(Option_t *)
{
/// Called once at the end of the query
/// Just a simple printout of the stat we analyse and how many histograms
/// we got
fHistogramCollection = dynamic_cast<AliMergeableCollection*>(GetOutputData(1));
TIter nextAnalysis(fSubAnalysisVector);
AliAnalysisMuMuBase* analysis;
while ( ( analysis = static_cast<AliAnalysisMuMuBase*>(nextAnalysis()) ) ){
analysis->SetHistogramCollection(fHistogramCollection);
analysis->Terminate();
}
if (!fHistogramCollection) AliError("Could not find back histogram collection in output...");
else{
// Removes empty objects
fHistogramCollection->PruneEmptyObjects();
UInt_t size2 = fHistogramCollection->EstimateSize();
TIter nextHistogram(fHistogramCollection->CreateIterator());
TObject* object;
while ( ( object = nextHistogram() ) ){
if ( object->IsA()->InheritsFrom(TH1::Class()) ){
TH1* h = static_cast<TH1*>(object);
if ( h->GetXaxis()->GetLabels() ) h->LabelsDeflate("X");
}
}
AliInfo(Form("size after prune histograms = %5.1f MB",size2/1024.0/1024.0));
fHistogramCollection->Print("-");
}
fEventCounters = dynamic_cast<AliCounterCollection*>(GetOutputData(2));
if (!fEventCounters) AliError("Could not find back counters in output...");
else fEventCounters->Print("trigger/event","centrality:all");
// post param container(s)
PostData(3,fBinning);
}
//_____________________________________________________________________________
AliAnalysisMuMuBinning* AliAnalysisTaskMuMu::Binning() const
{
/// Return our binning (making a default one if not already created
if ( fBinning ) return fBinning;
fBinning = new AliAnalysisMuMuBinning("BIN");
return fBinning;
}
//_____________________________________________________________________________
void AliAnalysisTaskMuMu::UserExec(Option_t* /*opt*/)
{
/// Executed at each event
// static Int_t n(0);
// AliInfo(Form("EVENT %10d Event()=%p MCEvent()=%p",n,Event(),MCEvent()));
// ++n;
AliCodeTimerAuto("",0);
Binning(); // insure we have a binning...
TIter nextAnalysis(fSubAnalysisVector);
AliAnalysisMuMuBase* analysis;
// Loop over each subanalysis
while ( ( analysis = static_cast<AliAnalysisMuMuBase*>(nextAnalysis()) ) ) {
// Set the MC flag for all analysis (prior to call anything from them
// (e.g. any trigger class selection that might behave differently for
// MC and real trigger classes)
if ( MCEvent() ) analysis->SetMC();
analysis->SetEvent(Event(),MCEvent()); // Set the new event properties derived in the analysis
}
TString firedTriggerClasses(Event()->GetFiredTriggerClasses());
TIter nextEventCutCombination(CutRegistry()->GetCutCombinations(AliAnalysisMuMuCutElement::kEvent));
AliAnalysisMuMuCutCombination* cutCombination;
TIter nextEventCutCombinationMix(CutRegistryMix()->GetCutCombinations(AliAnalysisMuMuCutElement::kEvent));
AliAnalysisMuMuCutCombination* cutCombinationMix;
// loop over cut combination on event level. Fill counters
while ( ( cutCombination = static_cast<AliAnalysisMuMuCutCombination*>(nextEventCutCombination()))){
if ( cutCombination->Pass(*fInputHandler) )
{
// Fill counters
FillCounters(cutCombination->GetName(), "EVERYTHING", "ALL", fCurrentRunNumber);
// Default counter
if ( firedTriggerClasses == "" ) FillCounters(cutCombination->GetName(),"EMPTY","ALL",fCurrentRunNumber);
}
}
// loop over trigger selected list and cut combination on event level. Fill histos
TObjArray selectedTriggerClasses;
selectedTriggerClasses.SetOwner(kTRUE);
GetSelectedTrigClassesInEvent(Event(),selectedTriggerClasses);
TIter next(&selectedTriggerClasses);
TObjString* tname;
while ( ( tname = static_cast<TObjString*>(next()) ) ){
nextEventCutCombination.Reset();
while ( ( cutCombination = static_cast<AliAnalysisMuMuCutCombination*>(nextEventCutCombination())) ){
if ( cutCombination->Pass(*fInputHandler) ) Fill(cutCombination->GetName(),tname->String().Data());
}
}
if(fMix){
GetSelectedTrigClassesInEventMix(Event(),selectedTriggerClasses);
TIter nextmix(&selectedTriggerClasses);
nextmix.Reset();
while ( ( tname = static_cast<TObjString*>(nextmix()) ) ){
nextEventCutCombinationMix.Reset();
while ( ( cutCombinationMix = static_cast<AliAnalysisMuMuCutCombination*>(nextEventCutCombinationMix())) ){
if ( cutCombinationMix->Pass(*fInputHandler) ) FillPools(cutCombinationMix->GetName(),tname->String().Data());
}
}
}
// Post output data.
PostData(1, fHistogramCollection);
PostData(2, fEventCounters);
PostData(3, fBinning);
}
//_____________________________________________________________________________
void AliAnalysisTaskMuMu::UserCreateOutputObjects()
{
/// Create histograms
/// Called once
OpenFile(1);
AliDebug(1,Form("fCutRegistry=%p",fCutRegistry));
if ( fCutRegistry ) StdoutToAliDebug(1,fCutRegistry->Print());
fHistogramCollection = new AliMergeableCollection("OC");
fEventCounters = new AliCounterCollection("CC");
// initialize event counters
TString eventRubric;
TIter next(CutRegistry()->GetCutCombinations(AliAnalysisMuMuCutElement::kEvent));
AliAnalysisMuMuCutCombination* cutCombination;
while ( ( cutCombination = static_cast<AliAnalysisMuMuCutCombination*>(next())) ){
TString cutName = cutCombination->GetName();
if ( eventRubric.Length() > 0 ) eventRubric += "/";
eventRubric += cutName;
}
fEventCounters->AddRubric("event", eventRubric.Data());
fEventCounters->AddRubric("trigger", 100);
fEventCounters->AddRubric("centrality", 100);
fEventCounters->AddRubric("run", 1000000);
if ( fCountInBins ) fEventCounters->AddRubric("bin", 1000000);
// Initialize our subtasks, if any...
TIter nextAnalysis(fSubAnalysisVector);
AliAnalysisMuMuBase* analysis;
while ( ( analysis = static_cast<AliAnalysisMuMuBase*>(nextAnalysis()) ) ) analysis->Init(*fEventCounters,*fHistogramCollection,*fBinning,*fCutRegistry);
// finally end the counters initialization
fEventCounters->Init();
// Post output data.
PostData(1,fHistogramCollection);
PostData(2,fEventCounters);
PostData(3,fBinning);
}
| 34.096096 | 171 | 0.708766 | [
"object"
] |
1b467c3a89e43a9909d15aabe3e7e1a0e4ec99a2 | 1,801 | cpp | C++ | regression/esbmc-cpp/cpp/ch9_9/main.cpp | shmarovfedor/esbmc | 3226a3d68b009d44b9535a993ac0f25e1a1fbedd | [
"BSD-3-Clause"
] | 143 | 2015-06-22T12:30:01.000Z | 2022-03-21T08:41:17.000Z | regression/esbmc-cpp/cpp/ch9_9/main.cpp | shmarovfedor/esbmc | 3226a3d68b009d44b9535a993ac0f25e1a1fbedd | [
"BSD-3-Clause"
] | 542 | 2017-06-02T13:46:26.000Z | 2022-03-31T16:35:17.000Z | regression/esbmc-cpp/cpp/ch9_9/main.cpp | shmarovfedor/esbmc | 3226a3d68b009d44b9535a993ac0f25e1a1fbedd | [
"BSD-3-Clause"
] | 81 | 2015-10-21T22:21:59.000Z | 2022-03-24T14:07:55.000Z | // Fig. 9.6: pointtest.cpp
// Testing class Point.
#include <iostream>
#include <cassert>
using std::cout;
using std::endl;
#include "point.h" // Point class definition
int main()
{
Point point( 72, 115 ); // instantiate Point object
// display point coordinates
cout << "X coordinate is " << point.getX()
<< "\nY coordinate is " << point.getY();
point.setX( 10 ); // set x-coordinate
point.setY( 10 ); // set y-coordinate
// display new point value
cout << "\n\nThe new location of point is ";
point.print();
cout << endl;
assert(point.getX() == 10);
assert(point.getY() == 10);
assert(point.getX() == 11);
return 0; // indicates successful termination
} // end main
/**************************************************************************
* (C) Copyright 1992-2003 by Deitel & Associates, Inc. and Prentice *
* Hall. All Rights Reserved. *
* *
* DISCLAIMER: The authors and publisher of this book have used their *
* best efforts in preparing the book. These efforts include the *
* development, research, and testing of the theories and programs *
* to determine their effectiveness. The authors and publisher make *
* no warranty of any kind, expressed or implied, with regard to these *
* programs or to the documentation contained in these books. The authors *
* and publisher shall not be liable in any event for incidental or *
* consequential damages in connection with, or arising out of, the *
* furnishing, performance, or use of these programs. *
*************************************************************************/
| 36.755102 | 75 | 0.55136 | [
"object"
] |
1b497fba131a0ca7968765510e8146d970cd9c85 | 9,371 | cpp | C++ | Compiler/AST/ASTBoxing_CG.cpp | zored/emojicode | 512e71357f8c4d6f56fa4050e1d959749e9b29a2 | [
"Artistic-2.0"
] | null | null | null | Compiler/AST/ASTBoxing_CG.cpp | zored/emojicode | 512e71357f8c4d6f56fa4050e1d959749e9b29a2 | [
"Artistic-2.0"
] | null | null | null | Compiler/AST/ASTBoxing_CG.cpp | zored/emojicode | 512e71357f8c4d6f56fa4050e1d959749e9b29a2 | [
"Artistic-2.0"
] | null | null | null | //
// ASTBoxing_CG.cpp
// Emojicode
//
// Created by Theo Weidmann on 03/09/2017.
// Copyright © 2017 Theo Weidmann. All rights reserved.
//
#include "ASTBoxing.hpp"
#include "ASTInitialization.hpp"
#include "Types/TypeDefinition.hpp"
#include "Generation/FunctionCodeGenerator.hpp"
#include "Generation/ProtocolsTableGenerator.hpp"
namespace EmojicodeCompiler {
Value* ASTUpcast::generate(FunctionCodeGenerator *fg) const {
return fg->builder().CreateBitCast(expr_->generate(fg), fg->typeHelper().llvmTypeFor(toType_));
}
ASTBoxing::ASTBoxing(std::shared_ptr<ASTExpr> expr, const SourcePosition &p, const Type &exprType)
: ASTUnaryMFForwarding(std::move(expr), p) {
setExpressionType(exprType);
if (auto init = std::dynamic_pointer_cast<ASTInitialization>(expr_)) {
init_ = init->initType() == ASTInitialization::InitType::ValueType;
}
}
Value* ASTRebox::generate(FunctionCodeGenerator *fg) const {
if (expressionType().boxedFor().type() == TypeType::Something) {
auto box = expr_->generate(fg);
auto pct = fg->typeHelper().protocolConformance();
auto pc = fg->builder().CreateBitCast(fg->builder().CreateExtractValue(box, 0), pct->getPointerTo());
auto bi = fg->builder().CreateLoad(fg->builder().CreateConstInBoundsGEP2_32(pct, pc, 0, 2));
return fg->builder().CreateInsertValue(box, bi, 0);
}
auto box = getAllocaTheBox(fg);
auto protocolId = fg->generator()->protocolIdentifierFor(expressionType().boxedFor());
auto conformance = fg->buildFindProtocolConformance(box, fg->builder().CreateLoad(fg->buildGetBoxInfoPtr(box)),
protocolId);
auto confPtrTy = fg->typeHelper().protocolConformance()->getPointerTo();
auto infoPtr = fg->buildGetBoxInfoPtr(box);
fg->builder().CreateStore(conformance, fg->builder().CreateBitCast(infoPtr, confPtrTy->getPointerTo()));
return fg->builder().CreateLoad(box);
}
Value* ASTBoxing::getBoxValuePtr(Value *box, FunctionCodeGenerator *fg) const {
Type type = expr_->expressionType().unboxed().unoptionalized();
return fg->buildGetBoxValuePtr(box, type);
}
Value* ASTBoxing::getSimpleOptional(Value *value, FunctionCodeGenerator *fg) const {
return fg->buildSimpleOptionalWithValue(value, expressionType());
}
Value* ASTBoxing::getSimpleError(llvm::Value *value, EmojicodeCompiler::FunctionCodeGenerator *fg) const {
auto undef = llvm::UndefValue::get(fg->typeHelper().llvmTypeFor(expressionType()));
auto error = fg->builder().CreateInsertValue(undef, fg->buildGetErrorNoError(), 0);
return fg->builder().CreateInsertValue(error, value, 1);
}
Value* ASTBoxing::getSimpleOptionalWithoutValue(FunctionCodeGenerator *fg) const {
return fg->buildSimpleOptionalWithoutValue(expressionType());
}
Value* ASTBoxing::getAllocaTheBox(FunctionCodeGenerator *fg) const {
auto box = fg->createEntryAlloca(fg->typeHelper().box());
fg->builder().CreateStore(expr_->generate(fg), box);
return box;
}
Value* ASTBoxing::getGetValueFromBox(Value *box, FunctionCodeGenerator *fg) const {
auto containedType = expr_->expressionType().unboxed().unoptionalized();
if (fg->typeHelper().isRemote(containedType)) {
auto type = fg->typeHelper().llvmTypeFor(containedType);
auto ptrPtr = fg->buildGetBoxValuePtr(box, type->getPointerTo()->getPointerTo());
return fg->builder().CreateLoad(fg->builder().CreateLoad(ptrPtr));
}
return fg->builder().CreateLoad(getBoxValuePtr(box, fg));
}
void ASTBoxing::valueTypeInit(FunctionCodeGenerator *fg, Value *destination) const {
auto init = std::dynamic_pointer_cast<ASTInitialization>(expr_);
init->setDestination(destination);
expr_->generate(fg);
}
Value* ASTBoxToSimple::generate(FunctionCodeGenerator *fg) const {
return getGetValueFromBox(getAllocaTheBox(fg), fg);
}
Value* ASTBoxToSimpleOptional::generate(FunctionCodeGenerator *fg) const {
auto box = getAllocaTheBox(fg);
auto hasNoValue = fg->buildHasNoValueBoxPtr(box);
return fg->createIfElsePhi(hasNoValue, [this, fg]() {
return getSimpleOptionalWithoutValue(fg);
}, [this, box, fg]() {
return getSimpleOptional(getGetValueFromBox(box, fg), fg);
});
}
Value* ASTSimpleToSimpleOptional::generate(FunctionCodeGenerator *fg) const {
return getSimpleOptional(expr_->generate(fg), fg);
}
Value* ASTSimpleToBox::generate(FunctionCodeGenerator *fg) const {
auto box = fg->createEntryAlloca(fg->typeHelper().box());
if (isValueTypeInit()) {
setBoxInfo(box, fg);
valueTypeInit(fg, buildStoreAddress(box, fg));
}
else {
getPutValueIntoBox(box, expr_->generate(fg), fg);
}
return fg->builder().CreateLoad(box);
}
Value* ASTSimpleOptionalToBox::generate(FunctionCodeGenerator *fg) const {
auto value = expr_->generate(fg);
auto box = fg->createEntryAlloca(fg->typeHelper().box());
auto hasNoValue = fg->buildOptionalHasNoValue(value, expr_->expressionType());
fg->createIfElse(hasNoValue, [fg, box]() {
fg->buildMakeNoValue(box);
}, [this, value, fg, box]() {
getPutValueIntoBox(box, fg->buildGetOptionalValue(value, expr_->expressionType()), fg);
});
return fg->builder().CreateLoad(box);
}
Value* ASTSimpleErrorToBox::generate(FunctionCodeGenerator *fg) const {
auto value = expr_->generate(fg);
auto box = fg->createEntryAlloca(fg->typeHelper().box());
auto hasNoValue = fg->buildGetIsError(value);
fg->createIfElse(hasNoValue, [this, fg, box, value]() {
fg->buildMakeNoValue(box);
auto ptr = fg->buildGetBoxValuePtr(box, expressionType().errorEnum());
fg->builder().CreateStore(fg->builder().CreateExtractValue(value, 0), ptr);
}, [this, value, fg, box]() {
getPutValueIntoBox(box, fg->builder().CreateExtractValue(value, 1), fg);
});
return fg->builder().CreateLoad(box);
}
Value* ASTSimpleToSimpleError::generate(FunctionCodeGenerator *fg) const {
return getSimpleError(expr_->generate(fg), fg);
}
Value* ASTBoxToSimpleError::generate(FunctionCodeGenerator *fg) const {
auto box = getAllocaTheBox(fg);
auto hasNoValue = fg->buildHasNoValueBoxPtr(box);
return fg->createIfElsePhi(hasNoValue, [this, box, fg]() {
auto errorEnumValue = fg->buildErrorEnumValueBoxPtr(box, expressionType().errorEnum());
return fg->buildSimpleErrorWithError(errorEnumValue, fg->typeHelper().llvmTypeFor(expressionType()));
}, [this, box, fg]() {
return getSimpleError(getGetValueFromBox(box, fg), fg);
});
}
Value* ASTToBox::buildStoreAddress(Value *box, FunctionCodeGenerator *fg) const {
auto containedType = expr_->expressionType().unboxed().unoptionalized();
if (fg->typeHelper().isRemote(containedType)) {
auto containedTypeLlvm = fg->typeHelper().llvmTypeFor(containedType);
auto mngType = fg->typeHelper().managable(containedTypeLlvm);
auto ctPtrPtr = containedTypeLlvm->getPointerTo()->getPointerTo();
auto boxPtr1 = fg->buildGetBoxValuePtr(box, ctPtrPtr);
auto boxPtr2 = fg->buildGetBoxValuePtrAfter(box, mngType->getPointerTo(), mngType->getPointerTo());
auto alloc = allocate(fg, mngType);
auto valuePtr = fg->managableGetValuePtr(alloc);
// The first element in the value area is a direct pointer to the struct.
fg->builder().CreateStore(valuePtr, boxPtr1);
// The second is a pointer to the allocated object for management.
fg->builder().CreateStore(alloc, boxPtr2);
return valuePtr;
}
return getBoxValuePtr(box, fg);
}
void ASTToBox::getPutValueIntoBox(Value *box, Value *value, FunctionCodeGenerator *fg) const {
setBoxInfo(box, fg);
fg->builder().CreateStore(value, buildStoreAddress(box, fg));
}
void ASTToBox::setBoxInfo(Value *box, FunctionCodeGenerator *fg) const {
auto boxedFor = expressionType().boxedFor();
if (boxedFor.type() == TypeType::Protocol || boxedFor.type() == TypeType::MultiProtocol) {
llvm::Value *table;
llvm::Type *type;
if (boxedFor.type() == TypeType::MultiProtocol) {
type = fg->typeHelper().multiprotocolConformance(boxedFor);
table = fg->generator()->protocolsTG().multiprotocol(boxedFor, expr_->expressionType());
}
else {
type = fg->typeHelper().protocolConformance();
table = expr_->expressionType().typeDefinition()->protocolTableFor(boxedFor);
}
auto ptr = fg->builder().CreateBitCast(fg->buildGetBoxInfoPtr(box), type->getPointerTo()->getPointerTo());
fg->builder().CreateStore(table, ptr);
return;
}
auto boxInfo = fg->boxInfoFor(expr_->expressionType().unoptionalized());
fg->builder().CreateStore(boxInfo, fg->buildGetBoxInfoPtr(box));
}
Value* ASTDereference::generate(FunctionCodeGenerator *fg) const {
return fg->builder().CreateLoad(expr_->generate(fg));
}
Value* ASTStoreTemporarily::generate(FunctionCodeGenerator *fg) const {
auto store = fg->createEntryAlloca(fg->typeHelper().llvmTypeFor(expr_->expressionType()), "temp");
if (isValueTypeInit()) {
valueTypeInit(fg, store);
}
else {
fg->builder().CreateStore(expr_->generate(fg), store);
}
return store;
}
} // namespace EmojicodeCompiler
| 41.464602 | 115 | 0.693843 | [
"object"
] |
1b4baf9d3eb89a47137d6b5e87b0b07c37d2e153 | 1,275 | cpp | C++ | LeviathanTest/TestFiles/ExtraAlgorithms.cpp | Higami69/Leviathan | 90f68f9f6e5506d6133bcefcf35c8e84f158483b | [
"BSL-1.0"
] | 16 | 2018-12-22T02:09:05.000Z | 2022-03-09T20:38:59.000Z | LeviathanTest/TestFiles/ExtraAlgorithms.cpp | Higami69/Leviathan | 90f68f9f6e5506d6133bcefcf35c8e84f158483b | [
"BSL-1.0"
] | 46 | 2018-04-02T11:06:01.000Z | 2019-12-14T11:16:04.000Z | LeviathanTest/TestFiles/ExtraAlgorithms.cpp | Higami69/Leviathan | 90f68f9f6e5506d6133bcefcf35c8e84f158483b | [
"BSL-1.0"
] | 14 | 2018-04-09T02:26:15.000Z | 2021-09-11T03:12:15.000Z |
//! \file Testing for functions in ExtraAlgorithms
#include "Common/ExtraAlgorithms.h"
#include "catch.hpp"
using namespace Leviathan;
using namespace std;
TEST_CASE("ExtraAlgorithms::FindRemovedElements", "[algorithm]"){
SECTION("Basic strings"){
std::vector<std::string> original {"first", "second", "more stuff", "final thing"};
std::vector<std::string> changed {"second", "final thing", "more"};
std::vector<std::string> added;
std::vector<std::string> removed;
FindRemovedElements(original, changed, added, removed);
REQUIRE(added.size() == 1);
REQUIRE(removed.size() == 2);
CHECK(added[0] == "more");
CHECK(removed[0] == "first");
CHECK(removed[1] == "more stuff");
}
SECTION("Numbers"){
std::vector<int32_t> original {2, 4, 6, 8, 11};
std::vector<int32_t> changed {2, 3, 5, 6, 8};
std::vector<int32_t> added;
std::vector<int32_t> removed;
FindRemovedElements(original, changed, added, removed);
REQUIRE(added.size() == 2);
REQUIRE(removed.size() == 2);
CHECK(added[0] == 3);
CHECK(added[1] == 5);
CHECK(removed[0] == 4);
CHECK(removed[1] == 11);
}
}
| 25 | 91 | 0.574118 | [
"vector"
] |
1b4e2b01a115f2ce87227e50ed1d9ba8f5e9f044 | 27,063 | cpp | C++ | Utils/Fake-Offline.cpp | mskd12/MP-SPDZ | 545ea8e60cf70dc7d2434a72df52cba3782a2eaa | [
"BSD-2-Clause"
] | null | null | null | Utils/Fake-Offline.cpp | mskd12/MP-SPDZ | 545ea8e60cf70dc7d2434a72df52cba3782a2eaa | [
"BSD-2-Clause"
] | null | null | null | Utils/Fake-Offline.cpp | mskd12/MP-SPDZ | 545ea8e60cf70dc7d2434a72df52cba3782a2eaa | [
"BSD-2-Clause"
] | null | null | null |
#include "Math/gf2n.h"
#include "Math/gfp.h"
#include "Protocols/Share.h"
#include "Math/Setup.h"
#include "Protocols/Spdz2kShare.h"
#include "Protocols/BrainShare.h"
#include "Protocols/MaliciousRep3Share.h"
#include "Protocols/PostSacriRepRingShare.h"
#include "Protocols/PostSacriRepFieldShare.h"
#include "Protocols/SemiShare.h"
#include "Protocols/MaliciousShamirShare.h"
#include "Protocols/SpdzWiseRingShare.h"
#include "Protocols/SpdzWiseShare.h"
#include "Protocols/Rep4Share2k.h"
#include "Protocols/fake-stuff.h"
#include "Exceptions/Exceptions.h"
#include "GC/MaliciousRepSecret.h"
#include "GC/SemiSecret.h"
#include "GC/TinySecret.h"
#include "GC/TinierSecret.h"
#include "GC/MaliciousCcdSecret.h"
#include "GC/Rep4Secret.h"
#include "Math/Setup.h"
#include "Processor/Data_Files.h"
#include "Tools/mkpath.h"
#include "Tools/ezOptionParser.h"
#include "Tools/benchmarking.h"
#include "Protocols/fake-stuff.hpp"
#include "Protocols/Shamir.hpp"
#include "Processor/Data_Files.hpp"
#include "Math/Z2k.hpp"
#include "Math/gfp.hpp"
#include "GC/Secret.hpp"
#include <sstream>
#include <fstream>
using namespace std;
string prep_data_prefix;
class FakeParams
{
int nplayers, default_num;
bool zero;
public:
ez::ezOptionParser opt;
template<class T>
int generate();
template<class T>
void generate_field(true_type);
template<class T>
void generate_field(false_type)
{
}
template<class T>
void make_with_mac_key(int nplayers, int default_num, bool zero);
template<class T>
void make_basic(const typename T::mac_type& key, int nplayers, int nitems, bool zero);
template<class T>
void make_edabits(const typename T::mac_type& key, int N, int ntrip, bool zero, false_type,
const typename T::bit_type::mac_type& bit_key = {});
template<class T>
void make_edabits(const typename T::mac_type&, int, int, bool, true_type)
{
}
};
void make_bit_triples(const gf2n& key,int N,int ntrip,Dtype dtype,bool zero)
{
PRNG G;
G.ReSeed();
ofstream* outf=new ofstream[N];
gf2n a,b,c, one;
one.assign_one();
vector<Share<gf2n> > Sa(N),Sb(N),Sc(N);
/* Generate Triples */
for (int i=0; i<N; i++)
{ stringstream filename;
filename << get_prep_sub_dir<Share<gf2n>>(prep_data_prefix, N)
<< DataPositions::dtype_names[dtype] << "-2-P" << i;
cout << "Opening " << filename.str() << endl;
outf[i].open(filename.str().c_str(),ios::out | ios::binary);
if (outf[i].fail()) { throw file_error(filename.str().c_str()); }
}
for (int i=0; i<ntrip; i++)
{
if (!zero)
a.randomize(G);
a.AND(a, one);
make_share(Sa,a,N,key,G);
if (!zero)
b.randomize(G);
if (dtype == DATA_BITTRIPLE)
b.AND(b, one);
make_share(Sb,b,N,key,G);
c.mul(a,b);
make_share(Sc,c,N,key,G);
for (int j=0; j<N; j++)
{ Sa[j].output(outf[j],false);
Sb[j].output(outf[j],false);
Sc[j].output(outf[j],false);
}
}
check_files(outf, N);
for (int i=0; i<N; i++)
{ outf[i].close(); }
delete[] outf;
}
/* N = Number players
* ntrip = Number tuples needed
* str = "2" or "p"
*/
template<class T>
void make_square_tuples(const typename T::mac_type& key,int N,int ntrip,const string& str,bool zero)
{
(void) str;
PRNG G;
G.ReSeed();
ofstream* outf=new ofstream[N];
typename T::clear a,c;
vector<T> Sa(N),Sc(N);
/* Generate Squares */
for (int i=0; i<N; i++)
{ stringstream filename;
filename << get_prep_sub_dir<T>(prep_data_prefix, N) << "Squares-"
<< T::type_short() << "-P" << i;
cout << "Opening " << filename.str() << endl;
outf[i].open(filename.str().c_str(),ios::out | ios::binary);
if (outf[i].fail()) { throw file_error(filename.str().c_str()); }
}
for (int i=0; i<ntrip; i++)
{
if (!zero)
a.randomize(G);
make_share(Sa,a,N,key,G);
c = a * a;
make_share(Sc,c,N,key,G);
for (int j=0; j<N; j++)
{ Sa[j].output(outf[j],false);
Sc[j].output(outf[j],false);
}
}
check_files(outf, N);
for (int i=0; i<N; i++)
{ outf[i].close(); }
delete[] outf;
}
/* N = Number players
* ntrip = Number bits needed
*/
template<class T>
void make_bits(const typename T::mac_type& key, int N, int ntrip, bool zero,
int thread_num = -1)
{
PRNG G;
G.ReSeed();
ofstream* outf=new ofstream[N];
typename T::clear a;
vector<T> Sa(N);
/* Generate Bits */
for (int i=0; i<N; i++)
{ stringstream filename;
filename << get_prep_sub_dir<T>(prep_data_prefix, N) << "Bits-"
<< T::type_short() << "-P" << i
<< Sub_Data_Files<T>::get_suffix(thread_num);
cout << "Opening " << filename.str() << endl;
outf[i].open(filename.str().c_str(),ios::out | ios::binary);
if (outf[i].fail()) { throw file_error(filename.str().c_str()); }
}
for (int i=0; i<ntrip; i++)
{ if ((G.get_uchar()&1)==0 || zero) { a.assign_zero(); }
else { a.assign_one(); }
make_share(Sa,a,N,key,G);
for (int j=0; j<N; j++)
{ Sa[j].output(outf[j],false); }
}
check_files(outf, N);
for (int i=0; i<N; i++)
{ outf[i].close(); }
delete[] outf;
}
template<class T>
void make_dabits(const typename T::mac_type& key, int N, int ntrip, bool zero,
const typename T::bit_type::mac_type& bit_key = { })
{
Files<T> files(N, key,
get_prep_sub_dir<T>(prep_data_prefix, N)
+ DataPositions::dtype_names[DATA_DABIT] + "-" + T::type_short());
SeededPRNG G;
for (int i = 0; i < ntrip; i++)
{
bool bit = not zero && G.get_bit();
files.template output_shares<T>(bit);
files.template output_shares<typename dabit<T>::bit_type>(bit, bit_key);
}
}
template<class T>
void FakeParams::make_edabits(const typename T::mac_type& key, int N, int ntrip, bool zero, false_type,
const typename T::bit_type::mac_type& bit_key)
{
vector<int> lengths;
opt.get("-e")->getInts(lengths);
for (auto length : lengths)
{
Files<T> files(N, key,
get_prep_sub_dir<T>(prep_data_prefix, N)
+ "edaBits-" + to_string(length));
SeededPRNG G;
bigint value;
int max_size = edabitvec<T>::MAX_SIZE;
for (int i = 0; i < ntrip / max_size; i++)
{
vector<typename T::clear> as(max_size);
vector<typename T::bit_type::part_type::clear> bs(length);
for (int j = 0; j < max_size; j++)
{
if (not zero)
G.get_bigint(value, length, true);
as[j] = value;
for (int k = 0; k < length; k++)
bs[k] ^= BitVec(bigint((value >> k) & 1).get_si()) << j;
}
for (auto& a : as)
files.template output_shares<T>(a);
for (auto& b : bs)
files.template output_shares<typename T::bit_type::part_type>(b, bit_key);
}
}
}
/* N = Number players
* ntrip = Number inputs needed
* str = "2" or "p"
*
*/
template<class T>
void make_inputs(const typename T::mac_type& key,int N,int ntrip,const string& str,bool zero)
{
(void) str;
PRNG G;
G.ReSeed();
ofstream* outf=new ofstream[N];
typename T::open_type a;
vector<T> Sa(N);
/* Generate Inputs */
for (int player=0; player<N; player++)
{ for (int i=0; i<N; i++)
{ stringstream filename;
filename << get_prep_sub_dir<T>(prep_data_prefix, N) << "Inputs-"
<< T::type_short() << "-P" << i << "-" << player;
cout << "Opening " << filename.str() << endl;
outf[i].open(filename.str().c_str(),ios::out | ios::binary);
if (outf[i].fail()) { throw file_error(filename.str().c_str()); }
}
for (int i=0; i<ntrip; i++)
{
if (!zero)
a.randomize(G);
make_share(Sa,a,N,key,G);
for (int j=0; j<N; j++)
{ Sa[j].output(outf[j],false);
if (j==player)
{ a.output(outf[j],false); }
}
}
for (int i=0; i<N; i++)
{ outf[i].close(); }
}
check_files(outf, N);
delete[] outf;
}
template<class T>
void make_PreMulC(const typename T::mac_type& key, int N, int ntrip, bool zero)
{
stringstream ss;
ss << get_prep_sub_dir<T>(prep_data_prefix, N) << "PreMulC-" << T::type_short();
Files<T> files(N, key, ss.str());
PRNG G;
G.ReSeed();
typename T::clear a, b, c;
c = 1;
for (int i=0; i<ntrip; i++)
{
// close the circle
if (i == ntrip - 1 || zero)
a.assign_one();
else
do
a.randomize(G);
while (a.is_zero());
files.output_shares(a);
b.invert(a);
files.output_shares(b);
files.output_shares(a * c);
c = b;
}
}
// Code for TTP AES
unsigned char sbox[256] =
{
0x63, 0x7C, 0x77, 0x7B, 0xF2, 0x6B, 0x6F, 0xC5, 0x30, 0x01, 0x67, 0x2B, 0xFE, 0xD7, 0xAB, 0x76,
0xCA, 0x82, 0xC9, 0x7D, 0xFA, 0x59, 0x47, 0xF0, 0xAD, 0xD4, 0xA2, 0xAF, 0x9C, 0xA4, 0x72, 0xC0,
0xB7, 0xFD, 0x93, 0x26, 0x36, 0x3F, 0xF7, 0xCC, 0x34, 0xA5, 0xE5, 0xF1, 0x71, 0xD8, 0x31, 0x15,
0x04, 0xC7, 0x23, 0xC3, 0x18, 0x96, 0x05, 0x9A, 0x07, 0x12, 0x80, 0xE2, 0xEB, 0x27, 0xB2, 0x75,
0x09, 0x83, 0x2C, 0x1A, 0x1B, 0x6E, 0x5A, 0xA0, 0x52, 0x3B, 0xD6, 0xB3, 0x29, 0xE3, 0x2F, 0x84,
0x53, 0xD1, 0x00, 0xED, 0x20, 0xFC, 0xB1, 0x5B, 0x6A, 0xCB, 0xBE, 0x39, 0x4A, 0x4C, 0x58, 0xCF,
0xD0, 0xEF, 0xAA, 0xFB, 0x43, 0x4D, 0x33, 0x85, 0x45, 0xF9, 0x02, 0x7F, 0x50, 0x3C, 0x9F, 0xA8,
0x51, 0xA3, 0x40, 0x8F, 0x92, 0x9D, 0x38, 0xF5, 0xBC, 0xB6, 0xDA, 0x21, 0x10, 0xFF, 0xF3, 0xD2,
0xCD, 0x0C, 0x13, 0xEC, 0x5F, 0x97, 0x44, 0x17, 0xC4, 0xA7, 0x7E, 0x3D, 0x64, 0x5D, 0x19, 0x73,
0x60, 0x81, 0x4F, 0xDC, 0x22, 0x2A, 0x90, 0x88, 0x46, 0xEE, 0xB8, 0x14, 0xDE, 0x5E, 0x0B, 0xDB,
0xE0, 0x32, 0x3A, 0x0A, 0x49, 0x06, 0x24, 0x5C, 0xC2, 0xD3, 0xAC, 0x62, 0x91, 0x95, 0xE4, 0x79,
0xE7, 0xC8, 0x37, 0x6D, 0x8D, 0xD5, 0x4E, 0xA9, 0x6C, 0x56, 0xF4, 0xEA, 0x65, 0x7A, 0xAE, 0x08,
0xBA, 0x78, 0x25, 0x2E, 0x1C, 0xA6, 0xB4, 0xC6, 0xE8, 0xDD, 0x74, 0x1F, 0x4B, 0xBD, 0x8B, 0x8A,
0x70, 0x3E, 0xB5, 0x66, 0x48, 0x03, 0xF6, 0x0E, 0x61, 0x35, 0x57, 0xB9, 0x86, 0xC1, 0x1D, 0x9E,
0xE1, 0xF8, 0x98, 0x11, 0x69, 0xD9, 0x8E, 0x94, 0x9B, 0x1E, 0x87, 0xE9, 0xCE, 0x55, 0x28, 0xDF,
0x8C, 0xA1, 0x89, 0x0D, 0xBF, 0xE6, 0x42, 0x68, 0x41, 0x99, 0x2D, 0x0F, 0xB0, 0x54, 0xBB, 0x16
};
template<class T>
void make_AES(const typename T::mac_type& key, int N, int ntrip, bool zero) {
stringstream ss;
ss << get_prep_sub_dir<T>(prep_data_prefix, N) << "Sbox-" << T::type_short();
Files<T> files(N, key, ss.str());
PRNG G;
G.ReSeed();
gf2n_short x;
for (int i = 0; i < ntrip; i++)
{
int mask = 0;
if (!zero)
mask = G.get_uchar();
expand_byte(x, mask);
files.output_shares(x);
for (int j = 0; j < 256; j++)
{
expand_byte(x, sbox[mask ^ j]);
files.output_shares(x);
}
}
}
// Code for TTP DES
vector<vector<unsigned char>> des_sbox = {
{14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12, 5, 9, 0, 7, 0, 15, 7, 4, 14, 2, 13, 1, 10, 6, 12, 11, 9, 5, 3, 8, 4, 1, 14, 8, 13, 6, 2, 11, 15, 12, 9, 7, 3, 10, 5, 0, 15, 12, 8, 2, 4, 9, 1, 7, 5, 11, 3, 14, 10, 0, 6, 13},
{15, 1, 8, 14, 6, 11, 3, 4, 9, 7, 2, 13, 12, 0, 5, 10, 3, 13, 4, 7, 15, 2, 8, 14, 12, 0, 1, 10, 6, 9, 11, 5, 0, 14, 7, 11, 10, 4, 13, 1, 5, 8, 12, 6, 9, 3, 2, 15, 13, 8, 10, 1, 3, 15, 4, 2, 11, 6, 7, 12, 0, 5, 14, 9},
{10, 0, 9, 14, 6, 3, 15, 5, 1, 13, 12, 7, 11, 4, 2, 8, 13, 7, 0, 9, 3, 4, 6, 10, 2, 8, 5, 14, 12, 11, 15, 1, 13, 6, 4, 9, 8, 15, 3, 0, 11, 1, 2, 12, 5, 10, 14, 7, 1, 10, 13, 0, 6, 9, 8, 7, 4, 15, 14, 3, 11, 5, 2, 12},
{7, 13, 14, 3, 0, 6, 9, 10, 1, 2, 8, 5, 11, 12, 4, 15, 13, 8, 11, 5, 6, 15, 0, 3, 4, 7, 2, 12, 1, 10, 14, 9, 10, 6, 9, 0, 12, 11, 7, 13, 15, 1, 3, 14, 5, 2, 8, 4, 3, 15, 0, 6, 10, 1, 13, 8, 9, 4, 5, 11, 12, 7, 2, 14},
{2, 12, 4, 1, 7, 10, 11, 6, 8, 5, 3, 15, 13, 0, 14, 9, 14, 11, 2, 12, 4, 7, 13, 1, 5, 0, 15, 10, 3, 9, 8, 6, 4, 2, 1, 11, 10, 13, 7, 8, 15, 9, 12, 5, 6, 3, 0, 14, 11, 8, 12, 7, 1, 14, 2, 13, 6, 15, 0, 9, 10, 4, 5, 3},
{12, 1, 10, 15, 9, 2, 6, 8, 0, 13, 3, 4, 14, 7, 5, 11, 10, 15, 4, 2, 7, 12, 9, 5, 6, 1, 13, 14, 0, 11, 3, 8, 9, 14, 15, 5, 2, 8, 12, 3, 7, 0, 4, 10, 1, 13, 11, 6, 4, 3, 2, 12, 9, 5, 15, 10, 11, 14, 1, 7, 6, 0, 8, 13},
{4, 11, 2, 14, 15, 0, 8, 13, 3, 12, 9, 7, 5, 10, 6, 1, 13, 0, 11, 7, 4, 9, 1, 10, 14, 3, 5, 12, 2, 15, 8, 6, 1, 4, 11, 13, 12, 3, 7, 14, 10, 15, 6, 8, 0, 5, 9, 2, 6, 11, 13, 8, 1, 4, 10, 7, 9, 5, 0, 15, 14, 2, 3, 12},
{13, 2, 8, 4, 6, 15, 11, 1, 10, 9, 3, 14, 5, 0, 12, 7, 1, 15, 13, 8, 10, 3, 7, 4, 12, 5, 6, 11, 0, 14, 9, 2, 7, 11, 4, 1, 9, 12, 14, 2, 0, 6, 10, 13, 15, 3, 5, 8, 2, 1, 14, 7, 4, 10, 8, 13, 15, 12, 9, 0, 3, 5, 6, 11}
};
template<class T>
void make_DES(const typename T::mac_type& key, int N, int ntrip, bool zero)
{
stringstream ss;
ss << get_prep_sub_dir<T>(prep_data_prefix, N) << "SboxDes-" << T::type_short();
Files<T> files(N, key, ss.str());
PRNG G;
G.ReSeed();
gf2n_short x;
for (int i = 0; i < ntrip; i++)
{
for (int r = 0; r < 8; ++r) {
int mask = 0;
if (!zero)
mask = G.get_uchar();
mask &= 63; //take only first 6 bits
expand_byte(x, mask);
files.output_shares(x);
for (int j = 0; j < 64; j++)
{
files.output_shares(des_sbox[r][mask ^ j]);
}
}
}
}
template<class T>
void make_Sbox(const typename T::mac_type& key, int N, int ntrip, bool zero, T, gf2n_short)
{
make_AES<T>(key, N, ntrip, zero);
make_DES<T>(key, N, ntrip, zero);
}
template<class T, class U>
void make_Sbox(const typename T::mac_type& key, int N, int ntrip, bool zero, T, U)
{
(void)key, (void)N, (void)ntrip, (void)zero;
}
template<class T>
void make_Sbox(const typename T::mac_type& key, int N, int ntrip, bool zero)
{
make_Sbox(key, N, ntrip, zero, T(), typename T::clear());
}
template<class T>
void make_minimal(const typename T::mac_type& key, int nplayers, int nitems, bool zero)
{
make_mult_triples<T>(key, nplayers, nitems, zero, prep_data_prefix);
make_bits<T>(key, nplayers, nitems, zero);
make_inputs<T>(key, nplayers, nitems, T::type_short(), zero);
}
template<class T>
void FakeParams::make_basic(const typename T::mac_type& key, int nplayers, int nitems, bool zero)
{
make_minimal<T>(key, nplayers, nitems, zero);
make_square_tuples<T>(key, nplayers, nitems, T::type_short(), zero);
make_dabits<T>(key, nplayers, nitems, zero);
make_edabits<T>(key, nplayers, nitems, zero, T::clear::characteristic_two);
if (T::clear::invertible)
{
make_inverse<T>(key, nplayers, nitems, zero, prep_data_prefix);
if (opt.isSet("-s"))
{
make_PreMulC<T>(key, nplayers, nitems, zero);
make_Sbox<T>(key, nplayers, nitems, zero);
}
}
}
template<class T>
void FakeParams::make_with_mac_key(int nplayers, int default_num, bool zero)
{
typename T::mac_share_type::open_type key;
generate_mac_keys<T>(key, nplayers, prep_data_prefix);
make_basic<T>(key, nplayers, default_num, zero);
}
template<class T>
int generate(ez::ezOptionParser& opt);
int main(int argc, const char** argv)
{
insecure("preprocessing");
bigint::init_thread();
FakeParams params;
auto& opt = params.opt;
opt.syntax = "./Fake-Offline.x <nplayers> [OPTIONS]\n\nOptions with 2 arguments take the form '-X <#gf2n tuples>,<#modp tuples>'";
opt.example = "./Fake-Offline.x 2 -lgp 128 -lg2 128 --default 10000\n./Fake-Offline.x 3 -trip 50000,10000 -btrip 100000\n";
opt.add(
"128", // Default.
0, // Required?
1, // Number of args expected.
0, // Delimiter if expecting multiple args.
"Bit length of GF(p) field (default: 128)", // Help description.
"-lgp", // Flag token.
"--lgp" // Flag token.
);
opt.add(
to_string(gf2n::default_degree()).c_str(), // Default.
0, // Required?
1, // Number of args expected.
0, // Delimiter if expecting multiple args.
("Bit length of GF(2^n) field (default: " + to_string(gf2n::default_degree()) + ")").c_str(), // Help description.
"-lg2", // Flag token.
"--lg2" // Flag token.
);
opt.add(
"1000", // Default.
0, // Required?
1, // Number of args expected.
0, // Delimiter if expecting multiple args.
"Default number of tuples to generate for ALL data types (default: 1000)", // Help description.
"-d", // Flag token.
"--default" // Flag token.
);
opt.add(
"", // Default.
0, // Required?
2, // Number of args expected.
',', // Delimiter if expecting multiple args.
"Number of triples, for gf2n / modp types", // Help description.
"-trip", // Flag token.
"--ntriples" // Flag token.
);
opt.add(
"", // Default.
0, // Required?
2, // Number of args expected.
',', // Delimiter if expecting multiple args.
"Number of random bits, for gf2n / modp types", // Help description.
"-bit", // Flag token.
"--nbits" // Flag token.
);
opt.add(
"", // Default.
0, // Required?
2, // Number of args expected.
',', // Delimiter if expecting multiple args.
"Number of input tuples, for gf2n / modp types", // Help description.
"-inp", // Flag token.
"--ninputs" // Flag token.
);
opt.add(
"", // Default.
0, // Required?
2, // Number of args expected.
',', // Delimiter if expecting multiple args.
"Number of square tuples, for gf2n / modp types", // Help description.
"-sq", // Flag token.
"--nsquares" // Flag token.
);
opt.add(
"", // Default.
0, // Required?
1, // Number of args expected.
0, // Delimiter if expecting multiple args.
"Number of inverse tuples (modp only)", // Help description.
"-inv", // Flag token.
"--ninverses" // Flag token.
);
opt.add(
"", // Default.
0, // Required?
1, // Number of args expected.
0, // Delimiter if expecting multiple args.
"Number of GF(2) triples", // Help description.
"-btrip", // Flag token.
"--nbittriples" // Flag token.
);
opt.add(
"", // Default.
0, // Required?
1, // Number of args expected.
0, // Delimiter if expecting multiple args.
"Number of GF(2) x GF(2^n) triples", // Help description.
"-mixed", // Flag token.
"--nbitgf2ntriples" // Flag token.
);
opt.add(
"", // Default.
0, // Required?
0, // Number of args expected.
0, // Delimiter if expecting multiple args.
"Set all values to zero, but not the shares", // Help description.
"-z", // Flag token.
"--zero" // Flag token.
);
opt.add(
"", // Default.
0, // Required?
1, // Number of args expected.
0, // Delimiter if expecting multiple args.
"Generate for SPDZ2k with parameter k (bit length)", // Help description.
"-Z", // Flag token.
"--spdz2k" // Flag token.
);
opt.add(
"", // Default.
0, // Required?
1, // Number of args expected.
0, // Delimiter if expecting multiple args.
"SPDZ2k security parameter (default: k)", // Help description.
"-S", // Flag token.
"--security" // Flag token.
);
opt.add(
"", // Default.
0, // Required?
-1, // Number of args expected.
',', // Delimiter if expecting multiple args.
"edaBit lengths (separate by comma)", // Help description.
"-e", // Flag token.
"--edabits" // Flag token.
);
opt.add(
"", // Default.
0, // Required?
0, // Number of args expected.
',', // Delimiter if expecting multiple args.
"Special preprocessing", // Help description.
"-s", // Flag token.
"--special" // Flag token.
);
opt.parse(argc, argv);
int lgp;
opt.get("--lgp")->getInt(lgp);
if (opt.isSet("-Z"))
{
int k, s;
opt.get("-Z")->getInt(k);
s = k;
if (opt.isSet("-S"))
opt.get("-S")->getInt(s);
if (k == 32 and s == 32)
return params.generate<Spdz2kShare<32, 32>>();
else if (k == 64 and s == 64)
return params.generate<Spdz2kShare<64, 64>>();
else if (k == 64 and s == 48)
return params.generate<Spdz2kShare<64, 48>>();
else
throw runtime_error("not compiled for k=" + to_string(k) + " and s=" + to_string(s));
}
else
params.generate<Share<gfpvar>>();
}
template<class T>
int FakeParams::generate()
{
vector<string> badOptions;
string usage;
unsigned int i;
if(!opt.gotRequired(badOptions))
{
for (i=0; i < badOptions.size(); ++i)
cerr << "ERROR: Missing required option " << badOptions[i] << ".";
opt.getUsage(usage);
cout << usage;
return 1;
}
if(!opt.gotExpected(badOptions))
{
for(i=0; i < badOptions.size(); ++i)
cerr << "ERROR: Got unexpected number of arguments for option " << badOptions[i] << ".";
opt.getUsage(usage);
cout << usage;
return 1;
}
if (opt.firstArgs.size() == 2)
{
nplayers = atoi(opt.firstArgs[1]->c_str());
}
else if (opt.lastArgs.size() == 1)
{
nplayers = atoi(opt.lastArgs[0]->c_str());
}
else
{
cerr << "ERROR: invalid number of arguments\n";
opt.getUsage(usage);
cout << usage;
return 1;
}
int ntrip2=0, ntripp=0, nbits2=0,nbitsp=0,nsqr2=0,nsqrp=0,ninp2=0,ninpp=0,ninv=0, nbittrip=0, nbitgf2ntrip=0;
vector<int> list_options;
int lg2, lgp;
opt.get("--lgp")->getInt(lgp);
opt.get("--lg2")->getInt(lg2);
opt.get("--default")->getInt(default_num);
ntrip2 = ntripp = nbits2 = nbitsp = nsqr2 = nsqrp = ninp2 = ninpp = ninv =
nbittrip = nbitgf2ntrip = default_num;
if (opt.isSet("--ntriples"))
{
opt.get("--ntriples")->getInts(list_options);
ntrip2 = list_options[0];
ntripp = list_options[1];
}
if (opt.isSet("--nbits"))
{
opt.get("--nbits")->getInts(list_options);
nbits2 = list_options[0];
nbitsp = list_options[1];
}
if (opt.isSet("--ninputs"))
{
opt.get("--ninputs")->getInts(list_options);
ninp2 = list_options[0];
ninpp = list_options[1];
}
if (opt.isSet("--nsquares"))
{
opt.get("--nsquares")->getInts(list_options);
nsqr2 = list_options[0];
nsqrp = list_options[1];
}
if (opt.isSet("--ninverses"))
opt.get("--ninverses")->getInt(ninv);
if (opt.isSet("--nbittriples"))
opt.get("--nbittriples")->getInt(nbittrip);
if (opt.isSet("--nbitgf2ntriples"))
opt.get("--nbitgf2ntriples")->getInt(nbitgf2ntrip);
zero = opt.isSet("--zero");
if (zero)
cout << "Set all values to zero" << endl;
// check compatibility
gf2n::init_field(lg2);
PRNG G;
G.ReSeed();
prep_data_prefix = PREP_DIR;
// Set up the fields
T::clear::template generate_setup<T>(prep_data_prefix, nplayers, lgp);
T::clear::init_default(lgp);
/* Find number players and MAC keys etc*/
typename T::mac_type::Scalar keyp;
gf2n key2;
// create PREP_DIR if not there
if (mkdir_p(PREP_DIR) == -1)
{
cerr << "mkdir_p(" PREP_DIR ") failed\n";
throw file_error(PREP_DIR);
}
typedef Share<gf2n> sgf2n;
generate_mac_keys<T>(keyp, nplayers, prep_data_prefix);
generate_mac_keys<sgf2n>(key2, nplayers, prep_data_prefix);
make_mult_triples<sgf2n>(key2,nplayers,ntrip2,zero,prep_data_prefix);
make_mult_triples<T>(keyp,nplayers,ntripp,zero,prep_data_prefix);
make_bits<Share<gf2n>>(key2,nplayers,nbits2,zero);
make_bits<T>(keyp,nplayers,nbitsp,zero);
make_square_tuples<sgf2n>(key2,nplayers,nsqr2,"2",zero);
make_square_tuples<T>(keyp,nplayers,nsqrp,"p",zero);
make_inputs<sgf2n>(key2,nplayers,ninp2,"2",zero);
make_inputs<T>(keyp,nplayers,ninpp,"p",zero);
make_inverse<sgf2n>(key2,nplayers,ninv,zero,prep_data_prefix);
if (T::clear::invertible)
make_inverse<T>(keyp,nplayers,ninv,zero,prep_data_prefix);
make_bit_triples(key2,nplayers,nbittrip,DATA_BITTRIPLE,zero);
make_bit_triples(key2,nplayers,nbitgf2ntrip,DATA_BITGF2NTRIPLE,zero);
if (opt.isSet("-s"))
{
make_PreMulC<sgf2n>(key2,nplayers,ninv,zero);
if (T::clear::invertible)
make_PreMulC<T>(keyp,nplayers,ninv,zero);
make_Sbox<sgf2n>(key2,nplayers,ninv,zero);
}
// replicated secret sharing only for three parties
if (nplayers == 3)
{
make_bits<Rep3Share<Integer>>({}, nplayers, nbitsp, zero);
make_basic<BrainShare<64, 40>>({}, nplayers, default_num, zero);
make_basic<PostSacriRepRingShare<64, 40>>({}, nplayers, default_num, zero);
make_with_mac_key<SpdzWiseRingShare<64, 40>>(nplayers, default_num, zero);
make_mult_triples<GC::MaliciousRepSecret>({}, nplayers, ntrip2, zero, prep_data_prefix);
make_bits<GC::MaliciousRepSecret>({}, nplayers, nbits2, zero);
}
else if (nplayers == 4)
make_basic<Rep4Share2<64>>({}, nplayers, default_num, zero);
make_basic<SemiShare<Z2<64>>>({}, nplayers, default_num, zero);
make_mult_triples<GC::SemiSecret>({}, nplayers, default_num, zero, prep_data_prefix);
make_bits<GC::SemiSecret>({}, nplayers, default_num, zero);
gf2n_short::reset();
gf2n_short::init_field(40);
Z2<41> keyt;
generate_mac_keys<GC::TinySecret<40>>(keyt, nplayers, prep_data_prefix);
make_minimal<GC::TinySecret<40>>(keyt, nplayers, default_num / 64, zero);
gf2n_short keytt;
generate_mac_keys<GC::TinierSecret<gf2n_short>>(keytt, nplayers, prep_data_prefix);
make_minimal<GC::TinierSecret<gf2n_short>>(keytt, nplayers, default_num / 64, zero);
make_dabits<T>(keyp, nplayers, default_num, zero, keytt);
make_edabits<T>(keyp, nplayers, default_num, zero, false_type(), keytt);
if (nplayers > 2)
{
make_mult_triples<GC::MaliciousCcdShare<gf2n_short>>({}, nplayers,
default_num, zero, prep_data_prefix);
}
generate_field<typename T::clear>(T::clear::prime_field);
generate_field<gf2n>(true_type());
return 0;
}
template<class U>
void FakeParams::generate_field(true_type)
{
if (nplayers == 3)
{
make_basic<Rep3Share<U>>({}, nplayers, default_num, zero);
make_basic<MaliciousRep3Share<U>>({}, nplayers, default_num, zero);
make_basic<PostSacriRepFieldShare<U>>({}, nplayers, default_num, zero);
make_with_mac_key<SpdzWiseShare<MaliciousRep3Share<U>>>(nplayers, default_num, zero);
}
make_basic<SemiShare<U>>({}, nplayers, default_num, zero);
if (nplayers > 2)
{
make_basic<ShamirShare<U>>({}, nplayers, default_num, zero);
make_basic<MaliciousShamirShare<U>>({}, nplayers, default_num, zero);
make_with_mac_key<SpdzWiseShare<MaliciousShamirShare<U>>>(nplayers,
default_num, zero);
}
}
| 32.410778 | 221 | 0.587407 | [
"vector"
] |
1b4e491c28580c42aa43f243e517cf0ebc3e01a6 | 23,498 | cpp | C++ | src/servers/media_addon/MediaAddonServer.cpp | Yn0ga/haiku | 74e271b2a286c239e60f0ec261f4f197f4727eee | [
"MIT"
] | 2 | 2018-03-28T06:53:23.000Z | 2021-05-26T19:35:01.000Z | src/servers/media_addon/MediaAddonServer.cpp | Yn0ga/haiku | 74e271b2a286c239e60f0ec261f4f197f4727eee | [
"MIT"
] | null | null | null | src/servers/media_addon/MediaAddonServer.cpp | Yn0ga/haiku | 74e271b2a286c239e60f0ec261f4f197f4727eee | [
"MIT"
] | null | null | null | /*
* Copyright 2009, Axel Dörfler, axeld@pinc-software.de.
* Copyright 2013 Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*/
/*
* Copyright (c) 2002-2004, Marcus Overhagen <marcus@overhagen.de>
* 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 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.
*/
#include <map>
#include <stdio.h>
#include <vector>
#include <Alert.h>
#include <Application.h>
#include <Beep.h>
#include <Directory.h>
#include <Entry.h>
#include <MediaAddOn.h>
#include <MediaRoster.h>
#include <MessageRunner.h>
#include <Path.h>
#include <Roster.h>
#include <String.h>
#include <AddOnMonitorHandler.h>
#include <DataExchange.h>
#include <DormantNodeManager.h>
#include <MediaDebug.h>
#include <MediaMisc.h>
#include <MediaRosterEx.h>
#include <MediaSounds.h>
#include <Notifications.h>
#include <ServerInterface.h>
#include "MediaFilePlayer.h"
#include "SystemTimeSource.h"
//#define USER_ADDON_PATH "../add-ons/media"
typedef std::vector<media_node> NodeVector;
struct AddOnInfo {
media_addon_id id;
bool wants_autostart;
int32 flavor_count;
NodeVector active_flavors;
// if != NULL, need to call gDormantNodeManager->PutAddOn(id)
BMediaAddOn* addon;
};
class MediaAddonServer : BApplication {
public:
MediaAddonServer(const char* signature);
virtual ~MediaAddonServer();
virtual void ReadyToRun();
virtual bool QuitRequested();
virtual void MessageReceived(BMessage* message);
private:
class MonitorHandler;
friend class MonitorHandler;
void _AddOnAdded(const char* path, ino_t fileNode);
void _AddOnRemoved(ino_t fileNode);
void _HandleMessage(int32 code, const void* data,
size_t size);
void _PutAddonIfPossible(AddOnInfo& info);
void _InstantiatePhysicalInputsAndOutputs(
AddOnInfo& info);
void _InstantiateAutostartFlavors(AddOnInfo& info);
void _DestroyInstantiatedFlavors(AddOnInfo& info);
void _ScanAddOnFlavors(BMediaAddOn* addOn);
port_id _ControlPort() const { return fControlPort; }
static status_t _ControlThread(void* arg);
private:
typedef std::map<ino_t, media_addon_id> FileMap;
typedef std::map<media_addon_id, AddOnInfo> InfoMap;
FileMap fFileMap;
InfoMap fInfoMap;
BMediaRoster* fMediaRoster;
MonitorHandler* fMonitorHandler;
BMessageRunner* fPulseRunner;
port_id fControlPort;
thread_id fControlThread;
bool fStartup;
bool fStartupSound;
SystemTimeSource* fSystemTimeSource;
};
class MediaAddonServer::MonitorHandler : public AddOnMonitorHandler {
public:
MonitorHandler(MediaAddonServer* server);
virtual void AddOnEnabled(const add_on_entry_info* info);
virtual void AddOnDisabled(const add_on_entry_info* info);
private:
MediaAddonServer* fServer;
};
#if DEBUG >= 2
static void
DumpFlavorInfo(const flavor_info* info)
{
printf(" name = %s\n", info->name);
printf(" info = %s\n", info->info);
printf(" internal_id = %" B_PRId32 "\n", info->internal_id);
printf(" possible_count = %" B_PRId32 "\n", info->possible_count);
printf(" flavor_flags = 0x%" B_PRIx32, info->flavor_flags);
if (info->flavor_flags & B_FLAVOR_IS_GLOBAL) printf(" B_FLAVOR_IS_GLOBAL");
if (info->flavor_flags & B_FLAVOR_IS_LOCAL) printf(" B_FLAVOR_IS_LOCAL");
printf("\n");
printf(" kinds = 0x%" B_PRIx64, info->kinds);
if (info->kinds & B_BUFFER_PRODUCER) printf(" B_BUFFER_PRODUCER");
if (info->kinds & B_BUFFER_CONSUMER) printf(" B_BUFFER_CONSUMER");
if (info->kinds & B_TIME_SOURCE) printf(" B_TIME_SOURCE");
if (info->kinds & B_CONTROLLABLE) printf(" B_CONTROLLABLE");
if (info->kinds & B_FILE_INTERFACE) printf(" B_FILE_INTERFACE");
if (info->kinds & B_ENTITY_INTERFACE) printf(" B_ENTITY_INTERFACE");
if (info->kinds & B_PHYSICAL_INPUT) printf(" B_PHYSICAL_INPUT");
if (info->kinds & B_PHYSICAL_OUTPUT) printf(" B_PHYSICAL_OUTPUT");
if (info->kinds & B_SYSTEM_MIXER) printf(" B_SYSTEM_MIXER");
printf("\n");
printf(" in_format_count = %" B_PRId32 "\n", info->in_format_count);
printf(" out_format_count = %" B_PRId32 "\n", info->out_format_count);
}
#endif
// #pragma mark -
MediaAddonServer::MonitorHandler::MonitorHandler(MediaAddonServer* server)
{
fServer = server;
}
void
MediaAddonServer::MonitorHandler::AddOnEnabled(const add_on_entry_info* info)
{
entry_ref ref;
make_entry_ref(info->dir_nref.device, info->dir_nref.node,
info->name, &ref);
BEntry entry(&ref, true);
if (!entry.IsFile())
return;
BPath path(&ref);
if (path.InitCheck() == B_OK)
fServer->_AddOnAdded(path.Path(), info->nref.node);
}
void
MediaAddonServer::MonitorHandler::AddOnDisabled(const add_on_entry_info* info)
{
fServer->_AddOnRemoved(info->nref.node);
}
// #pragma mark -
MediaAddonServer::MediaAddonServer(const char* signature)
:
BApplication(signature),
fMonitorHandler(NULL),
fPulseRunner(NULL),
fStartup(true),
fStartupSound(true),
fSystemTimeSource(NULL)
{
CALLED();
fMediaRoster = BMediaRoster::Roster();
fControlPort = create_port(64, MEDIA_ADDON_SERVER_PORT_NAME);
fControlThread = spawn_thread(_ControlThread, "media_addon_server control",
B_NORMAL_PRIORITY + 2, this);
resume_thread(fControlThread);
}
MediaAddonServer::~MediaAddonServer()
{
CALLED();
delete_port(fControlPort);
wait_for_thread(fControlThread, NULL);
// unregister all media add-ons
FileMap::iterator iterator = fFileMap.begin();
for (; iterator != fFileMap.end(); iterator++)
gDormantNodeManager->UnregisterAddOn(iterator->second);
delete fMonitorHandler;
delete fPulseRunner;
}
void
MediaAddonServer::ReadyToRun()
{
if (!be_roster->IsRunning(B_MEDIA_SERVER_SIGNATURE)) {
// the media server is not running, let's quit
fprintf(stderr, "The media_server is not running!\n");
Quit();
return;
}
// the control thread is already running at this point,
// so we can talk to the media server and also receive
// commands for instantiation
ASSERT(fStartup == true);
// The very first thing to do is to create the system time source,
// register it with the server, and make it the default SYSTEM_TIME_SOURCE
fSystemTimeSource = new SystemTimeSource();
status_t result = fMediaRoster->RegisterNode(fSystemTimeSource);
if (result != B_OK) {
fprintf(stderr, "Can't register system time source : %s\n",
strerror(result));
ERROR("Can't register system time source");
}
if (fSystemTimeSource->ID() != NODE_SYSTEM_TIMESOURCE_ID)
ERROR("System time source got wrong node ID");
media_node node = fSystemTimeSource->Node();
result = MediaRosterEx(fMediaRoster)->SetNode(SYSTEM_TIME_SOURCE, &node);
if (result != B_OK)
ERROR("Can't setup system time source as default");
// During startup, first all add-ons are loaded, then all
// nodes (flavors) representing physical inputs and outputs
// are instantiated. Next, all add-ons that need autostart
// will be autostarted. Finally, add-ons that don't have
// any active nodes (flavors) will be unloaded.
fMonitorHandler = new MonitorHandler(this);
AddHandler(fMonitorHandler);
BMessage pulse(B_PULSE);
// the monitor handler needs a pulse to check if add-ons are ready
fPulseRunner = new BMessageRunner(fMonitorHandler, &pulse, 1000000LL);
result = fPulseRunner->InitCheck();
if (result != B_OK)
ERROR("Can't create the pulse runner");
fMonitorHandler->AddAddOnDirectories("media");
#ifdef USER_ADDON_PATH
node_ref nodeRef;
if (entry.SetTo(USER_ADDON_PATH) == B_OK
&& entry.GetNodeRef(&nodeRef) == B_OK) {
fMonitorHandler->AddDirectory(&nodeRef);
}
#endif
fStartup = false;
InfoMap::iterator iterator = fInfoMap.begin();
for (; iterator != fInfoMap.end(); iterator++)
_InstantiatePhysicalInputsAndOutputs(iterator->second);
for (iterator = fInfoMap.begin(); iterator != fInfoMap.end(); iterator++)
_InstantiateAutostartFlavors(iterator->second);
for (iterator = fInfoMap.begin(); iterator != fInfoMap.end(); iterator++)
_PutAddonIfPossible(iterator->second);
server_rescan_defaults_command cmd;
SendToServer(SERVER_RESCAN_DEFAULTS, &cmd, sizeof(cmd));
}
bool
MediaAddonServer::QuitRequested()
{
CALLED();
InfoMap::iterator iterator = fInfoMap.begin();
for (iterator = fInfoMap.begin(); iterator != fInfoMap.end(); iterator++)
_DestroyInstantiatedFlavors(iterator->second);
// the System timesource should be removed before we quit the roster
if (fSystemTimeSource != NULL &&
be_roster->IsRunning(B_MEDIA_SERVER_SIGNATURE)) {
status_t result = fMediaRoster->UnregisterNode(fSystemTimeSource);
if (result != B_OK) {
fprintf(stderr, "Error removing the system time source : %s\n",
strerror(result));
ERROR("Can't remove the system time source");
}
fSystemTimeSource->Release();
fSystemTimeSource = NULL;
}
for (iterator = fInfoMap.begin(); iterator != fInfoMap.end(); iterator++)
_PutAddonIfPossible(iterator->second);
return true;
}
void
MediaAddonServer::MessageReceived(BMessage* message)
{
switch (message->what) {
case MEDIA_ADD_ON_SERVER_PLAY_MEDIA:
{
const char* name;
const char* type;
if (message->FindString(MEDIA_NAME_KEY, &name) != B_OK
|| message->FindString(MEDIA_TYPE_KEY, &type) != B_OK) {
message->SendReply(B_ERROR);
break;
}
PlayMediaFile(type, name);
message->SendReply((uint32)B_OK);
// TODO: don't know which reply is expected
return;
}
default:
BApplication::MessageReceived(message);
break;
}
}
void
MediaAddonServer::_HandleMessage(int32 code, const void* data, size_t size)
{
switch (code) {
case ADD_ON_SERVER_INSTANTIATE_DORMANT_NODE:
{
const add_on_server_instantiate_dormant_node_request* request
= static_cast<
const add_on_server_instantiate_dormant_node_request*>(
data);
add_on_server_instantiate_dormant_node_reply reply;
status_t status
= MediaRosterEx(fMediaRoster)->InstantiateDormantNode(
request->add_on_id, request->flavor_id,
request->creator_team, &reply.node);
request->SendReply(status, &reply, sizeof(reply));
break;
}
case ADD_ON_SERVER_RESCAN_ADD_ON_FLAVORS:
{
const add_on_server_rescan_flavors_command* command = static_cast<
const add_on_server_rescan_flavors_command*>(data);
BMediaAddOn* addOn
= gDormantNodeManager->GetAddOn(command->add_on_id);
if (addOn == NULL) {
ERROR("rescan flavors: Can't find a addon object for id %d\n",
(int)command->add_on_id);
break;
}
_ScanAddOnFlavors(addOn);
gDormantNodeManager->PutAddOn(command->add_on_id);
break;
}
case ADD_ON_SERVER_RESCAN_FINISHED_NOTIFY:
if (fStartupSound) {
BMessage msg(MEDIA_ADD_ON_SERVER_PLAY_MEDIA);
msg.AddString(MEDIA_NAME_KEY, MEDIA_SOUNDS_STARTUP);
msg.AddString(MEDIA_TYPE_KEY, MEDIA_TYPE_SOUNDS);
BMessageRunner::StartSending(this, &msg, 2000000, 1);
fStartupSound = false;
}
break;
default:
ERROR("media_addon_server: received unknown message code %#08"
B_PRIx32 "\n", code);
break;
}
}
status_t
MediaAddonServer::_ControlThread(void* _server)
{
MediaAddonServer* server = (MediaAddonServer*)_server;
char data[B_MEDIA_MESSAGE_SIZE];
ssize_t size;
int32 code;
while ((size = read_port_etc(server->_ControlPort(), &code, data,
sizeof(data), 0, 0)) > 0)
server->_HandleMessage(code, data, size);
return B_OK;
}
void
MediaAddonServer::_ScanAddOnFlavors(BMediaAddOn* addon)
{
ASSERT(addon->AddonID() > 0);
TRACE("MediaAddonServer::_ScanAddOnFlavors: id %" B_PRId32 "\n",
addon->AddonID());
// cache the media_addon_id in a local variable to avoid
// calling BMediaAddOn::AddonID() too often
media_addon_id addonID = addon->AddonID();
// update the cached flavor count, get oldflavorcount and newflavorcount
InfoMap::iterator found = fInfoMap.find(addonID);
ASSERT(found != fInfoMap.end());
AddOnInfo& info = found->second;
int32 oldFlavorCount = info.flavor_count;
int32 newFlavorCount = addon->CountFlavors();
info.flavor_count = newFlavorCount;
TRACE("%" B_PRId32 " old flavors, %" B_PRId32 " new flavors\n",
oldFlavorCount, newFlavorCount);
// during the first update (i == 0), the server removes old dormant_flavor_infos
for (int i = 0; i < newFlavorCount; i++) {
const flavor_info* flavorInfo;
TRACE("flavor %d:\n", i);
if (addon->GetFlavorAt(i, &flavorInfo) != B_OK) {
ERROR("MediaAddonServer::_ScanAddOnFlavors GetFlavorAt failed for "
"index %d!\n", i);
continue;
}
#if DEBUG >= 2
DumpFlavorInfo(flavorInfo);
#endif
dormant_flavor_info dormantFlavorInfo;
dormantFlavorInfo = *flavorInfo;
dormantFlavorInfo.node_info.addon = addonID;
dormantFlavorInfo.node_info.flavor_id = flavorInfo->internal_id;
strlcpy(dormantFlavorInfo.node_info.name, flavorInfo->name,
B_MEDIA_NAME_LENGTH);
size_t flattenedSize = dormantFlavorInfo.FlattenedSize();
size_t messageSize = flattenedSize
+ sizeof(server_register_dormant_node_command);
server_register_dormant_node_command* message
= (server_register_dormant_node_command*)malloc(messageSize);
if (message == NULL)
break;
// The server should remove previously registered "dormant_flavor_info"s
// during the first update, but after the first iteration, we don't
// want the server to anymore remove old dormant_flavor_infos
message->purge_id = i == 0 ? addonID : 0;
message->type = dormantFlavorInfo.TypeCode();
message->flattened_size = flattenedSize;
dormantFlavorInfo.Flatten(message->flattened_data, flattenedSize);
status_t status = SendToServer(SERVER_REGISTER_DORMANT_NODE,
message, messageSize);
if (status != B_OK) {
ERROR("MediaAddonServer::_ScanAddOnFlavors: couldn't register "
"dormant node: %s\n", strerror(status));
}
free(message);
}
// TODO: we currently pretend that all old flavors have been removed, this
// could probably be done in a smarter way
BPrivate::media::notifications::FlavorsChanged(addonID, newFlavorCount,
oldFlavorCount);
}
void
MediaAddonServer::_AddOnAdded(const char* path, ino_t fileNode)
{
TRACE("\n\nMediaAddonServer::_AddOnAdded: path %s\n", path);
media_addon_id id = gDormantNodeManager->RegisterAddOn(path);
if (id <= 0) {
ERROR("MediaAddonServer::_AddOnAdded: failed to register add-on %s\n",
path);
return;
}
TRACE("MediaAddonServer::_AddOnAdded: loading addon %" B_PRId32 " now..."
"\n", id);
BMediaAddOn* addon = gDormantNodeManager->GetAddOn(id);
if (addon == NULL) {
ERROR("MediaAddonServer::_AddOnAdded: failed to get add-on %s\n",
path);
gDormantNodeManager->UnregisterAddOn(id);
return;
}
TRACE("MediaAddonServer::_AddOnAdded: loading finished, id %" B_PRId32
"\n", id);
try {
// put file's inode and addon's id into map
fFileMap.insert(std::make_pair(fileNode, id));
AddOnInfo info = {};
fInfoMap.insert(std::make_pair(id, info));
} catch (std::bad_alloc& exception) {
fFileMap.erase(fileNode);
return;
}
InfoMap::iterator found = fInfoMap.find(id);
AddOnInfo& info = found->second;
info.id = id;
// temporary default
info.wants_autostart = false;
info.flavor_count = 0;
info.addon = addon;
// scan the flavors
_ScanAddOnFlavors(addon);
// need to call BMediaNode::WantsAutoStart()
// after the flavors have been scanned
info.wants_autostart = addon->WantsAutoStart();
if (info.wants_autostart)
TRACE("add-on %" B_PRId32 " WantsAutoStart!\n", id);
// During startup, first all add-ons are loaded, then all
// nodes (flavors) representing physical inputs and outputs
// are instantiated. Next, all add-ons that need autostart
// will be autostarted. Finally, add-ons that don't have
// any active nodes (flavors) will be unloaded.
// After startup is done, we simply do it for each new
// loaded add-on, too.
if (!fStartup) {
_InstantiatePhysicalInputsAndOutputs(info);
_InstantiateAutostartFlavors(info);
_PutAddonIfPossible(info);
// since something might have changed
server_rescan_defaults_command cmd;
SendToServer(SERVER_RESCAN_DEFAULTS, &cmd, sizeof(cmd));
}
// we do not call gDormantNodeManager->PutAddOn(id)
// since it is done by _PutAddonIfPossible()
}
void
MediaAddonServer::_DestroyInstantiatedFlavors(AddOnInfo& info)
{
printf("MediaAddonServer::_DestroyInstantiatedFlavors addon %" B_PRId32
"\n", info.id);
NodeVector::iterator iterator = info.active_flavors.begin();
for (; iterator != info.active_flavors.end(); iterator++) {
media_node& node = *iterator;
printf("node %" B_PRId32 "\n", node.node);
if ((node.kind & B_TIME_SOURCE) != 0
&& (fMediaRoster->StopTimeSource(node, 0, true) != B_OK)) {
printf("MediaAddonServer::_DestroyInstantiatedFlavors couldn't stop "
"timesource\n");
continue;
}
if (fMediaRoster->StopNode(node, 0, true) != B_OK) {
printf("MediaAddonServer::_DestroyInstantiatedFlavors couldn't stop "
"node\n");
continue;
}
if ((node.kind & B_BUFFER_CONSUMER) != 0) {
media_input inputs[16];
int32 count = 0;
if (fMediaRoster->GetConnectedInputsFor(node, inputs, 16, &count)
!= B_OK) {
printf("MediaAddonServer::_DestroyInstantiatedFlavors couldn't "
"get connected inputs\n");
continue;
}
for (int32 i = 0; i < count; i++) {
media_node_id sourceNode;
if ((sourceNode = fMediaRoster->NodeIDFor(
inputs[i].source.port)) < 0) {
printf("MediaAddonServer::_DestroyInstantiatedFlavors "
"couldn't get source node id\n");
continue;
}
if (fMediaRoster->Disconnect(sourceNode, inputs[i].source,
node.node, inputs[i].destination) != B_OK) {
printf("MediaAddonServer::_DestroyInstantiatedFlavors "
"couldn't disconnect input\n");
continue;
}
}
}
if ((node.kind & B_BUFFER_PRODUCER) != 0) {
media_output outputs[16];
int32 count = 0;
if (fMediaRoster->GetConnectedOutputsFor(node, outputs, 16,
&count) != B_OK) {
printf("MediaAddonServer::_DestroyInstantiatedFlavors couldn't "
"get connected outputs\n");
continue;
}
for (int32 i = 0; i < count; i++) {
media_node_id destNode;
if ((destNode = fMediaRoster->NodeIDFor(
outputs[i].destination.port)) < 0) {
printf("MediaAddonServer::_DestroyInstantiatedFlavors "
"couldn't get destination node id\n");
continue;
}
if (fMediaRoster->Disconnect(node.node, outputs[i].source,
destNode, outputs[i].destination) != B_OK) {
printf("MediaAddonServer::_DestroyInstantiatedFlavors "
"couldn't disconnect output\n");
continue;
}
}
}
if (MediaRosterEx(fMediaRoster)->ReleaseNodeAll(node) != B_OK) {
printf("MediaAddonServer::_DestroyInstantiatedFlavors "
"couldn't release node\n");
}
// wait a bit to let the node clean up
snooze(50000);
}
info.active_flavors.clear();
}
void
MediaAddonServer::_PutAddonIfPossible(AddOnInfo& info)
{
if (info.addon && info.active_flavors.empty()) {
gDormantNodeManager->PutAddOn(info.id);
info.addon = NULL;
}
}
void
MediaAddonServer::_InstantiatePhysicalInputsAndOutputs(AddOnInfo& info)
{
CALLED();
int32 count = info.addon->CountFlavors();
for (int32 i = 0; i < count; i++) {
const flavor_info* flavorinfo;
if (info.addon->GetFlavorAt(i, &flavorinfo) != B_OK) {
ERROR("MediaAddonServer::InstantiatePhysialInputsAndOutputs "
"GetFlavorAt failed for index %" B_PRId32 "!\n", i);
continue;
}
if ((flavorinfo->kinds & (B_PHYSICAL_INPUT | B_PHYSICAL_OUTPUT)) != 0) {
media_node node;
dormant_node_info dormantNodeInfo;
dormantNodeInfo.addon = info.id;
dormantNodeInfo.flavor_id = flavorinfo->internal_id;
strcpy(dormantNodeInfo.name, flavorinfo->name);
TRACE("MediaAddonServer::InstantiatePhysialInputsAndOutputs: "
"\"%s\" is a physical input/output\n", flavorinfo->name);
status_t status = fMediaRoster->InstantiateDormantNode(
dormantNodeInfo, &node);
if (status != B_OK) {
ERROR("MediaAddonServer::InstantiatePhysialInputsAndOutputs "
"Couldn't instantiate node flavor, internal_id %" B_PRId32
", name %s\n", flavorinfo->internal_id, flavorinfo->name);
} else {
TRACE("Node created!\n");
info.active_flavors.push_back(node);
}
}
}
}
void
MediaAddonServer::_InstantiateAutostartFlavors(AddOnInfo& info)
{
if (!info.wants_autostart)
return;
for (int32 index = 0;; index++) {
TRACE("trying autostart of node %" B_PRId32 ", index %" B_PRId32 "\n",
info.id, index);
BMediaNode* node;
int32 internalID;
bool hasMore;
status_t status = info.addon->AutoStart(index, &node, &internalID,
&hasMore);
if (status == B_MEDIA_ADDON_FAILED && hasMore)
continue;
else if (status != B_OK)
break;
printf("started node %" B_PRId32 "\n", index);
status = MediaRosterEx(fMediaRoster)->RegisterNode(node, info.id,
internalID);
if (status != B_OK) {
ERROR("failed to register node %" B_PRId32 "\n", index);
node->Release();
} else {
MediaRosterEx(fMediaRoster)->IncrementAddonFlavorInstancesCount(
info.id, internalID);
info.active_flavors.push_back(node->Node());
}
if (!hasMore)
return;
}
}
void
MediaAddonServer::_AddOnRemoved(ino_t fileNode)
{
// TODO: locking?
FileMap::iterator foundFile = fFileMap.find(fileNode);
if (foundFile == fFileMap.end()) {
ERROR("MediaAddonServer::_AddOnRemoved: inode %" B_PRIdINO " removed, but no "
"media add-on found\n", fileNode);
return;
}
media_addon_id id = foundFile->second;
fFileMap.erase(foundFile);
int32 oldFlavorCount;
InfoMap::iterator foundInfo = fInfoMap.find(id);
if (foundInfo == fInfoMap.end()) {
ERROR("MediaAddonServer::_AddOnRemoved: couldn't get addon info for "
"add-on %" B_PRId32 "\n", id);
oldFlavorCount = 1000;
} else {
AddOnInfo& info = foundInfo->second;
oldFlavorCount = info.flavor_count;
_DestroyInstantiatedFlavors(info);
_PutAddonIfPossible(info);
if (info.addon) {
ERROR("MediaAddonServer::_AddOnRemoved: couldn't unload addon "
"%" B_PRId32 " since flavors are in use\n", id);
}
fInfoMap.erase(foundInfo);
}
gDormantNodeManager->UnregisterAddOn(id);
BPrivate::media::notifications::FlavorsChanged(id, 0, oldFlavorCount);
}
// #pragma mark -
int
main()
{
new MediaAddonServer(B_MEDIA_ADDON_SERVER_SIGNATURE);
be_app->Run();
delete be_app;
return 0;
}
| 28.107656 | 84 | 0.720742 | [
"object",
"vector"
] |
1b57631aa8e4bc47e60e99275666525782dbfd7c | 2,078 | cpp | C++ | 10 Days of Statistics/Day_0/mean_mode_median.cpp | yurkovak/HackerRank | a10136e508692f98e76e7c27d9cd801a3380f8ba | [
"MIT"
] | null | null | null | 10 Days of Statistics/Day_0/mean_mode_median.cpp | yurkovak/HackerRank | a10136e508692f98e76e7c27d9cd801a3380f8ba | [
"MIT"
] | null | null | null | 10 Days of Statistics/Day_0/mean_mode_median.cpp | yurkovak/HackerRank | a10136e508692f98e76e7c27d9cd801a3380f8ba | [
"MIT"
] | null | null | null | #include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iomanip>
//using namespace std;
double mean(const std::vector<int>& values){
double sum = 0;
for (unsigned i = 0; i < values.size(); ++i)
sum += static_cast<double>(values.at(i));
return sum / values.size();
}
void bubbleSort(std::vector<int>& values){
bool done = false;
int smaller;
while (done != true){
done = true;
for (unsigned i = 1; i < values.size(); ++i){
if (values.at(i - 1) > values.at(i)){
smaller = values.at(i);
values.at(i) = values.at(i - 1);
values.at(i - 1) = smaller;
done = false;
}
}
}
}
float median(std::vector<int>& values){
bubbleSort(values);
unsigned len = values.size();
if (len == 1)
return static_cast<float>(values.at(0));
unsigned middle = len/2;
if (len % 2 == 0){
return static_cast<float>((values.at(middle - 1) + values.at(middle))/2.);
}
else return static_cast<float>(values.at(middle));
}
int mode(std::vector<int>& values){
bubbleSort(values);
int cur_el = values.at(0);
int mode = values.at(0);
unsigned cur_count = 1;
unsigned max_count = 1;
for (unsigned i = 1; i < values.size(); ++i)
if (values.at(i) == cur_el)
++cur_count;
else if(cur_count > max_count){
mode = values.at(i - 1);
max_count = cur_count;
cur_el = values.at(i);
cur_count = 1;
}
else {
cur_el = values.at(i);
cur_count = 1;
}
if(cur_count > max_count)
mode = values.back();
return mode;
}
int main() {
unsigned size;
std::cin >> size;
std::vector<int> values(size);
for (unsigned i = 0; i < size; i++)
std::cin >> values.at(i);
printf("%.1f\n", mean(values));
printf("%.1f\n", median(values));
std::cout << mode(values) << '\n';
return 0;
}
| 22.835165 | 82 | 0.522137 | [
"vector"
] |
1b5784f80bde6dd7c14e85a51dca956ff6dac5a6 | 2,316 | hpp | C++ | src/rpp/rpp/operators/fwd/map.hpp | victimsnino/ReactivePlusPlus | bb187cc52936bce7c1ef4899d7dbb9c970cef291 | [
"MIT"
] | 1 | 2022-03-19T20:15:50.000Z | 2022-03-19T20:15:50.000Z | src/rpp/rpp/operators/fwd/map.hpp | victimsnino/ReactivePlusPlus | bb187cc52936bce7c1ef4899d7dbb9c970cef291 | [
"MIT"
] | 12 | 2022-03-22T21:18:14.000Z | 2022-03-30T05:37:58.000Z | src/rpp/rpp/operators/fwd/map.hpp | victimsnino/ReactivePlusPlus | bb187cc52936bce7c1ef4899d7dbb9c970cef291 | [
"MIT"
] | null | null | null | // ReactivePlusPlus library
//
// Copyright Aleksey Loginov 2022 - present.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// https://www.boost.org/LICENSE_1_0.txt)
//
// Project home: https://github.com/victimsnino/ReactivePlusPlus
//
#pragma once
#include <rpp/observables/details/member_overload.hpp>
namespace rpp::details
{
struct map_tag;
}
namespace rpp::details
{
template<constraint::decayed_type Type, std::invocable<Type> Callable>
auto map_impl(Callable&& callable);
template<constraint::decayed_type Type, typename SpecificObservable>
struct member_overload<Type, SpecificObservable, map_tag>
{
/**
* \brief Transform the items emitted by an Observable via applying a function to each item and emitting result
* \note The Map operator can keep same type of value or change it to some another type.
*
* \marble map
{
source observable : +--1 -2 --3 -|
operator "map: x=>x+10" : +--(10)-(12)--(13)-|
}
*
* \param callable is callable used to provide this transformation. Should accept Type of original observable and return type for new observable
* \return new specific_observable with the Map operator as most recent operator.
* \warning #include <rpp/operators/map.hpp>
*
* \par Example with same type:
* \snippet map.cpp Same type
*
* \par Example with changed type:
* \snippet map.cpp Changed type
* \ingroup transforming_operators
* \see https://reactivex.io/documentation/operators/map.html
*/
template<std::invocable<Type> Callable>
auto map(Callable&& callable) const & requires is_header_included<map_tag, Callable>
{
return static_cast<const SpecificObservable*>(this)->template lift<std::invoke_result_t<Callable, Type>>(map_impl<Type>(std::forward<Callable>(callable)));
}
template<std::invocable<Type> Callable>
auto map(Callable&& callable) && requires is_header_included<map_tag, Callable>
{
return std::move(*static_cast<SpecificObservable*>(this)).template lift<std::invoke_result_t<Callable, Type>>(map_impl<Type>(std::forward<Callable>(callable)));
}
};
} // namespace rpp::details
| 36.761905 | 168 | 0.686097 | [
"transform"
] |
1b57b3cea2b2f6cd89b79e376b29bb73564eb49e | 4,632 | cpp | C++ | game/shared/portal/portal_usermessages.cpp | SmileyAG/cstrike15_src | 5315265785320e0f53ebd27c3486e6c7b826a227 | [
"Unlicense"
] | 2 | 2022-02-25T12:18:31.000Z | 2022-03-16T23:59:59.000Z | game/shared/portal/portal_usermessages.cpp | SmileyAG/cstrike15_src | 5315265785320e0f53ebd27c3486e6c7b826a227 | [
"Unlicense"
] | null | null | null | game/shared/portal/portal_usermessages.cpp | SmileyAG/cstrike15_src | 5315265785320e0f53ebd27c3486e6c7b826a227 | [
"Unlicense"
] | 7 | 2021-08-22T11:29:02.000Z | 2022-03-29T11:59:15.000Z | //========= Copyright (c) 1996-2005, Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
//=============================================================================//
#include "cbase.h"
#include "usermessages.h"
#include "shake.h"
#include "voice_gamemgr.h"
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
void RegisterUserMessages()
{
//copy/paste from hl2
usermessages->Register( "Geiger", 1 );
usermessages->Register( "Train", 1 );
usermessages->Register( "HudText", -1 );
usermessages->Register( "SayText", -1 );
usermessages->Register( "SayText2", -1 );
usermessages->Register( "TextMsg", -1 );
usermessages->Register( "HudMsg", -1 );
usermessages->Register( "ResetHUD", 1); // called every respawn
usermessages->Register( "GameTitle", 0 );
usermessages->Register( "ItemPickup", -1 );
usermessages->Register( "ShowMenu", -1 );
usermessages->Register( "Shake", 13 );
usermessages->Register( "Tilt", 22 );
usermessages->Register( "Fade", 10 );
usermessages->Register( "VGUIMenu", -1 ); // Show VGUI menu
usermessages->Register( "Rumble", 3 ); // Send a rumble to a controller
usermessages->Register( "Battery", 2 );
usermessages->Register( "Damage", 18 ); // BUG: floats are sent for coords, no variable bitfields in hud & fixed size Msg
usermessages->Register( "VoiceMask", VOICE_MAX_PLAYERS_DW*4 * 2 + 1 );
usermessages->Register( "RequestState", 0 );
usermessages->Register( "CloseCaption", -1 ); // Show a caption (by string id number)(duration in 10th of a second)
usermessages->Register( "CloseCaptionDirect", -1 ); // Show a forced caption (by string id number)(duration in 10th of a second)
usermessages->Register( "HintText", -1 ); // Displays hint text display
usermessages->Register( "KeyHintText", -1 ); // Displays hint text display
usermessages->Register( "SquadMemberDied", 0 );
usermessages->Register( "AmmoDenied", 2 );
usermessages->Register( "CreditsMsg", 1 );
usermessages->Register( "LogoTimeMsg", 4 );
usermessages->Register( "AchievementEvent", -1 );
usermessages->Register( "UpdateJalopyRadar", -1 );
usermessages->Register( "CurrentTimescale", 4 ); // Send one float for the new timescale
usermessages->Register( "DesiredTimescale", 13 ); // Send timescale and some blending vars
//new stuff for portal
usermessages->Register( "CreditsPortalMsg", 1 );
#ifdef PORTAL2
usermessages->Register( "InventoryFlash", sizeof( float ) + 1 );
usermessages->Register( "IndicatorFlash", sizeof( float ) + 1 );
usermessages->Register( "ControlHelperAnimate", 2 );
usermessages->Register( "TakePhoto", sizeof( long ) + sizeof( uint8 ) );
usermessages->Register( "Flash", sizeof( float ) + sizeof( Vector ) );
usermessages->Register( "HudPingIndicator", sizeof( Vector ) );
usermessages->Register( "OpenRadialMenu", -1 );
usermessages->Register( "AddLocator", -1 );
usermessages->Register( "MPMapCompleted", sizeof( char ) + sizeof( char ) );
usermessages->Register( "MPMapIncomplete", sizeof( char ) + sizeof( char ) );
usermessages->Register( "MPMapCompletedData", -1 );
usermessages->Register( "MPTauntEarned", -1 );
usermessages->Register( "MPTauntUnlocked", -1 );
usermessages->Register( "MPTauntLocked", -1 );
usermessages->Register( "MPAllTauntsLocked", -1 );
// Portal effects
usermessages->Register( "PortalFX_Surface", -1 );
// Paint messages
usermessages->Register( "PaintWorld", -1 );
usermessages->Register( "PaintEntity", sizeof( long ) + sizeof( uint8 ) + sizeof( Vector ) );
usermessages->Register( "ChangePaintColor", sizeof( long ) + sizeof( uint8 ) );
usermessages->Register( "PaintBombExplode", sizeof( Vector ) + sizeof( uint8 ) + sizeof( uint8 ) + sizeof( BYTE ) );
usermessages->Register( "RemoveAllPaint", 0 );
usermessages->Register( "PaintAllSurfaces", sizeof( BYTE ) );
usermessages->Register( "RemovePaint", sizeof( long ) );
usermessages->Register( "StartSurvey", sizeof( long ) );
usermessages->Register( "ApplyHitBoxDamageEffect", sizeof( long ) + sizeof( uint8 ) + sizeof( uint8 ) );
usermessages->Register( "SetMixLayerTriggerFactor", -1 );
usermessages->Register( "TransitionFade", sizeof( float ) );
usermessages->Register( "ScoreboardTempUpdate", sizeof( long ) + sizeof( long ) );
usermessages->Register( "ChallengeModeCheatSession", -1 );
usermessages->Register( "ChallengeModeCloseAllUI", -1 );
// FIXME: Bring this back for DLC2
//usermessages->Register( "MPVSGameStart", sizeof( char ) );
//usermessages->Register( "MPVSGameOver", sizeof( BYTE ) );
//usermessages->Register( "MPVSRoundEnd", sizeof( BYTE ) );
#endif // PORTAL2
}
| 47.265306 | 129 | 0.690415 | [
"vector"
] |
1b5f9ee0f79e9e03221334a58022db8df48a659c | 12,983 | cpp | C++ | src/skin.cpp | Rinnegatamante/librw | 9bc95992649ed87cdfaf7f1fd00ea7222377abef | [
"MIT"
] | null | null | null | src/skin.cpp | Rinnegatamante/librw | 9bc95992649ed87cdfaf7f1fd00ea7222377abef | [
"MIT"
] | null | null | null | src/skin.cpp | Rinnegatamante/librw | 9bc95992649ed87cdfaf7f1fd00ea7222377abef | [
"MIT"
] | null | null | null | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include "rwbase.h"
#include "rwerror.h"
#include "rwplg.h"
#include "rwpipeline.h"
#include "rwobjects.h"
#include "rwanim.h"
#include "rwengine.h"
#include "rwplugins.h"
#include "ps2/rwps2.h"
#include "ps2/rwps2plg.h"
#include "d3d/rwxbox.h"
#include "d3d/rwd3d8.h"
#include "d3d/rwd3d9.h"
#include "gl/rwwdgl.h"
#include "gl/rwgl3.h"
#include "gl/rwgl3plg.h"
#define PLUGIN_ID ID_SKIN
namespace rw {
SkinGlobals skinGlobals = { 0, 0, { nil } };
static void*
createSkin(void *object, int32 offset, int32)
{
*PLUGINOFFSET(Skin*, object, offset) = nil;
return object;
}
static void*
destroySkin(void *object, int32 offset, int32)
{
Skin *skin = *PLUGINOFFSET(Skin*, object, offset);
if(skin){
rwFree(skin->data);
rwFree(skin->remapIndices);
// delete[] skin->platformData;
}
rwFree(skin);
return object;
}
static void*
copySkin(void *dst, void *src, int32 offset, int32)
{
Skin *srcskin = *PLUGINOFFSET(Skin*, src, offset);
if(srcskin == nil)
return dst;
Geometry *geometry = (Geometry*)src;
assert(geometry->instData == nil);
assert(((Geometry*)src)->numVertices == ((Geometry*)dst)->numVertices);
Skin *dstskin = rwNewT(Skin, 1, MEMDUR_EVENT | ID_SKIN);
*PLUGINOFFSET(Skin*, dst, offset) = dstskin;
dstskin->numBones = srcskin->numBones;
dstskin->numUsedBones = srcskin->numUsedBones;
dstskin->numWeights = srcskin->numWeights;
assert(0 && "can't copy skin yet");
dstskin->init(srcskin->numBones, srcskin->numUsedBones,
geometry->numVertices);
sceClibMemcpy(dstskin->usedBones, srcskin->usedBones, srcskin->numUsedBones);
sceClibMemcpy(dstskin->inverseMatrices, srcskin->inverseMatrices,
srcskin->numBones*64);
sceClibMemcpy(dstskin->indices, srcskin->indices, geometry->numVertices*4);
sceClibMemcpy(dstskin->weights, srcskin->weights, geometry->numVertices*16);
return dst;
}
Stream*
readSkinSplitData(Stream *stream, Skin *skin)
{
uint32 sz;
int8 *data;
skin->boneLimit = stream->readI32();
skin->numMeshes = stream->readI32();
skin->rleSize = stream->readI32();
if(skin->numMeshes){
sz = skin->numBones + 2*(skin->numMeshes+skin->rleSize);
data = (int8*)rwMalloc(sz, MEMDUR_EVENT | ID_SKIN);
stream->read8(data, sz);
skin->remapIndices = data;
skin->rleCount = (Skin::RLEcount*)(data + skin->numBones);
skin->rle = (Skin::RLE*)(data + skin->numBones + 2*skin->numMeshes);
}
return stream;
}
Stream*
writeSkinSplitData(Stream *stream, Skin *skin)
{
stream->writeI32(skin->boneLimit);
stream->writeI32(skin->numMeshes);
stream->writeI32(skin->rleSize);
if(skin->numMeshes)
stream->write8(skin->remapIndices,
skin->numBones + 2*(skin->numMeshes+skin->rleSize));
return stream;
}
int32
skinSplitDataSize(Skin *skin)
{
if(skin->numMeshes == 0)
return 12;
return 12 + skin->numBones + 2*(skin->numMeshes+skin->rleSize);
}
static Stream*
readSkin(Stream *stream, int32 len, void *object, int32 offset, int32)
{
uint8 header[4];
Geometry *geometry = (Geometry*)object;
if(geometry->instData){
// TODO: function pointers
if(geometry->instData->platform == PLATFORM_PS2)
return ps2::readNativeSkin(stream, len, object, offset);
else if(geometry->instData->platform == PLATFORM_WDGL)
return wdgl::readNativeSkin(stream, len, object, offset);
else if(geometry->instData->platform == PLATFORM_XBOX)
return xbox::readNativeSkin(stream, len, object, offset);
else{
assert(0 && "unsupported native skin platform");
return nil;
}
}
stream->read8(header, 4); // numBones, numUsedBones,
// numWeights, unused
Skin *skin = rwNewT(Skin, 1, MEMDUR_EVENT | ID_SKIN);
*PLUGINOFFSET(Skin*, geometry, offset) = skin;
// numUsedBones and numWeights appear in/after 34003
// but not in/before 33002 (probably rw::version >= 0x34000)
bool oldFormat = header[1] == 0;
// Use numBones for numUsedBones to allocate data,
// find out the correct value later
if(oldFormat)
skin->init(header[0], header[0], geometry->numVertices);
else
skin->init(header[0], header[1], geometry->numVertices);
skin->numWeights = header[2];
if(!oldFormat)
stream->read8(skin->usedBones, skin->numUsedBones);
if(skin->indices)
stream->read8(skin->indices, geometry->numVertices*4);
if(skin->weights)
stream->read32(skin->weights, geometry->numVertices*16);
for(int32 i = 0; i < skin->numBones; i++){
if(oldFormat)
stream->seek(4); // skip 0xdeaddead
stream->read32(&skin->inverseMatrices[i*16], 64);
}
if(oldFormat){
skin->findNumWeights(geometry->numVertices);
skin->findUsedBones(geometry->numVertices);
}
if(!oldFormat)
readSkinSplitData(stream, skin);
return stream;
}
static Stream*
writeSkin(Stream *stream, int32 len, void *object, int32 offset, int32)
{
uint8 header[4];
Geometry *geometry = (Geometry*)object;
if(geometry->instData){
if(geometry->instData->platform == PLATFORM_PS2)
return ps2::writeNativeSkin(stream, len, object, offset);
else if(geometry->instData->platform == PLATFORM_WDGL)
return wdgl::writeNativeSkin(stream, len, object, offset);
else if(geometry->instData->platform == PLATFORM_XBOX)
return xbox::writeNativeSkin(stream, len, object, offset);
else{
assert(0 && "unsupported native skin platform");
return nil;
}
}
Skin *skin = *PLUGINOFFSET(Skin*, object, offset);
// not sure which version introduced the new format
bool oldFormat = version < 0x34000;
header[0] = skin->numBones;
if(oldFormat){
header[1] = 0;
header[2] = 0;
}else{
header[1] = skin->numUsedBones;
header[2] = skin->numWeights;
}
header[3] = 0;
stream->write8(header, 4);
if(!oldFormat)
stream->write8(skin->usedBones, skin->numUsedBones);
stream->write8(skin->indices, geometry->numVertices*4);
stream->write32(skin->weights, geometry->numVertices*16);
for(int32 i = 0; i < skin->numBones; i++){
if(oldFormat)
stream->writeU32(0xdeaddead);
stream->write32(&skin->inverseMatrices[i*16], 64);
}
if(!oldFormat)
writeSkinSplitData(stream, skin);
return stream;
}
static int32
getSizeSkin(void *object, int32 offset, int32)
{
Geometry *geometry = (Geometry*)object;
if(geometry->instData){
if(geometry->instData->platform == PLATFORM_PS2)
return ps2::getSizeNativeSkin(object, offset);
if(geometry->instData->platform == PLATFORM_WDGL)
return wdgl::getSizeNativeSkin(object, offset);
if(geometry->instData->platform == PLATFORM_XBOX)
return xbox::getSizeNativeSkin(object, offset);
if(geometry->instData->platform == PLATFORM_D3D8)
return -1;
if(geometry->instData->platform == PLATFORM_D3D9)
return -1;
assert(0 && "unsupported native skin platform");
}
Skin *skin = *PLUGINOFFSET(Skin*, object, offset);
if(skin == nil)
return -1;
int32 size = 4 + geometry->numVertices*(16+4) +
skin->numBones*64;
// not sure which version introduced the new format
if(version < 0x34000)
size += skin->numBones*4;
else
size += skin->numUsedBones + skinSplitDataSize(skin);
return size;
}
static Stream*
readSkinLegacy(Stream *stream, int32 len, void *object, int32, int32)
{
Atomic *atomic = (Atomic*)object;
Geometry *geometry = atomic->geometry;
int32 numBones = stream->readI32();
int32 numVertices = stream->readI32();
assert(numVertices == geometry->numVertices);
Skin *skin = rwNewT(Skin, 1, MEMDUR_EVENT | ID_SKIN);
*PLUGINOFFSET(Skin*, geometry, skinGlobals.geoOffset) = skin;
skin->init(numBones, numBones, numVertices);
skin->legacyType = 1;
skin->numWeights = 4;
stream->read8(skin->indices, numVertices*4);
stream->read32(skin->weights, numVertices*16);
HAnimHierarchy *hier = HAnimHierarchy::create(numBones, nil, nil, 0, 36);
for(int i = 0; i < numBones; i++){
hier->nodeInfo[i].id = stream->readI32();
hier->nodeInfo[i].index = stream->readI32();
hier->nodeInfo[i].flags = stream->readI32() & 3;
// printf("%d %d %d %d\n", i, hier->nodeInfo[i].id, hier->nodeInfo[i].index, hier->nodeInfo[i].flags);
stream->read32(&skin->inverseMatrices[i*16], 64);
Matrix mat;
Matrix::invert(&mat, (Matrix*)&skin->inverseMatrices[i*16]);
// printf("[ [ %8.4f, %8.4f, %8.4f, %8.4f ]\n"
// " [ %8.4f, %8.4f, %8.4f, %8.4f ]\n"
// " [ %8.4f, %8.4f, %8.4f, %8.4f ]\n"
// " [ %8.4f, %8.4f, %8.4f, %8.4f ] ]\n"
// " %08x == flags\n",
// mat.right.x, mat.up.x, mat.at.x, mat.pos.x,
// mat.right.y, mat.up.y, mat.at.y, mat.pos.y,
// mat.right.z, mat.up.z, mat.at.z, mat.pos.z,
// 0.0f, 0.0f, 0.0f, 1.0f,
// mat.flags);
}
Frame *frame = atomic->getFrame()->child;
assert(frame->next == nil); // in old files atomic is above hierarchy it seems
assert(frame->count() == numBones); // assuming one frame per node this should also be true
HAnimData::get(frame)->hierarchy = hier;
hier->parentFrame = frame;
return stream;
}
static void
skinRights(void *object, int32, int32, uint32)
{
Skin::setPipeline((Atomic*)object, 1);
}
static void
skinAlways(void *object, int32, int32)
{
Atomic *atomic = (Atomic*)object;
Geometry *geo = atomic->geometry;
if(geo == nil) return;
Skin *skin = Skin::get(geo);
if(skin == nil) return;
Skin::setPipeline((Atomic*)object, 1);
}
static void*
createSkinAtm(void *object, int32 offset, int32)
{
*PLUGINOFFSET(void*, object, offset) = nil;
return object;
}
static void*
destroySkinAtm(void *object, int32 offset, int32)
{
return object;
}
static void*
copySkinAtm(void *dst, void *src, int32 offset, int32)
{
*PLUGINOFFSET(void*, dst, offset) = *PLUGINOFFSET(void*, src, offset);
return dst;
}
static void*
skinOpen(void *o, int32, int32)
{
// init dummy pipelines
skinGlobals.dummypipe = ObjPipeline::create();
skinGlobals.dummypipe->pluginID = ID_SKIN;
skinGlobals.dummypipe->pluginData = 1;
for(uint i = 0; i < nelem(skinGlobals.pipelines); i++)
skinGlobals.pipelines[i] = skinGlobals.dummypipe;
return o;
}
static void*
skinClose(void *o, int32, int32)
{
for(uint i = 0; i < nelem(skinGlobals.pipelines); i++)
if(skinGlobals.pipelines[i] == skinGlobals.dummypipe)
matFXGlobals.pipelines[i] = nil;
skinGlobals.dummypipe->destroy();
skinGlobals.dummypipe = nil;
return o;
}
void
registerSkinPlugin(void)
{
Driver::registerPlugin(PLATFORM_NULL, 0, ID_SKIN,
skinOpen, skinClose);
ps2::initSkin();
xbox::initSkin();
d3d8::initSkin();
d3d9::initSkin();
wdgl::initSkin();
gl3::initSkin();
int32 o;
o = Geometry::registerPlugin(sizeof(Skin*), ID_SKIN,
createSkin, destroySkin, copySkin);
Geometry::registerPluginStream(ID_SKIN,
readSkin, writeSkin, getSizeSkin);
skinGlobals.geoOffset = o;
o = Atomic::registerPlugin(sizeof(HAnimHierarchy*),ID_SKIN,
createSkinAtm, destroySkinAtm, copySkinAtm);
skinGlobals.atomicOffset = o;
Atomic::registerPluginStream(ID_SKIN, readSkinLegacy, nil, nil);
Atomic::setStreamRightsCallback(ID_SKIN, skinRights);
Atomic::setStreamAlwaysCallback(ID_SKIN, skinAlways);
}
void
Skin::init(int32 numBones, int32 numUsedBones, int32 numVertices)
{
this->numBones = numBones;
this->numUsedBones = numUsedBones;
uint32 size = this->numUsedBones +
this->numBones*64 +
numVertices*(16+4) + 0xF;
this->data = rwNewT(uint8, size, MEMDUR_EVENT | ID_SKIN);
uint8 *p = this->data;
this->usedBones = nil;
if(this->numUsedBones){
this->usedBones = p;
p += this->numUsedBones;
}
p = (uint8*)(((uintptr)p + 0xF) & ~0xF);
this->inverseMatrices = nil;
if(this->numBones){
this->inverseMatrices = (float*)p;
p += 64*this->numBones;
}
this->indices = nil;
if(numVertices){
this->indices = p;
p += 4*numVertices;
}
this->weights = nil;
if(numVertices)
this->weights = (float*)p;
this->boneLimit = 0;
this->numMeshes = 0;
this->rleSize = 0;
this->remapIndices = nil;
this->rleCount = nil;
this->rle = nil;
this->platformData = nil;
this->legacyType = 0;
}
//static_assert(sizeof(Skin::RLEcount) == 2, "RLEcount size");
//static_assert(sizeof(Skin::RLE) == 2, "RLE size");
void
Skin::findNumWeights(int32 numVertices)
{
this->numWeights = 1;
float *w = this->weights;
while(numVertices--){
while(w[this->numWeights] != 0.0f){
this->numWeights++;
if(this->numWeights == 4)
return;
}
w += 4;
}
}
void
Skin::findUsedBones(int32 numVertices)
{
uint8 usedTab[256];
uint8 *indices = this->indices;
float *weights = this->weights;
memset(usedTab, 0, 256);
while(numVertices--){
for(int32 i = 0; i < this->numWeights; i++){
if(weights[i] == 0.0f)
continue; // TODO: this could probably be optimized
if(usedTab[indices[i]] == 0)
usedTab[indices[i]]++;
}
indices += 4;
weights += 4;
}
this->numUsedBones = 0;
for(int32 i = 0; i < 256; i++)
if(usedTab[i])
this->usedBones[this->numUsedBones++] = i;
}
void
Skin::setPipeline(Atomic *a, int32 type)
{
(void)type;
a->pipeline = skinGlobals.pipelines[rw::platform];
}
}
| 26.659138 | 103 | 0.678426 | [
"geometry",
"object"
] |
1b635f3183b79352c50925dbc4b34fe7c5e64b5f | 26,609 | cpp | C++ | source/managers/Storyboard.cpp | skelleher/HappyGame | 2c7610f420dab4ccf7e636c1c0d8fb6819989853 | [
"BSD-3-Clause"
] | 4 | 2015-06-23T19:23:31.000Z | 2017-01-05T07:08:08.000Z | source/managers/Storyboard.cpp | skelleher/HappyGame | 2c7610f420dab4ccf7e636c1c0d8fb6819989853 | [
"BSD-3-Clause"
] | null | null | null | source/managers/Storyboard.cpp | skelleher/HappyGame | 2c7610f420dab4ccf7e636c1c0d8fb6819989853 | [
"BSD-3-Clause"
] | null | null | null | #include "StoryboardManager.hpp"
#include "Storyboard.hpp"
#include "GameObjectManager.hpp"
#include "EffectManager.hpp"
#include "LayerManager.hpp"
namespace Z
{
//=============================================================================
//
// Multiple Animations are grouped together in an Storyboard,
// which controls all animated properties of a single object.
//
//=============================================================================
Storyboard::Storyboard() :
m_interpolatorType(INTERPOLATOR_TYPE_UNKNOWN),
m_isBoundToTarget(false),
m_numAnimations(0),
m_numFinishedAnimations(0),
m_pAnimationBindings(NULL),
m_pCallbackOnFinished(NULL),
m_pObject(NULL),
m_startTimeMS(0),
m_durationMS(0),
m_isStarted(false),
m_isPaused(false),
m_autoRepeat(false),
m_autoReverse(false),
m_releaseTargetOnFinish(true),
m_deleteOnFinish(true),
m_relativeToCurrentState(false)
{
}
Storyboard::~Storyboard()
{
DEBUGMSG(ZONE_STORYBOARD, "\t~Storyboard( %4d, \"%s\" 0x%x, numTargets %d = 0x%x)", m_ID, m_name.c_str(), (UINT32)m_hGameObject, m_numAnimations, m_pAnimationBindings);
StoryboardMan.Stop( this );
UnBind();
SAFE_ARRAY_DELETE(m_pAnimationBindings);
}
// TODO: implement the copy ctor and assignment operator like the others.
Storyboard*
Storyboard::Clone() const
{
RESULT rval = S_OK;
Storyboard* pClone = new Storyboard(*this);
// Duplicate m_hGameObject, if non-NULL, so the refcount will be increased.
// We're being paranoid; Storyboards should only be cloned from "templates,"
// which should NOT be bound to an actual GameObject.
if (!m_hGameObject.IsNull())
{
pClone->m_hGameObject = m_hGameObject;
CHR( GOMan.AddRef( m_hGameObject ));
}
// DEEP COPY: m_pAnimationBindings
pClone->m_pAnimationBindings = new AnimationBinding[m_numAnimations];
DEBUGCHK(pClone->m_pAnimationBindings);
// DEEP COPY: duplicate the AnimationBindings
for (int i = 0; i < m_numAnimations; ++i)
{
// Clone the AnimationBinding.
pClone->m_pAnimationBindings[i] = m_pAnimationBindings[i];
// Clone the Animation.
AnimationBinding* pClonedAnimationBinding = &pClone->m_pAnimationBindings[i];
if (FAILED(AnimationMan.GetCopy( pClonedAnimationBinding->m_animationName, &pClonedAnimationBinding->m_hAnimation ))) // Overwrite original handle with new handle (copy of the Animation)
{
RETAILMSG(ZONE_ERROR, "ERROR: StoryBoard::Clone( \"%s\" ): failed to copy Animation track %d \"%s\".",
m_name.c_str(), i, pClonedAnimationBinding->m_animationName.c_str());
// DEBUGCHK(0);
continue;
}
}
// DEEP COPY: m_pCallbackOnFinished
if (m_pCallbackOnFinished)
{
pClone->m_pCallbackOnFinished = m_pCallbackOnFinished->Clone();
}
// Give it a new name with a random suffix
char instanceName[MAX_PATH];
sprintf(instanceName, "%s_%X", m_name.c_str(), (unsigned int)Platform::Random());
pClone->m_name = string(instanceName);
Exit:
if (FAILED(rval))
{
RETAILMSG(ZONE_ERROR, "ERROR: Storyboard::Clone() failed! rval = 0x%x", rval);
}
return pClone;
}
RESULT
Storyboard::Init( IN const string& name, IN HAnimation* pHAnimations, UINT8 numAnimations, bool autoRepeat, bool autoReverse, bool releaseTargetOnFinish, bool deleteOnFinish, bool isRelative )
{
RESULT rval = S_OK;
if (!pHAnimations || !numAnimations)
{
RETAILMSG(ZONE_ERROR, "ERROR: Storyboard::Init(): must pass pHAnimations, numAnimations.");
rval = E_INVALID_DATA;
goto Exit;
}
if (name == "")
{
char randomName[MAX_NAME];
sprintf(randomName, "Storyboard_%X", (unsigned int)Platform::Random());
m_name = randomName;
}
else
{
m_name = name;
}
m_autoRepeat = autoRepeat;
m_autoReverse = autoReverse;
m_releaseTargetOnFinish = releaseTargetOnFinish;
m_deleteOnFinish = deleteOnFinish;
m_relativeToCurrentState = isRelative;
m_numAnimations = numAnimations;
m_pAnimationBindings = new AnimationBinding[ m_numAnimations ];
if (!m_pAnimationBindings)
{
RETAILMSG(ZONE_ERROR, "ERROR: Storyboard::Init(): out of memory");
rval = E_OUTOFMEMORY;
goto Exit;
}
for (int i = 0; i < m_numAnimations; ++i)
{
m_durationMS = MAX(m_durationMS, AnimationMan.GetDurationMS( *pHAnimations ));
//
// Create the AnimationBinding
//
AnimationBinding *pAnimationBinding = &m_pAnimationBindings[i];
string name;
CHR(AnimationMan.GetName( *pHAnimations, &name ));
rval = CreateAnimationBinding( name, pAnimationBinding );
if (FAILED(rval))
{
RETAILMSG(ZONE_ERROR, "ERROR: Storyboard::Init( %s ): failed to create AnimationBinding", m_name.c_str());
// Continue loading other Animations rather than aborting.
continue;
}
pHAnimations++;
// Override the Animation properties with our own.
// Redundant but err on the side of consistency.
AnimationMan.SetAutoRepeat ( pAnimationBinding->m_hAnimation, m_autoRepeat );
AnimationMan.SetAutoReverse ( pAnimationBinding->m_hAnimation, m_autoReverse );
AnimationMan.SetDeleteOnFinish ( pAnimationBinding->m_hAnimation, m_deleteOnFinish );
// AnimationMan.SetRelativeToCurrentState( pAnimationBinding->m_hAnimation, m_relativeToCurrentState );
DEBUGMSG(ZONE_STORYBOARD | ZONE_VERBOSE, "Storyboard [%s] += [%s]",
m_name.c_str(), pAnimationBinding->m_animationName.c_str() );
}
RETAILMSG(ZONE_STORYBOARD, "Storyboard[%4d]: \"%-32s\" %d animation tracks %d msec",
m_ID, m_name.c_str(), m_numAnimations, m_durationMS);
Exit:
return rval;
}
RESULT
Storyboard::Init( IN const string& name, IN const Settings* pSettings, IN const string& settingsPath )
{
RESULT rval = S_OK;
char path[MAX_PATH];
string interpolator;
m_name = name;
if (!pSettings)
{
RETAILMSG(ZONE_ERROR, "ERROR: Storyboard::Init(): NULL settings");
rval = E_INVALID_ARG;
goto Exit;
}
m_autoRepeat = pSettings->GetBool( settingsPath + ".AutoRepeat", false );
m_autoReverse = pSettings->GetBool( settingsPath + ".AutoReverse", false );
m_releaseTargetOnFinish = pSettings->GetBool( settingsPath + ".ReleaseOnFinish", false );
m_deleteOnFinish = pSettings->GetBool( settingsPath + ".DeleteOnFinish", false );
m_relativeToCurrentState = pSettings->GetBool( settingsPath + ".RelativeToObject", false );
// TODO: this needs to be a lookup table in Animation.
interpolator = pSettings->GetString( settingsPath + ".Interpolator", "" );
if ("Linear" == interpolator)
{
m_interpolatorType = INTERPOLATOR_TYPE_LINEAR;
}
else if ("QuadraticEaseIn" == interpolator)
{
m_interpolatorType = INTERPOLATOR_TYPE_QUADRATIC_IN;
}
else if ("QuadraticEaseOut" == interpolator)
{
m_interpolatorType = INTERPOLATOR_TYPE_QUADRATIC_OUT;
}
else if ("QuadraticEaseInOut" == interpolator)
{
m_interpolatorType = INTERPOLATOR_TYPE_QUADRATIC_INOUT;
}
else if ("ElasticIn" == interpolator)
{
m_interpolatorType = INTERPOLATOR_TYPE_ELASTIC_IN;
}
m_numAnimations = pSettings->GetInt( settingsPath + ".NumAnimations" );
if (0 == m_numAnimations)
{
RETAILMSG(ZONE_ERROR, "ERROR: Storyboard::Init(): zero Animations defined; check XML");
rval = E_INVALID_ARG;
goto Exit;
}
m_pAnimationBindings = new AnimationBinding[ m_numAnimations ];
if (!m_pAnimationBindings)
{
RETAILMSG(ZONE_ERROR, "ERROR: Storyboard::Init(): out of memory");
rval = E_OUTOFMEMORY;
goto Exit;
}
for (int i = 0; i < m_numAnimations; ++i)
{
//
// Create the Animation
//
sprintf(path, "%s/Animation%d", settingsPath.c_str(), i);
Animation *pAnimation = NULL;
RESULT rval = AnimationMan.CreateAnimation( pSettings, path, &pAnimation );
if (!pAnimation || FAILED(rval))
{
RETAILMSG(ZONE_ERROR, "ERROR: Storyboard::Init( %s ): failed to create Animation", path);
// Continue loading other Animations rather than aborting.
continue;
}
m_durationMS = MAX(m_durationMS, pAnimation->GetDurationMS());
// TODO: do this before creating the animation, so that
// the Animation can override settings inherited from the Storyboard.
pAnimation->SetAutoRepeat ( m_autoRepeat );
pAnimation->SetAutoReverse ( m_autoReverse );
pAnimation->SetDeleteOnFinish ( m_deleteOnFinish );
// pAnimation->SetRelativeToCurrentState( m_relativeToCurrentState );
if (m_interpolatorType != INTERPOLATOR_TYPE_UNKNOWN)
{
pAnimation->SetInterpolatorType( m_interpolatorType );
}
// DEBUGMSG(ZONE_STORYBOARD, "Created Animation [%s]", pAnimation->GetName().c_str());
CHR(AnimationMan.Add(pAnimation->GetName(), pAnimation));
//
// Create the AnimationBinding
//
AnimationBinding *pAnimationBinding = &m_pAnimationBindings[i];
string animationName = pAnimation->GetName();
rval = CreateAnimationBinding( animationName, pAnimationBinding );
if (FAILED(rval))
{
RETAILMSG(ZONE_ERROR, "ERROR: Storyboard::Init( %s ): failed to create AnimationBinding", path);
// Continue loading other Animations rather than aborting.
continue;
}
DEBUGMSG(ZONE_STORYBOARD | ZONE_VERBOSE, "Storyboard [%s] += [%s]",
m_name.c_str(), pAnimationBinding->m_animationName.c_str() );
}
RETAILMSG(ZONE_STORYBOARD, "Storyboard[%4d]: \"%-32s\" %d animation tracks, %d msec",
m_ID, m_name.c_str(), m_numAnimations, m_durationMS);
Exit:
return rval;
}
RESULT
Storyboard::Update( UINT64 elapsedMS )
{
RESULT rval = S_OK;
if (!m_isStarted || m_isPaused)
return S_OK;
//DEBUGMSG(ZONE_STORYBOARD | ZONE_VERBOSE, "Storyboard::Update( \"%s\" )", m_name.c_str());
// Update each Animation
for (int i = 0; i < m_numAnimations; ++i)
{
AnimationBinding* pAnimationBinding = &m_pAnimationBindings[i];
DEBUGCHK(pAnimationBinding);
if (pAnimationBinding->m_hasFinished)
continue;
if (FAILED(AnimationMan.Update( pAnimationBinding->m_hAnimation, elapsedMS )))
{
// If an Animation failed to Update, it has probably deleted itself after finishing.
pAnimationBinding->m_hasFinished = true;
m_numFinishedAnimations++;
}
}
// If all Animations are finished, let StoryboardManager know we're done ( and may be stopped / deleted ).
if (m_numFinishedAnimations == m_numAnimations)
{
DEBUGMSG(ZONE_STORYBOARD, "Storyboard::Update( \"%s\" ): END - all Animations done", m_name.c_str());
rval = E_NOTHING_TO_DO;
}
Exit:
return rval;
}
RESULT
Storyboard::BindTo( HGameObject hGameObject ) // TODO: bind to multiple GOs?
{
RESULT rval = S_OK;
DEBUGMSG(ZONE_STORYBOARD, "BIND Storyboard \"%s\" -> GO \"%s\"", m_name.c_str(), hGameObject.GetName().c_str());
if (IsStarted() || IsPaused())
{
StoryboardMan.Stop( this );
}
// Take a reference to the GameObject.
CHR(GOMan.AddRef( hGameObject ));
if (!m_hGameObject.IsNull())
{
CHR(GOMan.Release( m_hGameObject ));
}
m_hGameObject = hGameObject;
// Bind each Animation track to the GameObject.
for (int i = 0; i < m_numAnimations; ++i)
{
AnimationBinding* pAnimationBinding = &m_pAnimationBindings[i];
IProperty* pProperty = hGameObject.GetProperty( pAnimationBinding->m_propertyName ); // TODO: should this NOT allocate a new IProperty? Great LEAK potential!
if (!pProperty)
{
RETAILMSG(ZONE_ERROR, "ERROR: Storyboard::BindTo( \"%s\" ): GameObject \"%s\" [%4d] does not expose Property \"%s\"",
m_name.c_str(), hGameObject.GetName().c_str(), hGameObject.GetID(), pAnimationBinding->m_propertyName.c_str());
//DEBUGCHK(0);
continue;
}
CHR(AnimationMan.BindTo( pAnimationBinding->m_hAnimation, *pProperty ));
pAnimationBinding->m_isBound = true;
SAFE_DELETE(pProperty);
}
m_isBoundToTarget = true;
Exit:
return rval;
}
RESULT
Storyboard::BindTo( HEffect hEffect )
{
RESULT rval = S_OK;
DEBUGMSG(ZONE_STORYBOARD, "BIND Storyboard \"%s\" -> Effect \"%s\"", m_name.c_str(), hEffect.GetName().c_str());
if (IsStarted() || IsPaused())
{
StoryboardMan.Stop( this );
}
// Take a reference to the Effect.
CHR(EffectMan.AddRef( hEffect ));
if (!m_hEffect.IsNull())
{
CHR(EffectMan.Release( m_hEffect ));
}
m_hEffect = hEffect;
// Bind each Animation track to the Effect.
for (int i = 0; i < m_numAnimations; ++i)
{
AnimationBinding* pAnimationBinding = &m_pAnimationBindings[i];
IProperty* pProperty = hEffect.GetProperty( pAnimationBinding->m_propertyName );
if (!pProperty)
{
RETAILMSG(ZONE_ERROR, "ERROR: Storyboard::BindTo( \"%s\" ): Effect \"%s\" [%4d] does not expose Property \"%s\"",
m_name.c_str(), hEffect.GetName().c_str(), hEffect.GetID(), pAnimationBinding->m_propertyName.c_str());
// continue;
rval = E_INVALID_OPERATION;
goto Exit;
}
CHR(AnimationMan.BindTo( pAnimationBinding->m_hAnimation, *pProperty ));
pAnimationBinding->m_isBound = true;
SAFE_DELETE(pProperty);
}
m_isBoundToTarget = true;
Exit:
return rval;
}
RESULT
Storyboard::BindTo( HLayer hLayer )
{
RESULT rval = S_OK;
DEBUGMSG(ZONE_STORYBOARD, "BIND Storyboard \"%s\" -> Layer \"%s\"", m_name.c_str(), hLayer.GetName().c_str());
if (IsStarted() || IsPaused())
{
StoryboardMan.Stop( this );
}
// Take a reference to the Layer.
CHR(LayerMan.AddRef( hLayer ));
if (!m_hLayer.IsNull())
{
CHR(LayerMan.Release( m_hLayer ));
}
m_hLayer = hLayer;
// Bind each Animation track to the Layer.
for (int i = 0; i < m_numAnimations; ++i)
{
AnimationBinding* pAnimationBinding = &m_pAnimationBindings[i];
IProperty* pProperty = hLayer.GetProperty( pAnimationBinding->m_propertyName );
if (!pProperty)
{
RETAILMSG(ZONE_ERROR, "ERROR: Storyboard::BindTo( \"%s\" ): Layer \"%s\" [%4d] does not expose Property \"%s\"",
m_name.c_str(), hLayer.GetName().c_str(), hLayer.GetID(), pAnimationBinding->m_propertyName.c_str());
// continue;
rval = E_INVALID_OPERATION;
goto Exit;
}
CHR(AnimationMan.BindTo( pAnimationBinding->m_hAnimation, *pProperty ));
pAnimationBinding->m_isBound = true;
SAFE_DELETE(pProperty);
}
m_isBoundToTarget = true;
Exit:
return rval;
}
RESULT
Storyboard::BindTo( HSprite hSprite )
{
RESULT rval = S_OK;
DEBUGMSG(ZONE_STORYBOARD, "BIND Storyboard \"%s\" -> Sprite \"%s\"", m_name.c_str(), hSprite.GetName().c_str());
if (IsStarted() || IsPaused())
{
StoryboardMan.Stop( this );
}
// Take a reference to the Sprite.
CHR(SpriteMan.AddRef( hSprite ));
if (!m_hSprite.IsNull())
{
CHR(SpriteMan.Release( m_hSprite ));
}
m_hSprite = hSprite;
// Bind each Animation track to the Sprite.
for (int i = 0; i < m_numAnimations; ++i)
{
AnimationBinding* pAnimationBinding = &m_pAnimationBindings[i];
IProperty* pProperty = hSprite.GetProperty( pAnimationBinding->m_propertyName );
if (!pProperty)
{
RETAILMSG(ZONE_ERROR, "ERROR: Storyboard::BindTo( \"%s\" ): Sprite \"%s\" [%4d] does not expose Property \"%s\"",
m_name.c_str(), hSprite.GetName().c_str(), hSprite.GetID(), pAnimationBinding->m_propertyName.c_str());
// continue;
rval = E_INVALID_OPERATION;
goto Exit;
}
CHR(AnimationMan.BindTo( pAnimationBinding->m_hAnimation, *pProperty ));
pAnimationBinding->m_isBound = true;
SAFE_DELETE(pProperty);
}
m_isBoundToTarget = true;
Exit:
return rval;
}
RESULT
Storyboard::BindTo( HParticleEmitter hParticleEmitter )
{
RESULT rval = S_OK;
if (hParticleEmitter.IsNull() || hParticleEmitter.IsDangling() || hParticleEmitter.IsDeleted())
{
return E_BAD_HANDLE;
}
DEBUGMSG(ZONE_STORYBOARD, "BIND Storyboard \"%s\" -> ParticleEmitter \"%s\"", m_name.c_str(), hParticleEmitter.GetName().c_str());
if (IsStarted() || IsPaused())
{
StoryboardMan.Stop( this );
}
// Take a reference to the Emitter.
CHR(ParticleMan.AddRef( hParticleEmitter ));
if (!m_hParticleEmitter.IsNull())
{
CHR(ParticleMan.Release( m_hParticleEmitter ));
}
m_hParticleEmitter = hParticleEmitter;
// Bind each Animation track to the ParticleEmitter.
for (int i = 0; i < m_numAnimations; ++i)
{
AnimationBinding* pAnimationBinding = &m_pAnimationBindings[i];
IProperty* pProperty = hParticleEmitter.GetProperty( pAnimationBinding->m_propertyName );
if (!pProperty)
{
RETAILMSG(ZONE_ERROR, "ERROR: Storyboard::BindTo( \"%s\" ): ParticleEmitter \"%s\" [%4d] does not expose Property \"%s\"",
m_name.c_str(), hParticleEmitter.GetName().c_str(), hParticleEmitter.GetID(), pAnimationBinding->m_propertyName.c_str());
// continue;
rval = E_INVALID_OPERATION;
goto Exit;
}
CHR(AnimationMan.BindTo( pAnimationBinding->m_hAnimation, *pProperty ));
pAnimationBinding->m_isBound = true;
SAFE_DELETE(pProperty);
}
m_isBoundToTarget = true;
Exit:
return rval;
}
RESULT
Storyboard::BindTo( IProperty* pProperty )
{
RESULT rval = S_OK;
AnimationBinding* pAnimationBinding = &m_pAnimationBindings[0];
if (!pProperty)
{
RETAILMSG(ZONE_ERROR, "ERROR: Storyboard::BindTo(): pProperty is NULL.");
DEBUGCHK(0);
rval = E_NULL_POINTER;
goto Exit;
}
if (m_numAnimations > 1)
{
RETAILMSG(ZONE_ERROR, "ERROR: Storyboard::BindTo( IProperty ): Storyboard has more than one Animation, which to choose?.");
DEBUGCHK(0);
rval = E_INVALID_OPERATION;
goto Exit;
}
DEBUGMSG(ZONE_STORYBOARD, "BIND Storyboard \"%s\" -> IProperty \"%s\"", m_name.c_str(), pAnimationBinding->m_propertyName.c_str());
if (IsStarted() || IsPaused())
{
StoryboardMan.Stop( this );
}
CHR(AnimationMan.BindTo( pAnimationBinding->m_hAnimation, *pProperty ));
pAnimationBinding->m_isBound = true;
m_isBoundToTarget = true;
Exit:
return rval;
}
RESULT
Storyboard::BindTo( Object* pObject )
{
RESULT rval = S_OK;
if (!pObject)
{
RETAILMSG(ZONE_ERROR, "ERROR: Storyboard::BindTo(): pObject is NULL.");
DEBUGCHK(0);
rval = E_NULL_POINTER;
goto Exit;
}
DEBUGMSG(ZONE_STORYBOARD, "BIND Storyboard \"%s\" -> Object \"%s\"", m_name.c_str(), pObject->GetName().c_str());
if (IsStarted() || IsPaused())
{
StoryboardMan.Stop( this );
}
pObject->AddRef();
if (m_pObject)
{
m_pObject->Release();
}
m_pObject = pObject;
// Bind each Animation track to the Object.
for (int i = 0; i < m_numAnimations; ++i)
{
AnimationBinding* pAnimationBinding = &m_pAnimationBindings[i];
IProperty* pProperty = m_pObject->GetProperty( pAnimationBinding->m_propertyName );
if (!pProperty)
{
RETAILMSG(ZONE_ERROR, "ERROR: Storyboard::BindTo( \"%s\" ): Object \"%s\" [%4d] does not expose Property \"%s\"",
m_name.c_str(), m_pObject->GetName().c_str(), m_pObject->GetID(), pAnimationBinding->m_propertyName.c_str());
// continue;
rval = E_INVALID_OPERATION;
goto Exit;
}
CHR(AnimationMan.BindTo( pAnimationBinding->m_hAnimation, *pProperty ));
pAnimationBinding->m_isBound = true;
SAFE_DELETE(pProperty);
}
m_isBoundToTarget = true;
Exit:
return rval;
}
RESULT
Storyboard::UnBind( )
{
RESULT rval = S_OK;
if (!m_isBoundToTarget)
return S_OK;
// Un-bind each Animation track from the target.
// Decrements the refcount once for each Animation.
for (int i = 0; i < m_numAnimations; ++i)
{
AnimationBinding* pAnimationBinding = &m_pAnimationBindings[i];
IGNOREHR(AnimationMan.BindTo( pAnimationBinding->m_hAnimation, NULL ));
pAnimationBinding->m_isBound = false;
}
//
// Release the target object.
//
SAFE_RELEASE(m_pObject);
GOMan.Release ( m_hGameObject ); m_hGameObject = HGameObject::NullHandle();
EffectMan.Release ( m_hEffect ); m_hEffect = HEffect::NullHandle();
LayerMan.Release ( m_hLayer ); m_hLayer = HLayer::NullHandle();
SpriteMan.Release ( m_hSprite ); m_hSprite = HSprite::NullHandle();
ParticleMan.Release ( m_hParticleEmitter ); m_hParticleEmitter = HParticleEmitter::NullHandle();
Exit:
m_isBoundToTarget = false;
return rval;
}
RESULT
Storyboard::CallbackOnFinished( const ICallback& callback )
{
RESULT rval = S_OK;
if (callback.IsNull())
{
RETAILMSG(ZONE_ERROR, "ERROR: Storyboard::CallbackOnFinished( \"%s\", 0x%x ): Callback is NULL",
m_name.c_str(), (UINT32)&callback);
SAFE_DELETE(m_pCallbackOnFinished);
rval = E_INVALID_ARG;
goto Exit;
}
SAFE_DELETE(m_pCallbackOnFinished);
m_pCallbackOnFinished = callback.Clone();
Exit:
return rval;
}
RESULT
Storyboard::Start( )
{
RESULT rval = S_OK;
DEBUGMSG(ZONE_STORYBOARD, "START Storyboard \"%s\"", m_name.c_str());
m_isStarted = true;
m_isPaused = false;
m_numFinishedAnimations = 0;
// Start each Animation
for (int i = 0; i < m_numAnimations; ++i)
{
AnimationBinding* pAnimation = &m_pAnimationBindings[i];
DEBUGCHK(pAnimation);
pAnimation->m_hasFinished = false;
CHR(AnimationMan.Start( pAnimation->m_hAnimation ));
}
Exit:
return rval;
}
RESULT
Storyboard::Stop( )
{
RESULT rval = S_OK;
DEBUGMSG(ZONE_STORYBOARD, "STOP Storyboard \"%s\"", m_name.c_str());
if (!m_isStarted && !m_isPaused)
{
RETAILMSG(ZONE_WARN, "WARNING: Storyboard \"%s\" already stopped.", m_name.c_str());
return E_INVALID_OPERATION;
}
m_isStarted = false;
m_isPaused = false;
m_numFinishedAnimations = 0;
// Stop each Animation
for (int i = 0; i < m_numAnimations; ++i)
{
AnimationBinding* pTarget = &m_pAnimationBindings[i];
DEBUGCHK(pTarget);
IGNOREHR(AnimationMan.Stop( pTarget->m_hAnimation ));
}
if (m_releaseTargetOnFinish)
{
CHR(UnBind());
}
if (m_pCallbackOnFinished)
{
m_pCallbackOnFinished->Invoke();
}
if (m_deleteOnFinish && m_refCount > 0)
{
DEBUGMSG(ZONE_STORYBOARD, "Storyboard::Stop(): \"%s\" DELETE on finish.", m_name.c_str());
StoryboardMan.ReleaseOnNextFrame( this );
}
Exit:
return rval;
}
RESULT
Storyboard::Pause( )
{
RESULT rval = S_OK;
if (!m_isStarted)
return E_INVALID_OPERATION;
DEBUGMSG(ZONE_STORYBOARD, "PAUSE Storyboard \"%s\"", m_name.c_str());
m_isPaused = false;
// Pause each Animation
for (int i = 0; i < m_numAnimations; ++i)
{
AnimationBinding* pTarget = &m_pAnimationBindings[i];
DEBUGCHK(pTarget);
CHR(AnimationMan.Pause( pTarget->m_hAnimation ));
}
Exit:
return rval;
}
RESULT
Storyboard::CreateAnimationBinding( IN const string& animationName, INOUT AnimationBinding* pAnimationBinding )
{
RESULT rval = S_OK;
HAnimation hAnimation;
if ("" == animationName || !pAnimationBinding)
{
RETAILMSG(ZONE_ERROR, "ERROR: Storyboard::CreateAnimationBinding(): invalid arg");
rval = E_INVALID_ARG;
goto Exit;
}
//
// Get handle to the Animation
//
CHR(AnimationMan.GetCopy( animationName, &hAnimation ));
pAnimationBinding->m_hAnimation = hAnimation;
pAnimationBinding->m_animationName = animationName;
pAnimationBinding->m_propertyType = AnimationMan.GetPropertyType( hAnimation );
pAnimationBinding->m_propertyName = AnimationMan.GetPropertyName( hAnimation );
Exit:
if (FAILED(rval))
RETAILMSG(ZONE_ERROR, "ERROR: Storyboard::CreateAnimationBinding() failed.");
return rval;
}
/*
const StoryboardInfo&
Storyboard::GetInfo()
{
StoryboardInfo info;
return info;
}
*/
} // END namespace Z
| 27.862827 | 197 | 0.602202 | [
"object"
] |
1b6540083926da3d681cbf403741848241a999a7 | 9,535 | cpp | C++ | code/src/Wrapper/WrapperManager.cpp | salmanahmedshaikh/streamOLAPOptimization | 0a352bbd6e364865013452d30d2654e33b627e69 | [
"Apache-2.0"
] | 1 | 2021-04-15T11:42:52.000Z | 2021-04-15T11:42:52.000Z | code/src/Wrapper/WrapperManager.cpp | salmanahmedshaikh/streamOLAPOptimization | 0a352bbd6e364865013452d30d2654e33b627e69 | [
"Apache-2.0"
] | null | null | null | code/src/Wrapper/WrapperManager.cpp | salmanahmedshaikh/streamOLAPOptimization | 0a352bbd6e364865013452d30d2654e33b627e69 | [
"Apache-2.0"
] | 1 | 2019-08-25T05:46:20.000Z | 2019-08-25T05:46:20.000Z | //////////////////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2017 KDE Laboratory, University of Tsukuba, Tsukuba, Japan. //
// //
// The JsSpinnerSPE/StreamingCube and the accompanying materials are made available //
// under the terms of Eclipse Public License v1.0 which accompanies this distribution //
// and is available at <https://eclipse.org/org/documents/epl-v10.php> //
//////////////////////////////////////////////////////////////////////////////////////////
#include "../Common/stdafx.h"
#include "../Wrapper/WrapperManager.h"
#include "../Configure/ConfigureManager.h"
#include "../Common/Types.h"
#include "../BinaryJson/json.h"
#include "../Schema/JsonSchema.h"
#include "../Server/JsonStreamServer.h"
#include "../IO/RandomGeneratedStreamInput.h"
#include "../IO/SocketStreamInput.h"
#include "../IO/TwitterStreamInput.h"
#include "../Query/QueryManager.h"
#include "../IO/PeopleFlowStreamInput.h"
#include "../IO/TokyoPeopleFlowStreamInput.h"
#include "../IO/TokyoPeopleFlowStreamInputShort.h"
#include "../IO/RssStreamInput.h"
#include "../IO/SpecifiedInputRateStreamInput.h"
#include <boost/filesystem/operations.hpp>
#include <boost/filesystem/path.hpp>
#include <iostream>
#include <sstream>
#include <string>
#include <strstream>
WrapperManager* WrapperManager::wrapperManager = NULL;
WrapperManager::WrapperManager(void)
{
initial();
}
WrapperManager::~WrapperManager(void)
{
}
WrapperManager * WrapperManager::getInstance()
{
if(wrapperManager==NULL)
{
wrapperManager = new WrapperManager();
}
return wrapperManager;
}
void WrapperManager::initial()
{
//get the wrapper folder path from the configure file
std::string wrapperFolder = ConfigureManager::getInstance()->getConfigureValue(WRAPPER_FOLDER);
boost::filesystem::path wrapperFolderFullPath( boost::filesystem::initial_path() );
wrapperFolderFullPath = boost::filesystem::system_complete( boost::filesystem::path( wrapperFolder ) );
assert ( boost::filesystem::exists( wrapperFolderFullPath ) );
assert ( boost::filesystem::is_directory( wrapperFolderFullPath ) );
boost::filesystem::directory_iterator end_iter;
//scan the folder and get each wrapper file
for ( boost::filesystem::directory_iterator dir_itr( wrapperFolderFullPath );dir_itr != end_iter; ++dir_itr )
{
assert ( boost::filesystem::is_regular_file( *dir_itr ) );
boost::filesystem::path wrapperFilePath= dir_itr->path();
//wrapper file path
std::string wrapperFileFullPath = wrapperFilePath.string();
std::string extensionFilename = wrapperFileFullPath.substr(wrapperFileFullPath.find_last_of(".")+1);
if(extensionFilename != "txt")
{
continue;
}
//open the file and explain it
readWrapperFile(wrapperFileFullPath);
}
}
void WrapperManager::readWrapperFile(std::string filePath)
{
std::ifstream fin(filePath.c_str());
std::stringstream in;// << fin.rdbuf();
in << fin.rdbuf() ;
std::string wrapperDocumentString = in.str();
//std::cout<< "new wrapper starts:: " << wrapperDocumentString<<std::endl;
Document wrapperDocuemnt = fromjson(wrapperDocumentString);
registerWrapper(wrapperDocuemnt);
}
bool WrapperManager::registerWrapper(Document& wrapperDocument)
{
std::string implementClass = wrapperDocument.getField(IMPLEMENT_CLASS).valuestr();
Document argumentDocument = wrapperDocument.getField(CLASS_ARGUMENT).embeddedObject();
Document schemaDocument = wrapperDocument.getField(INFORMATION_SOURCE_SCHEMA).embeddedObject();
boost::shared_ptr<JsonSchema>jsonSchema(new JsonSchema(schemaDocument));
if(implementClass == "RandomGeneratedStreamInput")
{
boost::shared_ptr<IStreamInput> streamInput (new RandomGeneratedStreamInput(jsonSchema));
QueryManager::getInstance()->registerStream(streamInput);
}
else if(implementClass == "SpecifiedInputRateStreamInput")
{
boost::shared_ptr<IStreamInput> streamInput (new SpecifiedInputRateStreamInput(jsonSchema));
QueryManager::getInstance()->registerStream(streamInput);
}
else if(implementClass == "LogStreamInput")
{
std::string ip = argumentDocument.getField(IP).valuestr();
std::string port = argumentDocument.getField(PORT).valuestr();
boost::shared_ptr<IStreamInput> streamInput(new SocketStreamInput(ip,port,jsonSchema));
QueryManager::getInstance()->registerStream(streamInput);
}
else if(implementClass == "ConnectionStreamInput")
{
std::string ip = argumentDocument.getField(IP).valuestr();
std::string port = argumentDocument.getField(PORT).valuestr();
boost::shared_ptr<IStreamInput> streamInput(new SocketStreamInput(ip,port,jsonSchema));
QueryManager::getInstance()->registerStream(streamInput);
}
else if(implementClass == "SocketStreamInput")
{
std::string ip = argumentDocument.getField(IP).valuestr();
std::string port = argumentDocument.getField(PORT).valuestr();
boost::shared_ptr<IStreamInput> streamInput(new SocketStreamInput(ip,port,jsonSchema));
QueryManager::getInstance()->registerStream(streamInput);
}
else if(implementClass == "TwitterStreamInput")
{
std::string userName = argumentDocument.getField(USER_NAME).valuestr();
std::string userPassword = argumentDocument.getField(USER_PASSWORD).valuestr();
boost::shared_ptr<IStreamInput> streamInput(new TwitterStreamInput(userName,userPassword,jsonSchema));
QueryManager::getInstance()->registerStream(streamInput);
}
else if(implementClass == "RssStreamInput")
{
Document urlArrayDocument = argumentDocument.getField(URL_ARRAY).embeddedObject();
Document encodingArrayDocument = argumentDocument.getField(CORRESPONDING_ENCODING_ARRAY).embeddedObject();
std::vector<std::string> urlVector;
std::vector<std::string> encodingVector;
DocumentIterator it(urlArrayDocument);
while(it.more())
{
DocumentElement documentElement = it.next();
std::string url = documentElement.valuestr();
urlVector.push_back(url);
}
DocumentIterator it2(encodingArrayDocument);
while(it2.more())
{
DocumentElement documentElement = it2.next();
std::string url = documentElement.valuestr();
encodingVector.push_back(url);
}
boost::shared_ptr<IStreamInput> streamInput(new RssStreamInput(urlVector,encodingVector,jsonSchema));
QueryManager::getInstance()->registerStream(streamInput);
}
else if(implementClass == "PeopleFlowStreamInput")
{
Document dataFolderDocument = argumentDocument.getField(DATA_FOLDER).embeddedObject();
std::vector<std::string> dataFolderVector;
DocumentIterator it(dataFolderDocument);
while(it.more())
{
DocumentElement documentElement = it.next();
std::string folder = documentElement.valuestr();
dataFolderVector.push_back(folder);
}
boost::shared_ptr<IStreamInput> streamInput(new PeopleFlowStreamInput(dataFolderVector, jsonSchema));
QueryManager::getInstance()->registerStream(streamInput);
}
else if(implementClass == "TokyoPeopleFlowStreamInput")
{
Document dataFolderDocument = argumentDocument.getField(DATA_FOLDER).embeddedObject();
std::vector<std::string> dataFolderVector;
DocumentIterator it(dataFolderDocument);
while(it.more())
{
DocumentElement documentElement = it.next();
std::string folder = documentElement.valuestr();
dataFolderVector.push_back(folder);
}
// creating an instance of TokyoPeopleFlowStreamInput
boost::shared_ptr<IStreamInput> streamInput(new TokyoPeopleFlowStreamInput(dataFolderVector, jsonSchema));
QueryManager::getInstance()->registerStream(streamInput);
}
else if(implementClass == "TokyoPeopleFlowStreamInput_short")
{
Document dataFolderDocument = argumentDocument.getField(DATA_FOLDER).embeddedObject();
std::vector<std::string> dataFolderVector;
DocumentIterator it(dataFolderDocument);
while(it.more())
{
DocumentElement documentElement = it.next();
std::string folder = documentElement.valuestr();
dataFolderVector.push_back(folder);
}
// creating an instance of TokyoPeopleFlowStreamInput
boost::shared_ptr<IStreamInput> streamInput(new TokyoPeopleFlowStreamInputShort(dataFolderVector, jsonSchema));
QueryManager::getInstance()->registerStream(streamInput);
}
else if (implementClass == "RelationInput")
{
std::string ip = argumentDocument.getField(IP).valuestr();
std::string port = argumentDocument.getField(PORT).valuestr();
std::string userName = argumentDocument.getField(USER_NAME).valuestr();
std::string userPassword = argumentDocument.getField(USER_PASSWORD).valuestr();
std::string databaseName = argumentDocument.getField(DATABASE_NAME).valuestr();
std::string tableName = argumentDocument.getField(TABLE_NAME).valuestr();
boost::shared_ptr<RelationInput> relationInput(new RelationInput(ip, port, userName, userPassword, databaseName, tableName, jsonSchema));
QueryManager::getInstance()->registerRelation(relationInput);
}
else if (implementClass == "CSVInput")
{
std::string ip = argumentDocument.getField(IP).valuestr();
std::string port = argumentDocument.getField(PORT).valuestr();
std::string dataFile = argumentDocument.getField(DATA_FILE).valuestr();
//std::cout << "dataFile " << dataFile << std::endl;
boost::shared_ptr<CSVInput> csvInput(new CSVInput(ip, port, dataFile, jsonSchema));
QueryManager::getInstance()->registerCSV(csvInput);
}
else
{
std::cout<<implementClass<<" wrapper implement class does not exist "<<std::endl;
assert(false);
return false;
}
return true;
}
| 38.447581 | 139 | 0.739696 | [
"vector"
] |
1b6575d60912c3b38c57a5032b799cb5e4fe49ae | 1,942 | cpp | C++ | app/src/uptodatescreen.cpp | DaveeFTW/infinity | 6a4f269f8abcf65696064cad94ba9ac8b845bd74 | [
"MIT"
] | 137 | 2019-11-10T16:12:16.000Z | 2022-03-27T23:32:15.000Z | app/src/uptodatescreen.cpp | DaveeFTW/infinity | 6a4f269f8abcf65696064cad94ba9ac8b845bd74 | [
"MIT"
] | 12 | 2019-11-11T20:37:05.000Z | 2021-11-14T17:18:56.000Z | app/src/uptodatescreen.cpp | DaveeFTW/infinity | 6a4f269f8abcf65696064cad94ba9ac8b845bd74 | [
"MIT"
] | 49 | 2019-11-15T02:37:05.000Z | 2022-03-28T20:04:49.000Z | /*
Copyright (C) 2019, David "Davee" Morgan
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 "uptodatescreen.h"
#include "font2.h"
#include "textrenderer.h"
UptoDateScreen::UptoDateScreen(ViewManager* viewManager)
: PageView(viewManager, "Install/Update Infinity")
, m_latinText(new TextRenderer(new Font("flash0:/font/ltn0.pgf")))
, m_opacity(1.0f)
, m_updateDateScreen("This update is already installed: " INFINITY_VERSION "\n"
"Check https://infinity.lolhax.org for the latest version")
{
}
void UptoDateScreen::setOpacity(float opacity)
{
m_opacity = opacity;
m_latinText->font()->setOpacity(opacity);
}
float UptoDateScreen::opacity(void)
{
return m_opacity;
}
void UptoDateScreen::update(float dt)
{
PageView::update(dt);
}
void UptoDateScreen::render(void)
{
m_latinText->draw(480.f / 2.f, 272.f / 2.f, m_updateDateScreen, TextRenderer::ALIGN_CENTER);
PageView::render();
}
| 32.915254 | 96 | 0.753347 | [
"render"
] |
1b69e9da921a09428e086e566e53985234689ce8 | 4,222 | cpp | C++ | Tests/PerformanceTests/DFNsIntegration/VisualOdometry/OrbFlannRansacDecomposition.cpp | H2020-InFuse/cdff | e55fd48f9a909d0c274c3dfa4fe2704bc5071542 | [
"BSD-2-Clause"
] | 7 | 2019-02-26T15:09:50.000Z | 2021-09-30T07:39:01.000Z | Tests/PerformanceTests/DFNsIntegration/VisualOdometry/OrbFlannRansacDecomposition.cpp | H2020-InFuse/cdff | e55fd48f9a909d0c274c3dfa4fe2704bc5071542 | [
"BSD-2-Clause"
] | null | null | null | Tests/PerformanceTests/DFNsIntegration/VisualOdometry/OrbFlannRansacDecomposition.cpp | H2020-InFuse/cdff | e55fd48f9a909d0c274c3dfa4fe2704bc5071542 | [
"BSD-2-Clause"
] | 1 | 2020-12-06T12:09:05.000Z | 2020-12-06T12:09:05.000Z | /* --------------------------------------------------------------------------
*
* (C) Copyright …
*
* ---------------------------------------------------------------------------
*/
/*!
* @file OrbFlannRansacDecomposition.cpp
* @date 26/03/2018
* @author Alessandro Bianco
*/
/*!
* @addtogroup DFNsTest
*
* Performance Test for the integration of Orb extractor descriptor, Flann matcher, fundamental matrix RANSAC, and essential matrix decomposition
*
*
* @{
*/
/* --------------------------------------------------------------------------
*
* Includes
*
* --------------------------------------------------------------------------
*/
#include "VisualOdometry.hpp"
#include <FeaturesExtraction2D/OrbDetectorDescriptor.hpp>
#include <FeaturesMatching2D/FlannMatcher.hpp>
#include <FundamentalMatrixComputation/FundamentalMatrixRansac.hpp>
#include <CamerasTransformEstimation/EssentialMatrixDecomposition.hpp>
using namespace CDFF::DFN::FeaturesExtraction2D;
using namespace CDFF::DFN::FeaturesMatching2D;
using namespace CDFF::DFN::FundamentalMatrixComputation;
using namespace CDFF::DFN::CamerasTransformEstimation;
const std::string USAGE =
" \n \
This programs requires nine parameters: \n \
(i) the folder path containing the configuration files of each DFN \n \
(ii) the name of the OrbDetectorDescriptor Configuration file \n \
(iii) the name of the Flann Configuration file \n \
(iv) the name of the FundamentalMatrixComputation Configuration file \n \
(v) the name of the CamerasTransformEstimation Configuration file \n \
(vi) the name of the output performance file (that will be containing in the configuration folder) \n \
(vii) the base folder containing the images; \n \
(viii) the file containing the list of images in the format: (time relativeImagePath) on each line (except the first three lines that are ignored); \n \
(ix) the file containing the list of poses in the format: (x y z qx qy qz qw) on each line (except the first three lines that are ignored); \n \
(x) the number of images to process; \n \n \
Example Usage: ./orb_flann_ransac_decomposition ../tests/ConfigurationFiles/DFNsIntegration/VisualOdometry OrbExtractorDescriptor_PerformanceTest_1.yaml \
FlannMatcher_PerformanceTest_1.yaml FundamentalMatrixRansac_PerformanceTest_1.yaml EssentialMatrixDecomposition_PerformanceTest_2.yaml output.txt \
../tests/Data/Images ImagesList.txt PosesList.txt \n \n";
int main(int argc, char** argv)
{
ASSERT(argc >= 11, USAGE);
std::string configurationFolderPath, orbConfigurationFileName, flannConfigurationFileName, fundamentalConfigurationFile, estimatorConfigurationFile, outputFileName;
std::string imageFolderPath, imageListName, poseListName;
unsigned imageLimit;
configurationFolderPath = argv[1];
orbConfigurationFileName = argv[2];
flannConfigurationFileName = argv[3];
fundamentalConfigurationFile = argv[4];
estimatorConfigurationFile = argv[5];
outputFileName = argv[6];
imageFolderPath = argv[7];
imageListName = argv[8];
poseListName = argv[9];
try
{
imageLimit = std::stoi(argv[10]);
}
catch (...)
{
ASSERT(false, "the 10th parameter has to be a positive integer number");
}
std::vector<std::string> baseConfigurationFiles;
baseConfigurationFiles.push_back(orbConfigurationFileName);
baseConfigurationFiles.push_back(flannConfigurationFileName);
baseConfigurationFiles.push_back(fundamentalConfigurationFile);
baseConfigurationFiles.push_back(estimatorConfigurationFile);
VisualOdometry* interface = new VisualOdometry(configurationFolderPath, baseConfigurationFiles, outputFileName);
OrbDetectorDescriptor* orb = new OrbDetectorDescriptor();
FlannMatcher* flann = new FlannMatcher();
FundamentalMatrixRansac* ransac = new FundamentalMatrixRansac();
EssentialMatrixDecomposition* essential = new EssentialMatrixDecomposition();
interface->SetDfns(orb, NULL, flann, ransac, essential);
interface->SetInputFiles(imageFolderPath, (imageFolderPath+"/"+imageListName), (imageFolderPath+"/"+poseListName));
interface->LoadInputFiles();
interface->SetImageLimit(imageLimit);
interface->Run();
delete(interface);
delete(orb);
delete(flann);
delete(ransac);
delete(essential);
}
/** @} */
| 37.696429 | 165 | 0.721696 | [
"vector"
] |
1b76cbc289633f1555a67148619600136f2bdc26 | 14,180 | cpp | C++ | src/drivers/qurt/fc_addon/uart_esc/uart_esc_main.cpp | StrangeChen/Firmware | 1bef35d843cf423746347ac77fd4636410b9b7b7 | [
"BSD-3-Clause"
] | 8 | 2017-12-02T15:00:44.000Z | 2022-03-29T15:09:12.000Z | src/drivers/qurt/fc_addon/uart_esc/uart_esc_main.cpp | StrangeChen/Firmware | 1bef35d843cf423746347ac77fd4636410b9b7b7 | [
"BSD-3-Clause"
] | null | null | null | src/drivers/qurt/fc_addon/uart_esc/uart_esc_main.cpp | StrangeChen/Firmware | 1bef35d843cf423746347ac77fd4636410b9b7b7 | [
"BSD-3-Clause"
] | 10 | 2019-04-02T09:06:30.000Z | 2021-06-23T15:52:33.000Z | /****************************************************************************
*
* Copyright (c) 2015 Mark Charlebois. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 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. Neither the name PX4 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.
*
****************************************************************************/
#include <stdint.h>
#include <px4_platform_common/tasks.h>
#include <px4_platform_common/getopt.h>
#include <px4_platform_common/posix.h>
#include <errno.h>
#include <uORB/uORB.h>
#include <uORB/topics/actuator_controls.h>
#include <uORB/topics/actuator_armed.h>
#include <uORB/topics/actuator_outputs.h>
#include <uORB/topics/parameter_update.h>
#include <drivers/drv_hrt.h>
#include <drivers/drv_mixer.h>
#include <lib/mixer/mixer.h>
#include <lib/mixer/mixer_multirotor_normalized.generated.h>
#include <parameters/param.h>
#ifdef __cplusplus
extern "C" {
#endif
#include <uart_esc.h>
#ifdef __cplusplus
}
#endif
/** driver 'main' command */
extern "C" { __EXPORT int uart_esc_main(int argc, char *argv[]); }
#define MAX_LEN_DEV_PATH 32
namespace uart_esc
{
#define UART_ESC_MAX_MOTORS 4
volatile bool _task_should_exit = false; // flag indicating if uart_esc task should exit
static char _device[MAX_LEN_DEV_PATH];
static bool _is_running = false; // flag indicating if uart_esc app is running
static px4_task_t _task_handle = -1; // handle to the task main thread
UartEsc *esc; // esc instance
void uart_esc_rotate_motors(int16_t *motor_rpm, int num_rotors); // motor re-mapping
// subscriptions
int _controls_sub;
int _armed_sub;
int _param_sub;
// filenames
// /dev/fs/ is mapped to /usr/share/data/adsp/
static const char *MIXER_FILENAME = "/dev/fs/mixer_config.mix";
// publications
orb_advert_t _outputs_pub;
// topic structures
actuator_controls_s _controls;
actuator_armed_s _armed;
parameter_update_s _param_update;
actuator_outputs_s _outputs;
/** Print out the usage information */
static void usage();
/** uart_esc start */
static void start(const char *device) __attribute__((unused));
/** uart_esc stop */
static void stop();
/** task main trampoline function */
static void task_main_trampoline(int argc, char *argv[]);
/** uart_esc thread primary entry point */
static void task_main(int argc, char *argv[]);
/** mixer initialization */
static MultirotorMixer *mixer;
static int initialize_mixer(const char *mixer_filename);
static int mixer_control_callback(uintptr_t handle, uint8_t control_group, uint8_t control_index, float &input);
static void parameters_init();
static void parameters_update();
struct {
int model;
int baudrate;
int px4_motor_mapping[UART_ESC_MAX_MOTORS];
} _parameters;
struct {
param_t model;
param_t baudrate;
param_t px4_motor_mapping[UART_ESC_MAX_MOTORS];
} _parameter_handles;
void parameters_init()
{
_parameter_handles.model = param_find("UART_ESC_MODEL");
_parameter_handles.baudrate = param_find("UART_ESC_BAUD");
/* PX4 motor mapping parameters */
for (unsigned int i = 0; i < UART_ESC_MAX_MOTORS; i++) {
char nbuf[20];
/* min values */
sprintf(nbuf, "UART_ESC_MOTOR%d", i + 1);
_parameter_handles.px4_motor_mapping[i] = param_find(nbuf);
}
parameters_update();
}
void parameters_update()
{
PX4_WARN("uart_esc_main parameters_update");
int32_t v_int;
if (param_get(_parameter_handles.model, &v_int) == 0) {
_parameters.model = v_int;
PX4_WARN("UART_ESC_MODEL %d", _parameters.model);
}
if (param_get(_parameter_handles.baudrate, &v_int) == 0) {
_parameters.baudrate = v_int;
PX4_WARN("UART_ESC_BAUD %d", _parameters.baudrate);
}
for (unsigned int i = 0; i < UART_ESC_MAX_MOTORS; i++) {
if (param_get(_parameter_handles.px4_motor_mapping[i], &v_int) == 0) {
_parameters.px4_motor_mapping[i] = v_int;
PX4_WARN("UART_ESC_MOTOR%d %d", i + 1, _parameters.px4_motor_mapping[i]);
}
}
}
int mixer_control_callback(uintptr_t handle,
uint8_t control_group,
uint8_t control_index,
float &input)
{
const actuator_controls_s *controls = (actuator_controls_s *)handle;
input = controls[control_group].control[control_index];
/* motor spinup phase - lock throttle to zero *
if (_pwm_limit.state == PWM_LIMIT_STATE_RAMP) {
if (control_group == actuator_controls_s::GROUP_INDEX_ATTITUDE &&
control_index == actuator_controls_s::INDEX_THROTTLE) {
* limit the throttle output to zero during motor spinup,
* as the motors cannot follow any demand yet
*
input = 0.0f;
}
}
*/
return 0;
}
int initialize_mixer(const char *mixer_filename)
{
mixer = nullptr;
int mixer_initialized = -1;
char buf[2048];
unsigned int buflen = sizeof(buf);
PX4_INFO("Initializing mixer from config file in %s", mixer_filename);
int fd_load = open(mixer_filename, O_RDONLY);
if (fd_load != -1) {
int nRead = read(fd_load, buf, buflen);
close(fd_load);
if (nRead > 0) {
mixer = MultirotorMixer::from_text(mixer_control_callback, (uintptr_t)&_controls, buf, buflen);
if (mixer != nullptr) {
PX4_INFO("Successfully initialized mixer from config file");
mixer_initialized = 0;
} else {
PX4_WARN("Unable to parse from mixer config file");
}
} else {
PX4_WARN("Unable to read from mixer config file");
}
} else {
PX4_WARN("Unable to open mixer config file");
}
// mixer file loading failed, fall back to default mixer configuration for
// QUAD_X airframe
if (mixer_initialized < 0) {
float roll_scale = 1;
float pitch_scale = 1;
float yaw_scale = 1;
float deadband = 0;
mixer = new MultirotorMixer(mixer_control_callback, (uintptr_t)&_controls,
MultirotorGeometry::QUAD_X,
roll_scale, pitch_scale, yaw_scale, deadband);
if (mixer == nullptr) {
PX4_ERR("mixer initialization failed");
mixer_initialized = -1;
return mixer_initialized;
}
PX4_WARN("mixer config file not found, successfully initialized default quad x mixer");
mixer_initialized = 0;
}
return mixer_initialized;
}
/**
* Rotate the motor rpm values based on the motor mappings configuration stored
* in motor_mapping
*/
void uart_esc_rotate_motors(int16_t *motor_rpm, int num_rotors)
{
ASSERT(num_rotors <= UART_ESC_MAX_MOTORS);
int i;
int16_t motor_rpm_copy[UART_ESC_MAX_MOTORS];
for (i = 0; i < num_rotors; i++) {
motor_rpm_copy[i] = motor_rpm[i];
}
for (i = 0; i < num_rotors; i++) {
motor_rpm[_parameters.px4_motor_mapping[i] - 1] = motor_rpm_copy[i];
}
}
void task_main(int argc, char *argv[])
{
PX4_INFO("enter uart_esc task_main");
_outputs_pub = nullptr;
parameters_init();
esc = UartEsc::get_instance();
if (esc == NULL) {
PX4_ERR("failed to new UartEsc instance");
} else if (esc->initialize((enum esc_model_t)_parameters.model,
_device, _parameters.baudrate) < 0) {
PX4_ERR("failed to initialize UartEsc");
} else {
// Subscribe for orb topics
_controls_sub = orb_subscribe(ORB_ID(actuator_controls_0)); // single group for now
_armed_sub = orb_subscribe(ORB_ID(actuator_armed));
_param_sub = orb_subscribe(ORB_ID(parameter_update));
// initialize publication structures
memset(&_outputs, 0, sizeof(_outputs));
// set up poll topic and limit poll interval
px4_pollfd_struct_t fds[1];
fds[0].fd = _controls_sub;
fds[0].events = POLLIN;
//orb_set_interval(_controls_sub, 10); // max actuator update period, ms
// set up mixer
if (initialize_mixer(MIXER_FILENAME) < 0) {
PX4_ERR("Mixer initialization failed.");
_task_should_exit = true;
}
// Main loop
while (!_task_should_exit) {
int pret = px4_poll(&fds[0], (sizeof(fds) / sizeof(fds[0])), 100);
/* timed out - periodic check for _task_should_exit */
if (pret == 0) {
continue;
}
/* this is undesirable but not much we can do - might want to flag unhappy status */
if (pret < 0) {
PX4_WARN("poll error %d, %d", pret, errno);
/* sleep a bit before next try */
usleep(100000);
continue;
}
// Handle new actuator controls data
if (fds[0].revents & POLLIN) {
// Grab new controls data
orb_copy(ORB_ID(actuator_controls_0), _controls_sub, &_controls);
// Mix to the outputs
_outputs.timestamp = hrt_absolute_time();
int16_t motor_rpms[UART_ESC_MAX_MOTORS];
if (_armed.armed && !_armed.lockdown && !_armed.manual_lockdown) {
_outputs.noutputs = mixer->mix(&_outputs.output[0], actuator_controls_s::NUM_ACTUATOR_CONTROLS);
// Make sure we support only up to UART_ESC_MAX_MOTORS motors
if (_outputs.noutputs > UART_ESC_MAX_MOTORS) {
PX4_ERR("Unsupported motors %d, up to %d motors supported",
_outputs.noutputs, UART_ESC_MAX_MOTORS);
continue;
}
// Send outputs to the ESCs
for (unsigned outIdx = 0; outIdx < _outputs.noutputs; outIdx++) {
// map -1.0 - 1.0 outputs to RPMs
motor_rpms[outIdx] = (int16_t)(((_outputs.output[outIdx] + 1.0) / 2.0) *
(esc->max_rpm() - esc->min_rpm()) + esc->min_rpm());
}
uart_esc_rotate_motors(motor_rpms, _outputs.noutputs);
} else {
_outputs.noutputs = UART_ESC_MAX_MOTORS;
for (unsigned outIdx = 0; outIdx < _outputs.noutputs; outIdx++) {
motor_rpms[outIdx] = 0;
_outputs.output[outIdx] = -1.0;
}
}
esc->send_rpms(&motor_rpms[0], _outputs.noutputs);
// TODO-JYW: TESTING-TESTING
// MAINTAIN FOR REFERENCE, COMMENT OUT FOR RELEASE BUILDS
// static int count=0;
// count++;
// if (!(count % 100)) {
// PX4_DEBUG(" ");
// PX4_DEBUG("Time t: %13lu, Armed: %d ",(unsigned long)_outputs.timestamp,_armed.armed);
// PX4_DEBUG("Act Controls: 0: %+8.4f, 1: %+8.4f, 2: %+8.4f, 3: %+8.4f ",_controls.control[0],_controls.control[1],_controls.control[2],_controls.control[3]);
// PX4_DEBUG("Act Outputs : 0: %+8.4f, 1: %+8.4f, 2: %+8.4f, 3: %+8.4f ",_outputs.output[0],_outputs.output[1],_outputs.output[2],_outputs.output[3]);
// }
// TODO-JYW: TESTING-TESTING
/* Publish mixed control outputs */
if (_outputs_pub != nullptr) {
orb_publish(ORB_ID(actuator_outputs), _outputs_pub, &_outputs);
} else {
_outputs_pub = orb_advertise(ORB_ID(actuator_outputs), &_outputs);
}
}
// Check for updates in other subscripions
bool updated = false;
orb_check(_armed_sub, &updated);
if (updated) {
orb_copy(ORB_ID(actuator_armed), _armed_sub, &_armed);
PX4_DEBUG("arming status updated, _armed.armed: %d", _armed.armed);
}
orb_check(_param_sub, &updated);
if (updated) {
// Even though we are only interested in the update status of the parameters, copy
// the subscription to clear the update status.
orb_copy(ORB_ID(parameter_update), _param_sub, &_param_update);
parameters_update();
}
}
}
PX4_WARN("closing uart_esc");
delete esc;
}
/** uart_esc main entrance */
void task_main_trampoline(int argc, char *argv[])
{
PX4_WARN("task_main_trampoline");
task_main(argc, argv);
}
void start()
{
ASSERT(_task_handle == -1);
/* start the task */
_task_handle = px4_task_spawn_cmd("uart_esc_main",
SCHED_DEFAULT,
SCHED_PRIORITY_MAX,
1500,
(px4_main_t)&task_main_trampoline,
nullptr);
if (_task_handle < 0) {
warn("task start failed");
return;
}
_is_running = true;
}
void stop()
{
// TODO - set thread exit signal to terminate the task main thread
_is_running = false;
_task_handle = -1;
}
void usage()
{
PX4_WARN("missing command: try 'start', 'stop', 'status'");
PX4_WARN("options:");
PX4_WARN(" -D device");
}
}; // namespace uart_esc
int uart_esc_main(int argc, char *argv[])
{
const char *device = NULL;
int ch;
int myoptind = 1;
const char *myoptarg = NULL;
while ((ch = px4_getopt(argc, argv, "D:", &myoptind, &myoptarg)) != EOF) {
switch (ch) {
case 'D':
device = myoptarg;
break;
default:
uart_esc::usage();
return 1;
}
}
// Check on required arguments
if (device == NULL || strlen(device) == 0) {
uart_esc::usage();
return 1;
}
memset(uart_esc::_device, 0, MAX_LEN_DEV_PATH);
strncpy(uart_esc::_device, device, strlen(device));
const char *verb = argv[myoptind];
/*
* Start/load the driver.
*/
if (!strcmp(verb, "start")) {
if (uart_esc::_is_running) {
PX4_WARN("uart_esc already running");
return 1;
}
uart_esc::start();
}
else if (!strcmp(verb, "stop")) {
if (uart_esc::_is_running) {
PX4_WARN("uart_esc is not running");
return 1;
}
uart_esc::stop();
}
else if (!strcmp(verb, "status")) {
PX4_WARN("uart_esc is %s", uart_esc::_is_running ? "running" : "stopped");
return 0;
} else {
uart_esc::usage();
return 1;
}
return 0;
}
| 27.164751 | 165 | 0.68378 | [
"model"
] |
1b79d66d38b43e9b4e3f39f8d5db28a9b715cd0c | 17,420 | cxx | C++ | Common/Core/Testing/Cxx/TestArrayLookup.cxx | ciwei100000/vtk7 | 3a6996b27159d4e89979669a93d05e65855ed993 | [
"BSD-3-Clause"
] | 1 | 2021-12-02T07:23:36.000Z | 2021-12-02T07:23:36.000Z | Common/Core/Testing/Cxx/TestArrayLookup.cxx | ciwei100000/vtk7 | 3a6996b27159d4e89979669a93d05e65855ed993 | [
"BSD-3-Clause"
] | null | null | null | Common/Core/Testing/Cxx/TestArrayLookup.cxx | ciwei100000/vtk7 | 3a6996b27159d4e89979669a93d05e65855ed993 | [
"BSD-3-Clause"
] | 1 | 2021-12-02T07:29:15.000Z | 2021-12-02T07:29:15.000Z | /*=========================================================================
Program: Visualization Toolkit
Module: TestArrayLookup.cxx
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include "vtkBitArray.h"
#include "vtkIdList.h"
#include "vtkIdTypeArray.h"
#include "vtkIntArray.h"
#include "vtkSortDataArray.h"
#include "vtkStringArray.h"
#include "vtkTimerLog.h"
#include "vtkVariantArray.h"
#include "vtkSmartPointer.h"
#define VTK_CREATE(type,name) \
vtkSmartPointer<type> name = vtkSmartPointer<type>::New()
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
struct NodeCompare
{
bool operator()(const std::pair<int, vtkIdType>& a, const std::pair<int, vtkIdType>& b) const
{
return a.first < b.first;
}
};
vtkIdType LookupValue(std::multimap<int, vtkIdType>& lookup, int value)
{
std::pair<const int, vtkIdType> found = *lookup.lower_bound(value);
if (found.first == value)
{
return found.second;
}
return -1;
}
vtkIdType LookupValue(std::vector<std::pair<int, vtkIdType> >& lookup, int value)
{
NodeCompare comp;
std::pair<int, vtkIdType> val(value, 0);
std::pair<int, vtkIdType> found =
*std::lower_bound(lookup.begin(), lookup.end(), val, comp);
if (found.first == value)
{
return found.second;
}
return -1;
}
vtkIdType LookupValue(vtkIntArray* lookup, vtkIdTypeArray* index, int value)
{
int* ptr = lookup->GetPointer(0);
vtkIdType place = static_cast<vtkIdType>(std::lower_bound(ptr, ptr + lookup->GetNumberOfTuples(), value) - ptr);
if (place < lookup->GetNumberOfTuples() && ptr[place] == value)
{
return index->GetValue(place);
}
return -1;
}
int TestArrayLookupBit(vtkIdType numVal)
{
int errors = 0;
// Create the array
vtkIdType arrSize = (numVal-1)*numVal/2;
VTK_CREATE(vtkBitArray, arr);
for (vtkIdType i = 0; i < arrSize; i++)
{
arr->InsertNextValue(i < arrSize/2);
}
//
// Test lookup implemented inside data array
//
// Time the lookup creation
VTK_CREATE(vtkTimerLog, timer);
timer->StartTimer();
arr->LookupValue(0);
timer->StopTimer();
cerr << "," << timer->GetElapsedTime();
// Time simple lookup
timer->StartTimer();
for (vtkIdType i = 0; i < numVal; i++)
{
arr->LookupValue(i % 2);
}
timer->StopTimer();
cerr << "," << (timer->GetElapsedTime() / static_cast<double>(numVal));
// Time list lookup
VTK_CREATE(vtkIdList, list);
timer->StartTimer();
for (vtkIdType i = 0; i < numVal; i++)
{
arr->LookupValue(i % 2, list);
}
timer->StopTimer();
cerr << "," << (timer->GetElapsedTime() / static_cast<double>(numVal));
// Test for correctness (-1)
vtkIdType index = -1;
index = arr->LookupValue(-1);
if (index != -1)
{
cerr << "ERROR: lookup found value at " << index << " but is not there (should return -1)" << endl;
errors++;
}
arr->LookupValue(-1, list);
if (list->GetNumberOfIds() != 0)
{
cerr << "ERROR: lookup found " << list->GetNumberOfIds() << " matches but there should be " << 0 << endl;
errors++;
}
// Test for correctness (0)
index = arr->LookupValue(0);
if (index < arrSize/2 || index > arrSize-1)
{
cerr << "ERROR: vector lookup found value at " << index << " but is in range [" << arrSize/2 << "," << arrSize-1 << "]" << endl;
errors++;
}
arr->LookupValue(0, list);
if (list->GetNumberOfIds() != arrSize - arrSize/2)
{
cerr << "ERROR: lookup found " << list->GetNumberOfIds() << " matches but there should be " << arrSize - arrSize/2 << endl;
errors++;
}
else
{
for (vtkIdType j = 0; j < list->GetNumberOfIds(); j++)
{
if (arr->GetValue(list->GetId(j)) != 0)
{
cerr << "ERROR: could not find " << j << " in found list" << endl;
errors++;
}
}
}
// Test for correctness (1)
index = arr->LookupValue(1);
if (index < 0 || index > arrSize/2-1)
{
cerr << "ERROR: vector lookup found value at " << index << " but is in range [" << 0 << "," << arrSize/2-1 << "]" << endl;
errors++;
}
arr->LookupValue(1, list);
if (list->GetNumberOfIds() != arrSize/2)
{
cerr << "ERROR: lookup found " << list->GetNumberOfIds() << " matches but there should be " << arrSize/2 << endl;
errors++;
}
else
{
for (vtkIdType j = 0; j < list->GetNumberOfIds(); j++)
{
if (arr->GetValue(list->GetId(j)) != 1)
{
cerr << "ERROR: could not find " << j << " in found list" << endl;
errors++;
}
}
}
return errors;
}
int TestArrayLookupVariant(vtkIdType numVal)
{
int errors = 0;
// Create the array
vtkIdType arrSize = (numVal-1)*numVal/2;
VTK_CREATE(vtkVariantArray, arr);
for (vtkIdType i = 0; i < numVal; i++)
{
for (vtkIdType j = 0; j < numVal-1-i; j++)
{
arr->InsertNextValue(numVal-1-i);
}
}
//
// Test lookup implemented inside data array
//
// Time the lookup creation
VTK_CREATE(vtkTimerLog, timer);
timer->StartTimer();
arr->LookupValue(0);
timer->StopTimer();
cerr << "," << timer->GetElapsedTime();
// Time simple lookup
timer->StartTimer();
for (vtkIdType i = 0; i < numVal; i++)
{
arr->LookupValue(i);
}
timer->StopTimer();
cerr << "," << (timer->GetElapsedTime() / static_cast<double>(numVal));
// Time list lookup
VTK_CREATE(vtkIdList, list);
timer->StartTimer();
for (vtkIdType i = 0; i < numVal; i++)
{
arr->LookupValue(i, list);
}
timer->StopTimer();
cerr << "," << (timer->GetElapsedTime() / static_cast<double>(numVal));
// Test for correctness
vtkIdType correctIndex = arrSize;
for (vtkIdType i = 0; i < numVal; i++)
{
correctIndex -= i;
vtkIdType index = arr->LookupValue(i);
if (i == 0 && index != -1)
{
cerr << "ERROR: lookup found value at " << index << " but is at -1" << endl;
errors++;
}
if (i != 0 && (index < correctIndex || index > correctIndex + i - 1))
{
cerr << "ERROR: vector lookup found value at " << index << " but is in range [" << correctIndex << "," << correctIndex + i - 1 << "]" << endl;
errors++;
}
arr->LookupValue(i, list);
if (list->GetNumberOfIds() != i)
{
cerr << "ERROR: lookup found " << list->GetNumberOfIds() << " matches but there should be " << i << endl;
errors++;
}
else
{
for (vtkIdType j = correctIndex; j < correctIndex + i; j++)
{
bool inList = false;
for (vtkIdType k = 0; k < i; ++k)
{
if (list->GetId(k) == j)
{
inList = true;
break;
}
}
if (!inList)
{
cerr << "ERROR: could not find " << j << " in found list" << endl;
errors++;
}
}
}
}
return errors;
}
int TestArrayLookupString(vtkIdType numVal)
{
int errors = 0;
// Create the array
vtkIdType arrSize = (numVal-1)*numVal/2;
VTK_CREATE(vtkStringArray, arr);
for (vtkIdType i = 0; i < numVal; i++)
{
for (vtkIdType j = 0; j < numVal-1-i; j++)
{
arr->InsertNextValue(vtkVariant(numVal-1-i).ToString());
}
}
//
// Test lookup implemented inside data array
//
// Time the lookup creation
VTK_CREATE(vtkTimerLog, timer);
timer->StartTimer();
arr->LookupValue("0");
timer->StopTimer();
cerr << "," << timer->GetElapsedTime();
// Time simple lookup
timer->StartTimer();
for (vtkIdType i = 0; i < numVal; i++)
{
arr->LookupValue(vtkVariant(i).ToString());
}
timer->StopTimer();
cerr << "," << (timer->GetElapsedTime() / static_cast<double>(numVal));
// Time list lookup
VTK_CREATE(vtkIdList, list);
timer->StartTimer();
for (vtkIdType i = 0; i < numVal; i++)
{
arr->LookupValue(vtkVariant(i).ToString(), list);
}
timer->StopTimer();
cerr << "," << (timer->GetElapsedTime() / static_cast<double>(numVal));
// Test for correctness
vtkIdType correctIndex = arrSize;
for (vtkIdType i = 0; i < numVal; i++)
{
correctIndex -= i;
vtkIdType index = arr->LookupValue(vtkVariant(i).ToString());
if (i == 0 && index != -1)
{
cerr << "ERROR: lookup found value at " << index << " but is at -1" << endl;
errors++;
}
if (i != 0 && (index < correctIndex || index > correctIndex + i - 1))
{
cerr << "ERROR: vector lookup found value at " << index << " but is in range [" << correctIndex << "," << correctIndex + i - 1 << "]" << endl;
errors++;
}
arr->LookupValue(vtkVariant(i).ToString(), list);
if (list->GetNumberOfIds() != i)
{
cerr << "ERROR: lookup found " << list->GetNumberOfIds() << " matches but there should be " << i << endl;
errors++;
}
else
{
for (vtkIdType j = correctIndex; j < correctIndex + i; j++)
{
bool inList = false;
for (vtkIdType k = 0; k < i; ++k)
{
if (list->GetId(k) == j)
{
inList = true;
break;
}
}
if (!inList)
{
cerr << "ERROR: could not find " << j << " in found list" << endl;
errors++;
}
}
}
}
return errors;
}
int TestArrayLookupInt(vtkIdType numVal, bool runComparison)
{
int errors = 0;
// Create the array
vtkIdType arrSize = (numVal-1)*numVal/2;
VTK_CREATE(vtkIntArray, arr);
for (vtkIdType i = 0; i < numVal; i++)
{
for (vtkIdType j = 0; j < numVal-1-i; j++)
{
arr->InsertNextValue(numVal-1-i);
}
}
//
// Test lookup implemented inside data array
//
// Time the lookup creation
VTK_CREATE(vtkTimerLog, timer);
timer->StartTimer();
arr->LookupValue(0);
timer->StopTimer();
cerr << "," << timer->GetElapsedTime();
// Time simple lookup
timer->StartTimer();
for (vtkIdType i = 0; i < numVal; i++)
{
arr->LookupValue(i);
}
timer->StopTimer();
cerr << "," << (timer->GetElapsedTime() / static_cast<double>(numVal));
// Time list lookup
VTK_CREATE(vtkIdList, list);
timer->StartTimer();
for (vtkIdType i = 0; i < numVal; i++)
{
arr->LookupValue(i, list);
}
timer->StopTimer();
cerr << "," << (timer->GetElapsedTime() / static_cast<double>(numVal));
// Test for correctness
vtkIdType correctIndex = arrSize;
for (vtkIdType i = 0; i < numVal; i++)
{
correctIndex -= i;
vtkIdType index = arr->LookupValue(i);
if (i == 0 && index != -1)
{
cerr << "ERROR: lookup found value at " << index << " but is at -1" << endl;
errors++;
}
if (i != 0 && (index < correctIndex || index > correctIndex + i - 1))
{
cerr << "ERROR: vector lookup found value at " << index << " but is in range [" << correctIndex << "," << correctIndex + i - 1 << "]" << endl;
errors++;
}
arr->LookupValue(i, list);
if (list->GetNumberOfIds() != i)
{
cerr << "ERROR: lookup found " << list->GetNumberOfIds() << " matches but there should be " << i << endl;
errors++;
}
else
{
for (vtkIdType j = correctIndex; j < correctIndex + i; j++)
{
bool inList = false;
for (vtkIdType k = 0; k < i; ++k)
{
if (list->GetId(k) == j)
{
inList = true;
break;
}
}
if (!inList)
{
cerr << "ERROR: could not find " << j << " in found list" << endl;
errors++;
}
}
}
}
if (runComparison)
{
//
// Test STL map lookup
//
// Time the lookup creation
timer->StartTimer();
int* ptr = arr->GetPointer(0);
std::multimap<int, vtkIdType> map;
for (vtkIdType i = 0; i < arrSize; ++i, ++ptr)
{
map.insert(std::pair<const int, vtkIdType>(*ptr, i));
}
timer->StopTimer();
cerr << "," << timer->GetElapsedTime();
// Time simple lookup
timer->StartTimer();
for (vtkIdType i = 0; i < numVal; i++)
{
LookupValue(map, i);
}
timer->StopTimer();
cerr << "," << (timer->GetElapsedTime() / static_cast<double>(numVal));
// Test for correctness
correctIndex = arrSize;
for (vtkIdType i = 0; i < numVal; i++)
{
correctIndex -= i;
vtkIdType index = LookupValue(map, i);
if (i == 0 && index != -1)
{
cerr << "ERROR: lookup found value at " << index << " but is at -1" << endl;
errors++;
}
if (i != 0 && index != correctIndex)
{
cerr << "ERROR: lookup found value at " << index << " but is at " << correctIndex << endl;
errors++;
}
}
//
// Test STL vector lookup
//
// Time lookup creation
timer->StartTimer();
ptr = arr->GetPointer(0);
std::vector<std::pair<int, vtkIdType> > vec(arrSize);
for (vtkIdType i = 0; i < arrSize; ++i, ++ptr)
{
vec[i] = std::pair<int, vtkIdType>(*ptr, i);
}
NodeCompare comp;
std::sort(vec.begin(), vec.end(), comp);
timer->StopTimer();
cerr << "," << timer->GetElapsedTime();
// Time simple lookup
timer->StartTimer();
for (vtkIdType i = 0; i < numVal; i++)
{
LookupValue(vec, i);
}
timer->StopTimer();
cerr << "," << (timer->GetElapsedTime() / static_cast<double>(numVal));
// Test for correctness
correctIndex = arrSize;
for (vtkIdType i = 0; i < numVal; i++)
{
correctIndex -= i;
vtkIdType index = LookupValue(vec, i);
if (i == 0 && index != -1)
{
cerr << "ERROR: vector lookup found value at " << index << " but is at -1" << endl;
errors++;
}
if (i != 0 && (index < correctIndex || index > correctIndex + i - 1))
{
cerr << "ERROR: vector lookup found value at " << index << " but is in range [" << correctIndex << "," << correctIndex + i - 1 << "]" << endl;
errors++;
}
}
//
// Test sorted data array lookup
//
// Time lookup creation
timer->StartTimer();
VTK_CREATE(vtkIdTypeArray, indices);
indices->SetNumberOfTuples(arrSize);
vtkIdType* keyptr = indices->GetPointer(0);
for (vtkIdType i = 0; i < arrSize; ++i, ++keyptr)
{
*keyptr = i;
}
VTK_CREATE(vtkIntArray, sorted);
sorted->DeepCopy(arr);
vtkSortDataArray::Sort(sorted, indices);
timer->StopTimer();
cerr << "," << timer->GetElapsedTime();
// Time simple lookup
timer->StartTimer();
for (vtkIdType i = 0; i < numVal; i++)
{
LookupValue(sorted, indices, i);
}
timer->StopTimer();
cerr << "," << (timer->GetElapsedTime() / static_cast<double>(numVal));
// Test for correctness
correctIndex = arrSize;
for (vtkIdType i = 0; i < numVal; i++)
{
correctIndex -= i;
vtkIdType index = LookupValue(sorted, indices, i);
if (i == 0 && index != -1)
{
cerr << "ERROR: arr lookup found value at " << index << " but is at -1" << endl;
errors++;
}
if (i != 0 && (index < correctIndex || index > correctIndex + i - 1))
{
cerr << "ERROR: arr lookup found value at " << index << " but is in range [" << correctIndex << "," << correctIndex + i - 1 << "]" << endl;
errors++;
}
}
}
return errors;
}
int TestArrayLookup(int argc, char* argv[])
{
vtkIdType min = 100;
vtkIdType max = 200;
int steps = 2;
bool runComparison = false;
for (int i = 0; i < argc; ++i)
{
if (!strcmp(argv[i], "-C"))
{
runComparison = true;
}
if (!strcmp(argv[i], "-m") && i+1 < argc)
{
++i;
int size = atoi(argv[i]);
min = static_cast<int>((-1.0 + sqrt(1 + 8.0*size))/2.0);
}
if (!strcmp(argv[i], "-M") && i+1 < argc)
{
++i;
int size = atoi(argv[i]);
max = static_cast<int>((-1.0 + sqrt(1 + 8.0*size))/2.0);
}
if (!strcmp(argv[i], "-S") && i+1 < argc)
{
++i;
steps = atoi(argv[i]);
}
}
vtkIdType stepSize = (max-min)/(steps-1);
if (stepSize <= 0)
{
stepSize = 1;
}
int errors = 0;
cerr << "distinct values";
cerr << ",size";
cerr << ",create lookup";
cerr << ",index lookup";
cerr << ",list lookup";
if (runComparison)
{
cerr << ",create map lookup";
cerr << ",index map lookup";
cerr << ",create vector lookup";
cerr << ",index vector lookup";
cerr << ",create array lookup";
cerr << ",index array lookup";
}
cerr << ",string create lookup";
cerr << ",string index lookup";
cerr << ",string list lookup";
cerr << ",variant create lookup";
cerr << ",variant index lookup";
cerr << ",variant list lookup";
cerr << ",bit create lookup";
cerr << ",bit index lookup";
cerr << ",bit list lookup";
cerr << endl;
for (vtkIdType numVal = min; numVal <= max; numVal += stepSize)
{
vtkIdType total = numVal*(numVal+1)/2;
cerr << numVal << "," << total;
errors += TestArrayLookupInt(numVal, runComparison);
errors += TestArrayLookupString(numVal);
errors += TestArrayLookupVariant(numVal);
errors += TestArrayLookupBit(numVal);
cerr << endl;
}
return errors;
}
| 26.038864 | 150 | 0.553559 | [
"vector"
] |
1b7c141170bfdbff017c4f30775a3fa9516cb151 | 209 | cpp | C++ | Cpp_primer_5th/code_part10/prog10_34.cpp | Links789/Cpp_primer_5th | 18a60b75c358a79fdf006f8cb978c9be6e6aedd5 | [
"MIT"
] | null | null | null | Cpp_primer_5th/code_part10/prog10_34.cpp | Links789/Cpp_primer_5th | 18a60b75c358a79fdf006f8cb978c9be6e6aedd5 | [
"MIT"
] | null | null | null | Cpp_primer_5th/code_part10/prog10_34.cpp | Links789/Cpp_primer_5th | 18a60b75c358a79fdf006f8cb978c9be6e6aedd5 | [
"MIT"
] | null | null | null | #include <iostream>
#include <vector>
using namespace std;
int main(){
vector<int> vec{1,2,3,4,5,6};
for(auto i = vec.crbegin(); i != vec.crend() ; ++i)
cout << *i << " ";
cout <<endl;
return 0;
}
| 14.928571 | 52 | 0.564593 | [
"vector"
] |
b84766c5fdff4d54d4d7262165004eca604a9ca3 | 8,989 | cpp | C++ | src/transforms/slidingWindowRealDFTParameters.cpp | bakerb845/rtseis | 7d1e9493e68c9d848daa5b5e89239cdfcddaa757 | [
"MIT"
] | 2 | 2021-03-27T17:26:06.000Z | 2022-02-02T16:55:10.000Z | src/transforms/slidingWindowRealDFTParameters.cpp | uofuseismo/rtseis | ee44ea68c22726cf0d24485e205cb91bc15436da | [
"MIT"
] | 1 | 2020-01-08T17:25:07.000Z | 2020-02-24T15:50:21.000Z | src/transforms/slidingWindowRealDFTParameters.cpp | bakerb845/rtseis | 7d1e9493e68c9d848daa5b5e89239cdfcddaa757 | [
"MIT"
] | 2 | 2019-11-19T06:32:35.000Z | 2020-12-11T04:20:38.000Z | #include <iostream>
#include <string>
#include <vector>
#include <cassert>
#include <ipps.h>
#include "rtseis/utilities/windowFunctions.hpp"
#include "rtseis/transforms/slidingWindowRealDFTParameters.hpp"
#include "rtseis/transforms/enums.hpp"
using namespace RTSeis::Transforms;
class SlidingWindowRealDFTParameters::SlidingWindowRealDFTParametersImpl
{
public:
/// Holds the window function
std::vector<double> mWindow;
/// The number of samples in the signal
int mSamples = 0;
/// The length of the DFT
int mDFTLength = 0;
/// The number of samples in the overlap.
int mSamplesInOverlap = 0;
/// Describes the window function
SlidingWindowType mWindowType = SlidingWindowType::BOXCAR;
/// Describes the detrend strategy
SlidingWindowDetrendType mDetrendType = SlidingWindowDetrendType::REMOVE_NONE;
};
/// Constructor
SlidingWindowRealDFTParameters::SlidingWindowRealDFTParameters() :
pImpl(std::make_unique<SlidingWindowRealDFTParametersImpl> ())
{
}
/// Copy constructor
SlidingWindowRealDFTParameters::SlidingWindowRealDFTParameters(
const SlidingWindowRealDFTParameters ¶meters)
{
*this = parameters;
}
/// Move constructor
SlidingWindowRealDFTParameters::SlidingWindowRealDFTParameters(
SlidingWindowRealDFTParameters &¶meters) noexcept
{
*this = std::move(parameters);
}
/// Copy operator
SlidingWindowRealDFTParameters&
SlidingWindowRealDFTParameters::operator=(
const SlidingWindowRealDFTParameters ¶meters)
{
if (¶meters == this){return *this;}
pImpl = std::make_unique<SlidingWindowRealDFTParametersImpl> (*parameters.pImpl);
return *this;
}
/// Move operator
SlidingWindowRealDFTParameters&
SlidingWindowRealDFTParameters::operator=(
SlidingWindowRealDFTParameters &¶meters) noexcept
{
if (¶meters == this){return *this;}
pImpl = std::move(parameters.pImpl);
return *this;
}
/// Destructor
SlidingWindowRealDFTParameters::~SlidingWindowRealDFTParameters() = default;
/// Clears the memory and resets the class
void SlidingWindowRealDFTParameters::clear() noexcept
{
pImpl->mWindow.clear();
pImpl->mSamples = 0;
pImpl->mDFTLength = 0;
pImpl->mSamplesInOverlap = 0;
pImpl->mWindowType = SlidingWindowType::BOXCAR;
pImpl->mDetrendType = SlidingWindowDetrendType::REMOVE_NONE;
}
/// Set number of samples
void SlidingWindowRealDFTParameters::setNumberOfSamples(const int nSamples)
{
pImpl->mSamples = 0;
if (nSamples < 1)
{
throw std::invalid_argument("Number of samples = "
+ std::to_string(nSamples)
+ " must be positive");
}
pImpl->mSamples = nSamples;
}
/// Get number of samples
int SlidingWindowRealDFTParameters::getNumberOfSamples() const
{
if (pImpl->mSamples < 1)
{
throw std::runtime_error("Number of samples not yet set");
}
return pImpl->mSamples;
}
/// Sets the window
void SlidingWindowRealDFTParameters::setWindow(
const int windowLength,
const SlidingWindowType windowType)
{
// Error checks
pImpl->mDFTLength = 0;
pImpl->mSamplesInOverlap = 0;
pImpl->mWindow.clear();
if (windowLength < 1)
{
throw std::invalid_argument("Window length must be positive");
}
if (windowType == SlidingWindowType::CUSTOM)
{
throw std::invalid_argument("Predefined window type cannot be custom");
}
// Resize
pImpl->mDFTLength = windowLength;
pImpl->mWindowType = windowType;
pImpl->mWindow.resize(windowLength);
// Create window
double *windowPtr = pImpl->mWindow.data();
if (windowType == SlidingWindowType::HAMMING)
{
Utilities::WindowFunctions::hamming(windowLength, &windowPtr);
}
else if (windowType == SlidingWindowType::HANN)
{
Utilities::WindowFunctions::hann(windowLength, &windowPtr);
}
else if (windowType == SlidingWindowType::BLACKMAN)
{
Utilities::WindowFunctions::blackman(windowLength, &windowPtr);
}
else if (windowType == SlidingWindowType::BARTLETT)
{
Utilities::WindowFunctions::bartlett(windowLength, &windowPtr);
}
else if (windowType == SlidingWindowType::BOXCAR)
{
ippsSet_64f(1.0, windowPtr, windowLength);
}
#ifndef NDEBUG
else
{
std::cerr << "Impossible location" << std::endl;
assert(false);
}
#endif
}
void SlidingWindowRealDFTParameters::setWindow(
const int windowLength, const double window[])
{
// Error checks
pImpl->mDFTLength = 0;
pImpl->mSamplesInOverlap = 0;
pImpl->mWindow.clear();
if (windowLength < 1)
{
throw std::invalid_argument("Window length must be positive");
}
if (window == nullptr)
{
throw std::invalid_argument("window cannot be NULL");
}
// Resize and copy
pImpl->mDFTLength = windowLength;
pImpl->mWindow.resize(windowLength);
pImpl->mWindowType = SlidingWindowType::CUSTOM;
ippsCopy_64f(window, pImpl->mWindow.data(), windowLength);
}
std::vector<double> SlidingWindowRealDFTParameters::getWindow() const
{
if (pImpl->mWindow.empty()){throw std::runtime_error("Window not yet set");}
return pImpl->mWindow;
}
int SlidingWindowRealDFTParameters::getWindowLength() const
{
if (pImpl->mWindow.empty()){throw std::runtime_error("Window not yet set");}
return static_cast<int> (pImpl->mWindow.size());
}
SlidingWindowType SlidingWindowRealDFTParameters::getWindowType() const
{
if (pImpl->mWindow.empty()){throw std::runtime_error("Window not yet set");}
return pImpl->mWindowType;
}
/// Sets the DFT length
void SlidingWindowRealDFTParameters::setDFTLength(const int dftLength)
{
int windowLength = getWindowLength(); // Will throw if window not set
pImpl->mDFTLength = windowLength;
if (dftLength < windowLength)
{
throw std::invalid_argument("dftLength = " + std::to_string(dftLength)
+ " cannot be less than window length = "
+ std::to_string(windowLength));
}
pImpl->mDFTLength = dftLength;
}
int SlidingWindowRealDFTParameters::getDFTLength() const
{
if (pImpl->mWindow.empty()){throw std::runtime_error("Window not yet set");}
return pImpl->mDFTLength;
}
/// Sets the number of samples in the ovlerap
void SlidingWindowRealDFTParameters::setNumberOfSamplesInOverlap(
const int nSamplesInOverlap)
{
pImpl->mSamplesInOverlap = 0;
int windowLength = getWindowLength(); // Will throw
if (nSamplesInOverlap < 0 || nSamplesInOverlap >= windowLength)
{
throw std::invalid_argument("nSamplesInOverlap = "
+ std::to_string(nSamplesInOverlap)
+ " must be in range [0,"
+ std::to_string(windowLength - 1) + "]");
}
pImpl->mSamplesInOverlap = nSamplesInOverlap;
}
int SlidingWindowRealDFTParameters::getNumberOfSamplesInOverlap() const noexcept
{
return pImpl->mSamplesInOverlap;
}
/// Defines the detrend type
void SlidingWindowRealDFTParameters::setDetrendType(
const SlidingWindowDetrendType detrendType) noexcept
{
pImpl->mDetrendType = detrendType;
}
SlidingWindowDetrendType
SlidingWindowRealDFTParameters::getDetrendType() const noexcept
{
return pImpl->mDetrendType;
}
/// Gets/sets the precision
/*
void SlidingWindowRealDFTParameters::setPrecision(
const RTSeis::Precision precision) noexcept
{
pImpl->mPrecision = precision;
}
RTSeis::Precision SlidingWindowRealDFTParameters::getPrecision() const noexcept
{
return pImpl->mPrecision;
}
*/
/// Check if class is usable
bool SlidingWindowRealDFTParameters::isValid() const noexcept
{
if (pImpl->mSamples < 1){return false;}
if (pImpl->mWindow.empty()){return false;}
return true;
}
/// Check for equality
bool RTSeis::Transforms::operator==(
const SlidingWindowRealDFTParameters &lhs,
const SlidingWindowRealDFTParameters &rhs)
{
if (lhs.isValid() != rhs.isValid()){return false;}
// Do the no except checks
if (lhs.getDetrendType() != rhs.getDetrendType()){return false;}
if (lhs.getNumberOfSamplesInOverlap() != rhs.getNumberOfSamplesInOverlap())
{
return false;
}
// Do the checks that would throw exceptions
if (lhs.isValid() == false && rhs.isValid() == false){return true;}
// This is valid so we can safely call these
if (lhs.getNumberOfSamples() != rhs.getNumberOfSamples()){return false;}
auto v1 = lhs.getWindow();
auto v2 = rhs.getWindow();
if (v1.size() != v2.size()){return false;}
double error = 0;
ippsNormDiff_Inf_64f(v1.data(), v2.data(), v1.size(), &error);
if (error > 0){return false;}
return true;
}
bool RTSeis::Transforms::operator!=(
const SlidingWindowRealDFTParameters &lhs,
const SlidingWindowRealDFTParameters &rhs)
{
return !(lhs == rhs);
}
| 29.472131 | 85 | 0.688508 | [
"vector"
] |
b84e404af5e9e55d1f02d0de1282496258193281 | 7,583 | hpp | C++ | TrainingExtensions/common/include/QcOp/qc_quantizer.hpp | Rohan-Chaudhury/aimet | 1c38cac8cc0fd32dca40ce5e39940805d29f7a4a | [
"BSD-3-Clause"
] | 3 | 2021-08-23T13:00:54.000Z | 2021-11-17T10:52:36.000Z | TrainingExtensions/common/include/QcOp/qc_quantizer.hpp | Rohan-Chaudhury/aimet | 1c38cac8cc0fd32dca40ce5e39940805d29f7a4a | [
"BSD-3-Clause"
] | null | null | null | TrainingExtensions/common/include/QcOp/qc_quantizer.hpp | Rohan-Chaudhury/aimet | 1c38cac8cc0fd32dca40ce5e39940805d29f7a4a | [
"BSD-3-Clause"
] | 1 | 2021-03-06T18:40:33.000Z | 2021-03-06T18:40:33.000Z | //==============================================================================
//
// @@-COPYRIGHT-START-@@
//
// Copyright (c) 2017-2018, Qualcomm Innovation Center, Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// 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. 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 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.
//
// SPDX-License-Identifier: BSD-3-Clause
//
// @@-COPYRIGHT-END-@@
//
//==============================================================================
#ifndef QC_QUANTIZER_HPP
#define QC_QUANTIZER_HPP
#include <memory>
#include "DlQuantization/IQuantizer.hpp"
#include "DlQuantization/QuantizerFactory.hpp"
namespace QcOp {
enum class Device {
CPU = 0,
GPU = 1
};
typedef enum {
CONFIG_TYPE_MIN,
CONFIG_TYPE_UPDATE_STATS,
CONFIG_TYPE_GET_ENCODING,
CONFIG_TYPE_SET_ENCODING,
CONFIG_TYPE_Q_DQ_PARAMS,
CONFIG_TYPE_Q_DQ_ACTIVATIONS,
CONFIG_TYPE_MAX
} OP_CONFIG_TYPE;
template <typename T>
class QC_Quantizer {
public:
void setup (
std::string &op_name,
DlQuantization::QuantizationMode quant_mode,
DlQuantization::RoundingMode roundingMode,
int bitwidth ) {
op_name_ = op_name;
quant_mode_ = quant_mode;
// Use Op only in OUTPUT activation mode.
activationMode_ = DlQuantization::LAYER_OUTPUT;
roundingMode_ = roundingMode;
bitwidth_ = bitwidth;
}
static void InitQuantizer (
const std::vector<std::string>& layer_names,
DlQuantization::ComputationMode mode_cpu_gpu,
const std::vector<int>& bw_activations,
DlQuantization::QuantizationMode quantization_mode) {
if (nullptr == quantizer_) {
quantizer_ = std::shared_ptr<DlQuantization::IQuantizer<float> >(
DlQuantization::GetQuantizerInstance<T> (
layer_names,mode_cpu_gpu,bw_activations,quantization_mode));
}
}
static void ResetQuantizerInstance() { quantizer_.reset(); }
// Forward() method with const pointers as inputs
void Forward (
OP_CONFIG_TYPE config,
const std::vector<const T*>& in_tensors,
const std::vector<size_t>& in_count,
std::vector<T*>& out_tensors,
DlQuantization::TfEncodingLayer &in_encoding,
DlQuantization::TfEncodingLayer &out_encoding) {
if (nullptr == quantizer_)
throw std::runtime_error ("Quantizer not initialized. Aborting.");
switch (config) {
case CONFIG_TYPE_UPDATE_STATS: {
quantizer_->UpdateStats (
op_name_, activationMode_, in_tensors, in_count);
}
break;
case CONFIG_TYPE_GET_ENCODING: {
quantizer_->GetEncoding (op_name_, bitwidth_, out_encoding);
}
break;
case CONFIG_TYPE_SET_ENCODING: {
// First compute delta, offset for the given input range
for (int enc_count = 0; enc_count < in_encoding.out.size(); ++enc_count) {
quantizer_->ComputeDeltaAndOffset (bitwidth_,
in_encoding.out[enc_count].min, in_encoding.out[enc_count].max,
in_encoding.out[enc_count].delta, in_encoding.out[enc_count].offset);
}
// Now set encodings to the op
quantizer_->SetEncoding(op_name_, in_encoding);
}
break;
case CONFIG_TYPE_Q_DQ_ACTIVATIONS: {
std::cerr << "Config type: " << config <<
" not handled with this API. Use the non-const version instead." << std::endl;
}
break;
default:
break;
}
}
// Overloaded Forward() method with non-const pointers as inputs
void Forward(OP_CONFIG_TYPE config,
std::vector<T*>& in_tensors,
const std::vector<size_t>& in_count,
const bool training_in_progress,
std::vector<T*>& out_tensors,
DlQuantization::TfEncodingLayer &in_encoding,
DlQuantization::TfEncodingLayer &out_encoding)
{
if (nullptr == quantizer_)
throw std::runtime_error ("Quantizer not initialized. Aborting.");
// If training is not in progress, we only support NEAREST rounding
DlQuantization::RoundingMode roundingMode = roundingMode_;
if (!training_in_progress)
{
roundingMode = DlQuantization::ROUND_NEAREST;
}
switch (config)
{
case CONFIG_TYPE_Q_DQ_ACTIVATIONS:
{
quantizer_->QuantizeDequantizeActs(op_name_, activationMode_, bitwidth_,
in_tensors, in_count, out_tensors, out_encoding.out);
}
break;
case CONFIG_TYPE_Q_DQ_PARAMS:
{
DlQuantization::TfEncoding param_encodings;
quantizer_->QuantizeDequantizeParams(bitwidth_, in_tensors[0], in_count[0],
roundingMode, out_tensors[0], param_encodings);
out_encoding.out.push_back (param_encodings);
}
break;
case CONFIG_TYPE_UPDATE_STATS:
case CONFIG_TYPE_GET_ENCODING:
case CONFIG_TYPE_SET_ENCODING:
{
std::cerr << "Config type: " << config <<
" not handled with this API. Use the const version instead." << std::endl;
break;
}
default:
break;
}
}
private:
std::string op_name_; // The name of the layer whose params/activations are to be quantized
DlQuantization::QuantizationMode quant_mode_;
DlQuantization::LayerInOut activationMode_;
DlQuantization::RoundingMode roundingMode_;
int bitwidth_;
static std::shared_ptr<DlQuantization::IQuantizer<T> > quantizer_;
};
// Static object instantiation
template <typename T>
std::shared_ptr<DlQuantization::IQuantizer<T> > QC_Quantizer<T>::quantizer_;
}
#endif // QC_QUANTIZER_HPP
| 37.726368 | 104 | 0.621126 | [
"object",
"vector"
] |
b84e77510544c0b61393e61d106df23fa15726db | 6,256 | cpp | C++ | src/examples.cpp | einKnie/Logger | 40da940163aa650592161ad3d2c2d2bf6c575bbc | [
"MIT"
] | null | null | null | src/examples.cpp | einKnie/Logger | 40da940163aa650592161ad3d2c2d2bf6c575bbc | [
"MIT"
] | null | null | null | src/examples.cpp | einKnie/Logger | 40da940163aa650592161ad3d2c2d2bf6c575bbc | [
"MIT"
] | null | null | null | // __
// / / ___ __ _ __ _ ___ _ __
// / / / _ \ / _` |/ _` |/ _ \ '__|
// / /___| (_) | (_| | (_| | __/ |
// \____/ \___/ \__, |\__, |\___|_|
// |___/ |___/ v1.0
// <ramharter>
/// @file examples.cpp
/// @brief All example code used in the doxygen examples
#include "log.h"
void init_example() {
//! [init default]
// create a default logger
Logger *log = new Logger();
log->always("This is a default logger configuration\n");
delete log;
//! [init default]
//! [init file]
// create a file logger
log = new Logger("test0.log", CfgLog::CLogLevelDefault, CfgLog::CLogProfileDefault);
log->always("This logger writes to a file\n");
delete log;
//! [init file]
//! [init cfglog]
// Create a new CfgLog object
CfgLog *cfg = new CfgLog();
cfg->logToFile = true; // enable logging to file
strncpy(cfg->logfile, "test1.log", CfgLog::CMaxPathLen); // set path to logfile
cfg->profile = CfgLog::ELogProfileUser; // set profile to user defined
strncpy(cfg->pattern, "&tim&sep&msg&end", CfgLog::CMaxPatternLen); // set custom message pattern
// Create a Logger object from the config
log = new Logger(cfg);
log->always("This is a cfgLog-configured logger\n");
delete log;
delete cfg;
//! [init cfglog]
//! [init reinit]
// Create a new default Logger
log = new Logger();
log->always("This is a default logger");
// Create a CfgLog object and set the profile to verbose
cfg = new CfgLog();
cfg->profile = CfgLog::ELogProfileVerbose;
// Call the logger's init() method with the custom config
log->init(cfg);
log->always("This is the new configuration");
delete log;
delete cfg;
//! [init reinit]
}
void pattern_example() {
//! [pattern example]
Logger *log = new Logger();
log->always("This is the default logger configuration");
// set a user pattern that shows the loglevel and the time
// and add a vertical separator between them
if (log->setPattern("&tim&sep&lev&sep&msg") == Logger::EErr) {
log->error("Failed to set pattern\n");
} else {
log->always("This is our new pattern\n");
log->always("Current pattern set: %s\n", log->getPattern());
}
delete log;
//! [pattern example]
}
void userPatternShorthand_example() {
//! [shorthand example]
// Create a CfgLog object
CfgLog *cfg = new CfgLog();
cfg->useUsrPattern = true; // enable user pattern shorthands
cfg->addUsrPattern(0, " ~!~ "); // add shorthand to position 0
cfg->addUsrPattern(1, " --- "); // add shorthand to position 1
cfg->profile = CfgLog::ELogProfileUser; // set profile to user defined
strncpy(cfg->pattern, "&us0&lev&us1&msg", CfgLog::CMaxPatternLen); // set custom message pattern
// Create a Logger object from the config
Logger *log = new Logger(cfg);
log->always("This is a message using user defined pattern shorthands\n");
log->always("Current pattern set: %s\n", log->getPattern());
log->always("The user patterns are \"%s\" and \"%s\"\n", cfg->getUsrPattern(0), cfg->getUsrPattern(1));
delete log;
delete cfg;
//! [shorthand example]
}
void color_example() {
//! [color example]
// Create a CfgLog object
CfgLog *cfg = new CfgLog();
cfg->useColor = true; // enable colors
cfg->color = CfgLog::EColorGreen; // set color green
cfg->profile = CfgLog::ELogProfileDefault; // set default profile to include log level output
// Create a Logger object from the config
Logger *log = new Logger(cfg);
log->always("This is a colorful logger");
log->warning("This is a warning");
log->error("This is an error");
log->critical("This is critical");
delete log;
delete cfg;
//! [color example]
}
void basic_usage_example() {
//! [profile example]
// Create a new Logger object
Logger *log = new Logger();
// The default configuration uses logging profile None, which prints only the message to stdout
log->error("This is an error");
log->info("This is an information");
log->always("Current pattern set: %s\n", log->getPattern());
// minimal profile
log->setProfile(CfgLog::ELogProfileMinimal);
log->error("This is an error in minimal profile");
log->info("This is an information in minimal profile");
log->always("Current pattern set: %s\n", log->getPattern());
// default profile
log->setProfile(CfgLog::ELogProfileDefault);
log->error("This is an error in default profile");
log->info("This is an information in default profile");
log->always("Current pattern set: %s\n", log->getPattern());
// verbose profile
log->setProfile(CfgLog::ELogProfileVerbose);
log->error("This is an error in verbose profile");
log->info("This is an information in verbose profile");
log->always("Current pattern set: %s\n", log->getPattern());
delete log;
//! [profile example]
//! [level example]
// Create a new Logger object
log = new Logger();
log->setProfile(CfgLog::ELogProfileDefault);
for (int i = 0; i <= CfgLog::ELogDebug; i++) {
log->setLevel((CfgLog::level_e)i);
log->always("--- Test log level %s start ---", CfgLog::CLogMsgLevel[i]);
log->always("an always msg");
log->emergency("an emergency");
log->alert("an alert");
log->critical("a critical msg");
log->error("an error");
log->warning("a warning");
log->notice("a notice");
log->info("an info");
log->debug("a debug msg");
log->always("--- Test log level %s end ---\n", CfgLog::CLogMsgLevel[i]);
}
delete log;
//! [level example]
}
int main(void) {
Logger *mainLog = new Logger();
mainLog->always("Starting init example...");
init_example();
mainLog->always("\nStarting basic usage example...");
basic_usage_example();
mainLog->always("\nStarting pattern example...");
pattern_example();
mainLog->always("\nStarting user pattern shorthand example...");
userPatternShorthand_example();
mainLog->always("\nStarting color example...");
color_example();
delete mainLog;
return 0;
}
| 31.437186 | 105 | 0.622602 | [
"object"
] |
b8506bf2547682d59f8e318c74a126a893fad510 | 9,848 | cpp | C++ | core/render2d/src/render_params.cpp | mongrzzzzzfr/Indigo | 07cb744a90ff17828f8c1185bcc2e78cb4e882b3 | [
"Apache-2.0"
] | 1 | 2021-08-15T02:53:35.000Z | 2021-08-15T02:53:35.000Z | core/render2d/src/render_params.cpp | mongrzzzzzfr/Indigo | 07cb744a90ff17828f8c1185bcc2e78cb4e882b3 | [
"Apache-2.0"
] | null | null | null | core/render2d/src/render_params.cpp | mongrzzzzzfr/Indigo | 07cb744a90ff17828f8c1185bcc2e78cb4e882b3 | [
"Apache-2.0"
] | null | null | null | /****************************************************************************
* Copyright (C) from 2009 to Present EPAM Systems.
*
* This file is part of Indigo toolkit.
*
* 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 "base_cpp/array.h"
#include "base_cpp/os_sync_wrapper.h"
#include "base_cpp/output.h"
#include "layout/metalayout.h"
#include "layout/molecule_layout.h"
#include "layout/reaction_layout.h"
#include "molecule/molecule.h"
#include "molecule/molecule_arom.h"
#include "molecule/molecule_auto_loader.h"
#include "molecule/molecule_dearom.h"
#include "molecule/molfile_loader.h"
#include "molecule/molfile_saver.h"
#include "molecule/query_molecule.h"
#include "molecule/smiles_loader.h"
#include "reaction/query_reaction.h"
#include "reaction/reaction.h"
#include "reaction/reaction_auto_loader.h"
#include "reaction/rsmiles_loader.h"
#include "reaction/rxnfile_loader.h"
#include "reaction/rxnfile_saver.h"
#include "render_cdxml.h"
#include "render_context.h"
#include "render_grid.h"
#include "render_item_factory.h"
#include "render_item_molecule.h"
#include "render_params.h"
#include "render_single.h"
using namespace indigo;
RenderParams::RenderParams()
{
clear();
}
RenderParams::~RenderParams()
{
}
void RenderParams::clearArrays()
{
mols.clear();
rxns.clear();
titles.clear();
refAtoms.clear();
}
void RenderParams::clear()
{
relativeThickness = 1.0f;
bondLineWidthFactor = 1.0f;
rmode = RENDER_NONE;
mol.reset(nullptr);
rxn.reset(nullptr);
rOpt.clear();
cnvOpt.clear();
clearArrays();
}
IMPL_ERROR(RenderParamInterface, "render param interface");
bool RenderParamInterface::needsLayoutSub(BaseMolecule& mol)
{
QS_DEF(RedBlackSet<int>, atomsToIgnore);
atomsToIgnore.clear();
for (int i = mol.sgroups.begin(); i != mol.sgroups.end(); i = mol.sgroups.next(i))
{
SGroup& sg = mol.sgroups.getSGroup(i);
if (sg.sgroup_type == SGroup::SG_TYPE_MUL)
{
const Array<int>& atoms = sg.atoms;
const Array<int>& patoms = ((MultipleGroup&)sg).parent_atoms;
for (int j = 0; j < atoms.size(); ++j)
atomsToIgnore.find_or_insert(atoms[j]);
for (int j = 0; j < patoms.size(); ++j)
if (atomsToIgnore.find(patoms[j]))
atomsToIgnore.remove(patoms[j]);
}
}
for (int i = mol.vertexBegin(); i < mol.vertexEnd(); i = mol.vertexNext(i))
{
if (atomsToIgnore.find(i))
continue;
for (int j = mol.vertexNext(i); j < mol.vertexEnd(); j = mol.vertexNext(j))
{
if (atomsToIgnore.find(j))
continue;
const Vec3f& v = mol.getAtomXyz(i);
const Vec3f& w = mol.getAtomXyz(j);
Vec3f d;
d.diff(v, w);
d.z = 0;
if (d.length() < 1e-3)
return true;
}
}
return false;
}
bool RenderParamInterface::needsLayout(BaseMolecule& mol)
{
if (needsLayoutSub(mol))
return true;
MoleculeRGroups& rGroups = mol.rgroups;
for (int i = 1; i <= rGroups.getRGroupCount(); ++i)
{
PtrPool<BaseMolecule>& frags = rGroups.getRGroup(i).fragments;
for (int j = frags.begin(); j != frags.end(); j = frags.next(j))
if (needsLayoutSub(*frags[j]))
return true;
}
return false;
}
void RenderParamInterface::_prepareMolecule(RenderParams& params, BaseMolecule& bm)
{
if (needsLayout(bm))
{
MoleculeLayout ml(bm, params.smart_layout);
ml.layout_orientation = UNCPECIFIED;
ml.make();
bm.clearBondDirections();
bm.markBondsStereocenters();
bm.markBondsAlleneStereo();
}
}
void RenderParamInterface::_prepareReaction(RenderParams& params, BaseReaction& rxn)
{
for (int i = rxn.begin(); i < rxn.end(); i = rxn.next(i))
{
BaseMolecule& mol = rxn.getBaseMolecule(i);
if (needsLayout(mol))
{
MoleculeLayout ml(mol, params.smart_layout);
ml.layout_orientation = UNCPECIFIED;
ml.make();
mol.clearBondDirections();
mol.markBondsStereocenters();
mol.markBondsAlleneStereo();
}
}
}
int RenderParamInterface::multilineTextUnit(RenderItemFactory& factory, int type, const Array<char>& titleStr, const float spacing,
const MultilineTextLayout::Alignment alignment)
{
int title = factory.addItemColumn();
int start = 0;
while (start < titleStr.size())
{
int next = titleStr.find(start + 1, titleStr.size(), '\n');
if (next == -1)
next = titleStr.size();
int title_line = factory.addItemAuxiliary();
factory.getItemAuxiliary(title_line).type = (RenderItemAuxiliary::AUX_TYPE)type;
factory.getItemAuxiliary(title_line).text.copy(titleStr.ptr() + start, next - start);
factory.getItemAuxiliary(title_line).text.push('\0');
factory.getItemColumn(title).items.push(title_line);
start = next + 1;
}
factory.getItemColumn(title).setVerticalSpacing(spacing);
factory.getItemColumn(title).setAlignment(alignment);
return title;
}
void RenderParamInterface::render(RenderParams& params)
{
// Disable multithreaded SVG rendering due to the Cairo issue. See IND-482
OsLock* render_lock = 0;
if (params.rOpt.mode == MODE_SVG)
{
static ThreadSafeStaticObj<OsLock> svg_lock;
render_lock = svg_lock.ptr();
}
OsLockerNullable locker(render_lock);
if (params.rmode == RENDER_NONE)
throw Error("No object to render specified");
RenderContext rc(params.rOpt, params.relativeThickness, params.bondLineWidthFactor);
bool bondLengthSet = params.cnvOpt.bondLength > 0;
int bondLength = (int)(bondLengthSet ? params.cnvOpt.bondLength : 100);
rc.setDefaultScale((float)bondLength); // TODO: fix bondLength type
RenderItemFactory factory(rc);
int obj = -1;
Array<int> objs;
Array<int> titles;
if (params.rmode == RENDER_MOL)
{
if (params.mols.size() == 0)
{
obj = factory.addItemMolecule();
BaseMolecule& bm = *params.mol;
_prepareMolecule(params, bm);
factory.getItemMolecule(obj).mol = &bm;
}
else
{
for (int i = 0; i < params.mols.size(); ++i)
{
int mol = factory.addItemMolecule();
BaseMolecule& bm = *params.mols[i];
_prepareMolecule(params, bm);
factory.getItemMolecule(mol).mol = &bm;
objs.push(mol);
if (params.titles.size() > 0)
{
titles.push(multilineTextUnit(factory, RenderItemAuxiliary::AUX_TITLE, params.titles[i],
params.rOpt.titleSpacing * params.rOpt.titleFontFactor, params.cnvOpt.titleAlign.inbox_alignment));
}
}
}
}
else if (params.rmode == RENDER_RXN)
{
if (params.rxns.size() == 0)
{
obj = factory.addItemReaction();
factory.getItemReaction(obj);
BaseReaction& rxn = *params.rxn;
_prepareReaction(params, rxn);
factory.getItemReaction(obj).rxn = &rxn;
}
else
{
for (int i = 0; i < params.rxns.size(); ++i)
{
int rxn = factory.addItemReaction();
BaseReaction& br = *params.rxns[i];
_prepareReaction(params, br);
factory.getItemReaction(rxn).rxn = &br;
objs.push(rxn);
if (params.titles.size() > 0)
{
titles.push(multilineTextUnit(factory, RenderItemAuxiliary::AUX_TITLE, params.titles[i],
params.rOpt.titleSpacing * params.rOpt.titleFontFactor, params.cnvOpt.titleAlign.inbox_alignment));
}
}
}
}
else
{
throw Error("Invalid rendering mode: %i", params.rmode);
}
int comment = -1;
if (params.cnvOpt.comment.size() > 0)
{
comment = multilineTextUnit(factory, RenderItemAuxiliary::AUX_COMMENT, params.cnvOpt.comment,
params.rOpt.commentSpacing * params.rOpt.commentFontFactor, params.cnvOpt.commentAlign.inbox_alignment);
}
// Render into other formats after objects has been prepared (layout, etc.)
if (params.rOpt.mode == MODE_CDXML)
{
// Render into CDXML format
RenderParamCdxmlInterface::render(params);
return;
}
if (obj >= 0)
{
RenderSingle render(rc, factory, params.cnvOpt, bondLength, bondLengthSet);
render.obj = obj;
render.comment = comment;
render.draw();
}
else
{
RenderGrid render(rc, factory, params.cnvOpt, bondLength, bondLengthSet);
render.objs.copy(objs);
render.comment = comment;
render.titles.copy(titles);
render.refAtoms.copy(params.refAtoms);
render.draw();
}
rc.closeContext(false);
} | 32.50165 | 149 | 0.598599 | [
"render",
"object"
] |
b85ad703e509a99c139bae6ce256a6471b5456a8 | 78,323 | cpp | C++ | Engine/Core/Scene.cpp | bioglaze/aether3d | e45ac96508c74b4497a00365067590fa3f7a6eff | [
"Zlib"
] | 216 | 2015-04-19T22:08:24.000Z | 2022-02-12T04:14:48.000Z | Engine/Core/Scene.cpp | bioglaze/aether3d | e45ac96508c74b4497a00365067590fa3f7a6eff | [
"Zlib"
] | 5 | 2015-05-16T12:37:39.000Z | 2022-03-06T16:28:17.000Z | Engine/Core/Scene.cpp | bioglaze/aether3d | e45ac96508c74b4497a00365067590fa3f7a6eff | [
"Zlib"
] | 14 | 2015-07-04T13:06:53.000Z | 2021-05-05T01:34:20.000Z | // This is an independent project of an individual developer. Dear PVS-Studio, please check it.
// PVS-Studio Static Code Analyzer for C, C++, C#, and Java: http://www.viva64.com
#include "Scene.hpp"
#include <algorithm>
#include <chrono>
#include <locale>
#include <string>
#include <sstream>
#include <vector>
#include "AudioSourceComponent.hpp"
#include "AudioSystem.hpp"
#include "CameraComponent.hpp"
#include "DirectionalLightComponent.hpp"
#include "FileSystem.hpp"
#include "Frustum.hpp"
#include "GameObject.hpp"
#include "GfxDevice.hpp"
#include "LightTiler.hpp"
#include "LineRendererComponent.hpp"
#include "Matrix.hpp"
#include "Material.hpp"
#include "Mesh.hpp"
#include "MeshRendererComponent.hpp"
#include "ParticleSystemComponent.hpp"
#include "PointLightComponent.hpp"
#include "RenderTexture.hpp"
#include "Renderer.hpp"
#include "SpriteRendererComponent.hpp"
#include "SpotLightComponent.hpp"
#include "Statistics.hpp"
#include "System.hpp"
#include "TextRendererComponent.hpp"
#include "TransformComponent.hpp"
#include "Texture2D.hpp"
#if !TARGET_OS_IPHONE
#include "Window.hpp"
#else
namespace ae3d
{
namespace Window
{
void GetSize( int& outWidth, int& outHeight );
}
}
#endif
using namespace ae3d;
extern Renderer renderer;
float GetVRFov();
void BeginOffscreen();
void EndOffscreen( int profilerIndex, ae3d::RenderTexture* target );
std::string GetSerialized( const ae3d::TextRendererComponent* component );
std::string GetSerialized( ae3d::CameraComponent* component );
std::string GetSerialized( ae3d::AudioSourceComponent* component );
std::string GetSerialized( ae3d::MeshRendererComponent* component );
std::string GetSerialized( const ae3d::DirectionalLightComponent* component );
std::string GetSerialized( ae3d::PointLightComponent* component );
std::string GetSerialized( const ae3d::SpotLightComponent* component );
std::string GetSerialized( ae3d::TransformComponent* component );
namespace GfxDeviceGlobal
{
extern PerObjectUboStruct perObjectUboStruct;
extern ae3d::LightTiler lightTiler;
}
namespace MathUtil
{
void GetMinMax( const Vec3* aPoints, int count, Vec3& outMin, Vec3& outMax );
bool IsNaN( float f );
}
namespace Global
{
extern Vec3 vrEyePosition;
}
namespace VRGlobal
{
extern int eye;
}
namespace SceneGlobal
{
GameObject shadowCamera;
bool isShadowCameraCreated = false;
Matrix44 shadowCameraViewMatrix;
Matrix44 shadowCameraProjectionMatrix;
}
bool someLightCastsShadow = false;
void SetupCameraForSpotShadowCasting( const Vec3& lightPosition, const Vec3& lightDirection, float coneAngleDegrees, ae3d::CameraComponent& outCamera,
ae3d::TransformComponent& outCameraTransform )
{
outCameraTransform.LookAt( lightPosition, lightPosition - lightDirection * 200, Vec3( 0, 1, 0 ) );
outCamera.SetProjectionType( ae3d::CameraComponent::ProjectionType::Perspective );
outCamera.SetProjection( coneAngleDegrees, 1, 0.1f, 200 );
}
void SetupCameraForDirectionalShadowCasting( const Vec3& lightDirection, const Frustum& eyeFrustum, const Vec3& sceneAABBmin, const Vec3& sceneAABBmax,
ae3d::CameraComponent& outCamera, ae3d::TransformComponent& outCameraTransform )
{
const Vec3 viewFrustumCentroid = eyeFrustum.Centroid();
System::Assert( !MathUtil::IsNaN( lightDirection.x ) && !MathUtil::IsNaN( lightDirection.y ) && !MathUtil::IsNaN( lightDirection.z ), "Invalid light direction" );
System::Assert( !MathUtil::IsNaN( sceneAABBmin.x ) && !MathUtil::IsNaN( sceneAABBmin.y ) && !MathUtil::IsNaN( sceneAABBmin.z ), "Invalid scene AABB min" );
System::Assert( !MathUtil::IsNaN( sceneAABBmax.x ) && !MathUtil::IsNaN( sceneAABBmax.y ) && !MathUtil::IsNaN( sceneAABBmax.z ), "Invalid scene AABB max" );
System::Assert( !MathUtil::IsNaN( viewFrustumCentroid.x ) && !MathUtil::IsNaN( viewFrustumCentroid.y ) && !MathUtil::IsNaN( viewFrustumCentroid.z ), "Invalid eye frustum" );
System::Assert( outCamera.GetTargetTexture() != nullptr, "Shadow camera needs target texture" );
System::Assert( lightDirection.Length() > 0.9f && lightDirection.Length() < 1.1f, "Light dir must be normalized" );
// Start at the centroid, and move back in the opposite direction of the light
// by an amount equal to the camera's farClip. This is the temporary working position for the light.
// TODO: Verify math. + was - in my last engine but had to be changed to get the right direction [TimoW, 2015-09-26]
const Vec3 shadowCameraPosition = viewFrustumCentroid + lightDirection * eyeFrustum.FarClipPlane();
outCameraTransform.LookAt( shadowCameraPosition, viewFrustumCentroid, Vec3( 0, 1, 0 ) );
Matrix44 view;
outCameraTransform.GetLocalRotation().GetMatrix( view );
Matrix44 translation;
translation.SetTranslation( -outCameraTransform.GetLocalPosition() );
Matrix44::Multiply( translation, view, view );
outCamera.SetView( view );
const Matrix44& shadowCameraView = outCamera.GetView();
// Transforms view camera frustum points to shadow camera space.
Vec3 viewFrustumLS[ 8 ];
Matrix44::TransformPoint( eyeFrustum.NearTopLeft(), shadowCameraView, &viewFrustumLS[ 0 ] );
Matrix44::TransformPoint( eyeFrustum.NearTopRight(), shadowCameraView, &viewFrustumLS[ 1 ] );
Matrix44::TransformPoint( eyeFrustum.NearBottomLeft(), shadowCameraView, &viewFrustumLS[ 2 ] );
Matrix44::TransformPoint( eyeFrustum.NearBottomRight(), shadowCameraView, &viewFrustumLS[ 3 ] );
Matrix44::TransformPoint( eyeFrustum.FarTopLeft(), shadowCameraView, &viewFrustumLS[ 4 ] );
Matrix44::TransformPoint( eyeFrustum.FarTopRight(), shadowCameraView, &viewFrustumLS[ 5 ] );
Matrix44::TransformPoint( eyeFrustum.FarBottomLeft(), shadowCameraView, &viewFrustumLS[ 6 ] );
Matrix44::TransformPoint( eyeFrustum.FarBottomRight(), shadowCameraView, &viewFrustumLS[ 7 ] );
// Gets light-space view frustum extremes.
Vec3 viewMinLS, viewMaxLS;
MathUtil::GetMinMax( viewFrustumLS, 8, viewMinLS, viewMaxLS );
// Transforms scene's AABB to light-space.
Vec3 sceneAABBminLS, sceneAABBmaxLS;
const Vec3 min = sceneAABBmin;
const Vec3 max = sceneAABBmax;
const Vec3 sceneCorners[] =
{
Vec3( min.x, min.y, min.z ),
Vec3( max.x, min.y, min.z ),
Vec3( min.x, max.y, min.z ),
Vec3( min.x, min.y, max.z ),
Vec3( max.x, max.y, min.z ),
Vec3( min.x, max.y, max.z ),
Vec3( max.x, max.y, max.z ),
Vec3( max.x, min.y, max.z )
};
Vec3 sceneAABBLS[ 8 ];
for (int i = 0; i < 8; ++i)
{
Matrix44::TransformPoint( sceneCorners[ i ], shadowCameraView, &sceneAABBLS[ i ] );
}
MathUtil::GetMinMax( sceneAABBLS, 8, sceneAABBminLS, sceneAABBmaxLS );
// Use world volume for near plane.
viewMaxLS.z = sceneAABBmaxLS.z > viewMaxLS.z ? sceneAABBmaxLS.z : viewMaxLS.z;
outCamera.SetProjectionType( ae3d::CameraComponent::ProjectionType::Orthographic );
outCamera.SetProjection( viewMinLS.x, viewMaxLS.x, viewMinLS.y, viewMaxLS.y, -viewMaxLS.z, -viewMinLS.z );
}
void ae3d::Scene::Add( GameObject* gameObject )
{
for (const auto& go : gameObjects)
{
if (go == gameObject)
{
return;
}
}
if (nextFreeGameObject >= gameObjects.size())
{
gameObjects.resize( gameObjects.size() + 10 );
}
gameObjects[ nextFreeGameObject++ ] = gameObject;
}
void ae3d::Scene::Remove( GameObject* gameObject )
{
for (std::size_t i = 0; i < gameObjects.size(); ++i)
{
if (gameObject == gameObjects[ i ])
{
gameObjects.erase( std::begin( gameObjects ) + i );
return;
}
}
}
void ae3d::Scene::RenderDepthAndNormalsForAllCameras( std::vector< GameObject* >& cameras )
{
Statistics::BeginDepthNormalsProfiling();
for (auto camera : cameras)
{
CameraComponent* cameraComponent = camera->GetComponent< CameraComponent >();
if (cameraComponent->GetDepthNormalsTexture().GetID() != 0)
{
std::vector< unsigned > gameObjectsWithMeshRenderer;
gameObjectsWithMeshRenderer.reserve( gameObjects.size() );
int i = -1;
for (auto gameObject : gameObjects)
{
++i;
if (gameObject == nullptr || (gameObject->GetLayer() & cameraComponent->GetLayerMask()) == 0 || !gameObject->IsEnabled())
{
continue;
}
auto meshRenderer = gameObject->GetComponent< MeshRendererComponent >();
if (meshRenderer)
{
gameObjectsWithMeshRenderer.push_back( i );
}
}
Frustum frustum;
if (cameraComponent->GetProjectionType() == CameraComponent::ProjectionType::Perspective)
{
frustum.SetProjection( cameraComponent->GetFovDegrees(), cameraComponent->GetAspect(), cameraComponent->GetNear(), cameraComponent->GetFar() );
}
else
{
frustum.SetProjection( cameraComponent->GetLeft(), cameraComponent->GetRight(), cameraComponent->GetBottom(),
cameraComponent->GetTop(), cameraComponent->GetNear(), cameraComponent->GetFar() );
}
auto cameraTransform = camera->GetComponent< TransformComponent >();
// TODO: world position
Vec3 position = cameraTransform ? cameraTransform->GetLocalPosition() : Vec3( 0, 0, 0 );
const Matrix44& view = cameraComponent->GetView();
const Vec3 viewDir = Vec3( view.m[ 2 ], view.m[ 6 ], view.m[ 10 ] ).Normalized();
frustum.Update( position, viewDir );
RenderDepthAndNormals( cameraComponent, view, gameObjectsWithMeshRenderer, 0, frustum );
GfxDeviceGlobal::lightTiler.ClearLightCount();
int goWithPointLightIndex = 0;
int goWithSpotLightIndex = 0;
for (auto gameObject : gameObjects)
{
if (gameObject == nullptr || (gameObject->GetLayer() & cameraComponent->GetLayerMask()) == 0 || !gameObject->IsEnabled())
{
continue;
}
auto transform = gameObject->GetComponent< TransformComponent >();
auto pointLight = gameObject->GetComponent< PointLightComponent >();
auto spotLight = gameObject->GetComponent< SpotLightComponent >();
if (transform && pointLight)
{
auto worldPos = transform->GetWorldPosition();
GfxDeviceGlobal::lightTiler.SetPointLightParameters( goWithPointLightIndex, worldPos, pointLight->GetRadius(), Vec4( pointLight->GetColor() ) );
++goWithPointLightIndex;
}
if (transform && spotLight)
{
auto worldPos = transform->GetWorldPosition();
GfxDeviceGlobal::lightTiler.SetSpotLightParameters( goWithSpotLightIndex, worldPos, spotLight->GetRadius(), Vec4( spotLight->GetColor() ), transform->GetViewDirection(), spotLight->GetConeAngle(), 3 );
++goWithSpotLightIndex;
}
}
GfxDeviceGlobal::lightTiler.UpdateLightBuffers();
Statistics::BeginLightCullerProfiling();
GfxDeviceGlobal::lightTiler.CullLights( renderer.builtinShaders.lightCullShader, cameraComponent->GetProjection(),
view, cameraComponent->GetDepthNormalsTexture() );
Statistics::EndLightCullerProfiling();
}
}
Statistics::EndDepthNormalsProfiling();
}
const float scale = 2000;
static const Vec3 directions[ 6 ] =
{
Vec3( 1, 0, 0 ) * scale, // posX
Vec3( -1, 0, 0 ) * scale, // negX
Vec3( 0, 1, 0 ) * scale, // posY
Vec3( 0, -1, 0 ) * scale, // negY
Vec3( 0, 0, 1 ) * scale, // posZ
Vec3( 0, 0, -1 ) * scale // negZ
};
static const Vec3 ups[ 6 ] =
{
Vec3( 0, -1, 0 ),
Vec3( 0, -1, 0 ),
Vec3( 0, 0, 1 ),
Vec3( 0, 0, -1 ),
Vec3( 0, -1, 0 ),
Vec3( 0, -1, 0 )
};
void ae3d::Scene::SetAmbient( const Vec3& color )
{
ambientColor = color;
}
void ae3d::Scene::RenderRTCameras( std::vector< GameObject* >& rtCameras )
{
for (auto rtCamera : rtCameras)
{
auto transform = rtCamera->GetComponent< TransformComponent >();
if (transform && !rtCamera->GetComponent< CameraComponent >()->GetTargetTexture()->IsCube())
{
if (rtCamera->GetComponent< CameraComponent >()->ShouldRenderParticles() && rtCamera->GetComponent< CameraComponent >()->GetProjectionType() == ae3d::CameraComponent::ProjectionType::Perspective)
{
Matrix44::Multiply( rtCamera->GetComponent< CameraComponent >()->GetView(), rtCamera->GetComponent< CameraComponent >()->GetProjection(), GfxDeviceGlobal::perObjectUboStruct.viewToClip );
ParticleSystemComponent::Simulate( renderer.builtinShaders.particleSimulationShader );
}
RenderWithCamera( rtCamera, 0, rtCamera->GetName() );
}
else if (transform && rtCamera->GetComponent< CameraComponent >()->GetTargetTexture()->IsCube())
{
const Vec3 cameraPos = transform->GetLocalPosition();
for (int cubeMapFace = 0; cubeMapFace < 6; ++cubeMapFace)
{
transform->LookAt( cameraPos, cameraPos + directions[ cubeMapFace ], ups[ cubeMapFace ] );
transform->UpdateLocalAndGlobalMatrix();
RenderWithCamera( rtCamera, cubeMapFace, "Cube Map RT" );
}
}
}
}
void ae3d::Scene::RenderShadowMaps( std::vector< GameObject* >& cameras )
{
for (auto camera : cameras)
{
if (camera == nullptr || !camera->GetComponent<TransformComponent>())
{
continue;
}
TransformComponent* cameraTransform = camera->GetComponent<TransformComponent>();
// Shadow pass
if (camera->GetComponent<CameraComponent>()->GetProjectionType() != ae3d::CameraComponent::ProjectionType::Perspective)
{
continue;
}
for (auto go : gameObjects)
{
if (!go || !go->IsEnabled())
{
continue;
}
auto lightTransform = go->GetComponent<TransformComponent>();
if (!lightTransform)
{
continue;
}
auto dirLight = go->GetComponent<DirectionalLightComponent>();
auto spotLight = go->GetComponent<SpotLightComponent>();
auto pointLight = go->GetComponent<PointLightComponent>();
if (((dirLight && dirLight->CastsShadow()) || (spotLight && spotLight->CastsShadow()) ||
(pointLight && pointLight->CastsShadow())))
{
Statistics::BeginShadowMapProfiling();
Frustum eyeFrustum;
auto cameraComponent = camera->GetComponent< CameraComponent >();
if (cameraComponent->GetProjectionType() == CameraComponent::ProjectionType::Perspective)
{
eyeFrustum.SetProjection( cameraComponent->GetFovDegrees(), cameraComponent->GetAspect(), cameraComponent->GetNear(), cameraComponent->GetFar() );
}
else
{
eyeFrustum.SetProjection( cameraComponent->GetLeft(), cameraComponent->GetRight(), cameraComponent->GetBottom(), cameraComponent->GetTop(), cameraComponent->GetNear(), cameraComponent->GetFar() );
}
Matrix44 eyeView;
cameraTransform->GetWorldRotation().GetMatrix( eyeView );
Matrix44 translation;
translation.SetTranslation( -cameraTransform->GetWorldPosition() );
Matrix44::Multiply( translation, eyeView, eyeView );
const Vec3 eyeViewDir = Vec3( eyeView.m[2], eyeView.m[6], eyeView.m[10] ).Normalized();
eyeFrustum.Update( cameraTransform->GetWorldPosition(), eyeViewDir );
if (!SceneGlobal::isShadowCameraCreated)
{
SceneGlobal::shadowCamera.AddComponent< CameraComponent >();
SceneGlobal::shadowCamera.GetComponent< CameraComponent >()->SetClearFlag( ae3d::CameraComponent::ClearFlag::DepthAndColor );
SceneGlobal::shadowCamera.AddComponent< TransformComponent >();
SceneGlobal::isShadowCameraCreated = true;
// Component adding can invalidate lightTransform pointer.
lightTransform = go->GetComponent<TransformComponent>();
}
if (dirLight && go->GetComponent<DirectionalLightComponent>()->shadowMap.IsCreated())
{
SceneGlobal::shadowCamera.GetComponent< CameraComponent >()->SetTargetTexture( &go->GetComponent<DirectionalLightComponent>()->shadowMap );
SetupCameraForDirectionalShadowCasting( lightTransform->GetViewDirection(), eyeFrustum, aabbMin, aabbMax, *SceneGlobal::shadowCamera.GetComponent< CameraComponent >(), *SceneGlobal::shadowCamera.GetComponent< TransformComponent >() );
GfxDeviceGlobal::perObjectUboStruct.lightType = PerObjectUboStruct::LightType::Dir;
RenderShadowsWithCamera( &SceneGlobal::shadowCamera, 0 );
Material::SetGlobalRenderTexture( &go->GetComponent<DirectionalLightComponent>()->shadowMap );
}
else if (spotLight)
{
SceneGlobal::shadowCamera.GetComponent< CameraComponent >()->SetTargetTexture( &go->GetComponent<SpotLightComponent>()->shadowMap );
SetupCameraForSpotShadowCasting( lightTransform->GetWorldPosition(), lightTransform->GetViewDirection(), go->GetComponent<SpotLightComponent>()->GetConeAngle(), *SceneGlobal::shadowCamera.GetComponent< CameraComponent >(), *SceneGlobal::shadowCamera.GetComponent< TransformComponent >() );
GfxDeviceGlobal::perObjectUboStruct.lightType = PerObjectUboStruct::LightType::Spot;
RenderShadowsWithCamera( &SceneGlobal::shadowCamera, 0 );
Material::SetGlobalRenderTexture( &go->GetComponent<SpotLightComponent>()->shadowMap );
}
else if (pointLight)
{
SceneGlobal::shadowCamera.GetComponent< CameraComponent >()->SetTargetTexture( &go->GetComponent<PointLightComponent>()->shadowMap );
GfxDeviceGlobal::perObjectUboStruct.lightType = PerObjectUboStruct::LightType::Point;
for (int cubeMapFace = 0; cubeMapFace < 6; ++cubeMapFace)
{
lightTransform->LookAt( lightTransform->GetLocalPosition(), lightTransform->GetLocalPosition() + directions[ cubeMapFace ], ups[ cubeMapFace ] );
lightTransform->UpdateLocalAndGlobalMatrix();
SetupCameraForSpotShadowCasting( lightTransform->GetWorldPosition(), lightTransform->GetViewDirection(), 45, *SceneGlobal::shadowCamera.GetComponent< CameraComponent >(), *SceneGlobal::shadowCamera.GetComponent< TransformComponent >() );
SceneGlobal::shadowCamera.GetComponent< TransformComponent >()->UpdateLocalAndGlobalMatrix();
RenderShadowsWithCamera( &SceneGlobal::shadowCamera, cubeMapFace );
}
Material::SetGlobalRenderTexture( &go->GetComponent<PointLightComponent>()->shadowMap );
}
Statistics::EndShadowMapProfiling();
}
}
}
}
void BubbleSort( GameObject** gos, int count )
{
for (int i = 0; i < count - 1; ++i)
{
for (int j = 0; j < count - i - 1; ++j)
{
if (gos[ j ]->GetComponent< CameraComponent >()->GetRenderOrder() >
gos[ j + 1 ]->GetComponent< CameraComponent >()->GetRenderOrder())
{
GameObject* temp = gos[ j ];
gos[ j ] = gos[ j + 1 ];
gos[ j + 1 ] = temp;
}
}
}
}
void ae3d::Scene::Render()
{
#if RENDERER_VULKAN && !AE3D_OPENVR
GfxDevice::BeginFrame();
#endif
GenerateAABB();
#if RENDERER_D3D12
GfxDevice::ResetCommandList();
#endif
Statistics::ResetFrameStatistics();
TransformComponent::UpdateLocalMatrices();
GfxDeviceGlobal::perObjectUboStruct.particleCount = 10;
GfxDeviceGlobal::perObjectUboStruct.timeStamp = (float)System::SecondsSinceStartup();
//printf("time: %f\n", GfxDeviceGlobal::perObjectUboStruct.timeStamp );
std::vector< GameObject* > rtCameras;
rtCameras.reserve( gameObjects.size() / 4 );
std::vector< GameObject* > cameras;
cameras.reserve( gameObjects.size() / 4 );
for (auto gameObject : gameObjects)
{
if (gameObject == nullptr || !gameObject->IsEnabled())
{
continue;
}
auto cameraComponent = gameObject->GetComponent<CameraComponent>();
if (cameraComponent && cameraComponent->GetTargetTexture() != nullptr && gameObject->GetComponent<TransformComponent>())
{
rtCameras.push_back( gameObject );
}
if (cameraComponent && cameraComponent->GetTargetTexture() == nullptr && gameObject->GetComponent<TransformComponent>())
{
cameras.push_back( gameObject );
}
}
#if RENDERER_VULKAN
if (cameras.empty())
{
GfxDevice::BeginRenderPassAndCommandBuffer();
GfxDevice::EndRenderPassAndCommandBuffer();
}
#endif
BubbleSort( cameras.data(), (int)cameras.size() );
BubbleSort( rtCameras.data(), (int)rtCameras.size() );
if (someLightCastsShadow)
{
RenderShadowMaps( rtCameras );
}
RenderDepthAndNormalsForAllCameras( rtCameras );
RenderRTCameras( rtCameras );
RenderDepthAndNormalsForAllCameras( cameras );
#if RENDERER_VULKAN && !AE3D_OPENVR
GfxDevice::BeginRenderPassAndCommandBuffer();
#endif
#if RENDERER_METAL
GfxDevice::BeginBackBufferEncoding();
#endif
for (auto camera : cameras)
{
auto cameraTransform = camera->GetComponent< TransformComponent >();
auto cameraPos = cameraTransform->GetWorldPosition();
auto cameraDir = cameraTransform->GetViewDirection();
AudioSystem::SetListenerPosition( cameraPos.x, cameraPos.y, cameraPos.z );
AudioSystem::SetListenerOrientation( cameraDir.x, cameraDir.y, cameraDir.z );
RenderWithCamera( camera, 0, "Primary Pass" );
}
GfxDevice::SetRenderTarget( nullptr, 0 );
#if RENDERER_D3D12
GfxDevice::ClearScreen( GfxDevice::ClearFlags::Depth );
#endif
}
void ae3d::Scene::EndFrame()
{
#if RENDERER_VULKAN
GfxDevice::EndRenderPassAndCommandBuffer();
#endif
#if RENDERER_METAL
GfxDevice::EndBackBufferEncoding();
Statistics::EndFrameTimeProfiling();
#endif
}
void ae3d::Scene::RenderWithCamera( GameObject* cameraGo, int cubeMapFace, const char* debugGroupName )
{
ae3d::System::Assert( 0 <= cubeMapFace && cubeMapFace < 6, "invalid cube map face" );
CameraComponent* camera = cameraGo->GetComponent< CameraComponent >();
const Vec3 color = camera->GetClearColor();
GfxDevice::SetClearColor( color.x, color.y, color.z );
#ifndef RENDERER_VULKAN
GfxDevice::SetViewport( camera->GetViewport() );
#endif
#ifndef RENDERER_METAL
GfxDevice::SetRenderTarget( camera->GetTargetTexture(), cubeMapFace );
#endif
#ifdef RENDERER_VULKAN
if (camera->GetTargetTexture())
{
BeginOffscreen();
}
GfxDevice::SetViewport( camera->GetViewport() );
GfxDevice::SetScissor( camera->GetViewport() );
#endif
#ifndef RENDERER_METAL
GfxDevice::PushGroupMarker( debugGroupName );
#endif
if (camera->GetClearFlag() == CameraComponent::ClearFlag::DepthAndColor)
{
GfxDevice::ClearScreen( GfxDevice::ClearFlags::Color | GfxDevice::ClearFlags::Depth );
}
else if (camera->GetClearFlag() == CameraComponent::ClearFlag::Depth)
{
GfxDevice::ClearScreen( GfxDevice::ClearFlags::Depth );
}
else if (camera->GetClearFlag() == CameraComponent::ClearFlag::DontClear)
{
GfxDevice::ClearScreen( GfxDevice::ClearFlags::DontClear );
}
else
{
System::Assert( false, "Unhandled clear flag." );
}
#if RENDERER_METAL
GfxDevice::SetRenderTarget( camera->GetTargetTexture(), cubeMapFace );
GfxDevice::PushGroupMarker( debugGroupName );
#endif
Matrix44 view;
if (skybox != nullptr && camera->GetProjectionType() != ae3d::CameraComponent::ProjectionType::Orthographic)
{
auto cameraTrans = cameraGo->GetComponent< TransformComponent >();
cameraTrans->GetLocalRotation().GetMatrix( view );
#if defined( AE3D_OPENVR )
Matrix44 vrView = cameraTrans->GetVrView();
// Cancels translation.
vrView.m[ 14 ] = 0;
vrView.m[ 13 ] = 0;
vrView.m[ 12 ] = 0;
camera->SetView( vrView );
#else
camera->SetView( view );
#endif
renderer.RenderSkybox( skybox, *camera );
}
float fovDegrees;
Vec3 position;
// TODO: Maybe add a VR flag into camera to select between HMD and normal pose.
#if defined( AE3D_OPENVR )
view = cameraGo->GetComponent< TransformComponent >()->GetVrView();
position = Global::vrEyePosition;
fovDegrees = GetVRFov();
#else
auto cameraTransform = cameraGo->GetComponent< TransformComponent >();
position = cameraTransform->GetWorldPosition();
fovDegrees = camera->GetFovDegrees();
cameraTransform->GetWorldRotation().GetMatrix( view );
Matrix44 translation;
translation.SetTranslation( -cameraTransform->GetWorldPosition() );
Matrix44::Multiply( translation, view, view );
camera->SetView( view );
#endif
Frustum frustum;
if (camera->GetProjectionType() == CameraComponent::ProjectionType::Perspective)
{
frustum.SetProjection( fovDegrees, camera->GetAspect(), camera->GetNear(), camera->GetFar() );
}
else
{
frustum.SetProjection( camera->GetLeft(), camera->GetRight(), camera->GetBottom(), camera->GetTop(), camera->GetNear(), camera->GetFar() );
}
const Vec3 viewDir = Vec3( view.m[2], view.m[6], view.m[10] ).Normalized();
frustum.Update( position, viewDir );
std::vector< unsigned > gameObjectsWithMeshRenderer;
gameObjectsWithMeshRenderer.reserve( gameObjects.size() );
int gameObjectIndex = -1;
GfxDeviceGlobal::perObjectUboStruct.lightColor = Vec4( 0, 0, 0, 1 );
GfxDeviceGlobal::perObjectUboStruct.minAmbient = ambientColor.x;
GfxDeviceGlobal::perObjectUboStruct.lightType = PerObjectUboStruct::LightType::Empty;
GfxDeviceGlobal::perObjectUboStruct.cameraParams = Vec4( camera->GetFovDegrees() * 3.14159265f / 180.0f, camera->GetAspect(), camera->GetNear(), camera->GetFar() );
for (auto gameObject : gameObjects)
{
++gameObjectIndex;
if (gameObject == nullptr || (gameObject->GetLayer() & camera->GetLayerMask()) == 0 || !gameObject->IsEnabled())
{
continue;
}
auto transform = gameObject->GetComponent< TransformComponent >();
auto dirLight = gameObject->GetComponent< DirectionalLightComponent >();
auto spotLight = gameObject->GetComponent< SpotLightComponent >();
auto pointLight = gameObject->GetComponent< PointLightComponent >();
if (dirLight)
{
auto lightTransform = gameObject->GetComponent< TransformComponent >();
Vec4 lightDirection = Vec4( lightTransform != nullptr ? lightTransform->GetViewDirection() : Vec3( 1, 0, 0 ), 0 );
Vec3 lightDirectionVS;
Matrix44::TransformDirection( Vec3( lightDirection.x, lightDirection.y, lightDirection.z ), camera->GetView(), &lightDirectionVS );
GfxDeviceGlobal::perObjectUboStruct.lightColor = Vec4( dirLight->GetColor() );
GfxDeviceGlobal::perObjectUboStruct.lightDirection = Vec4( lightDirectionVS.x, lightDirectionVS.y, lightDirectionVS.z, 0 );
// FIXME: This is an ugly hack to get shadow shaders to work with different light types.
if (dirLight->CastsShadow())
{
GfxDeviceGlobal::perObjectUboStruct.lightType = PerObjectUboStruct::LightType::Dir;
}
}
else if (spotLight && spotLight->CastsShadow())
{
GfxDeviceGlobal::perObjectUboStruct.lightType = PerObjectUboStruct::LightType::Spot;
}
else if (pointLight && pointLight->CastsShadow())
{
GfxDeviceGlobal::perObjectUboStruct.lightType = PerObjectUboStruct::LightType::Point;
}
auto spriteRenderer = gameObject->GetComponent< SpriteRendererComponent >();
if (spriteRenderer)
{
Matrix44 localToClip;
Matrix44::Multiply( transform ? transform->GetLocalToWorldMatrix() : Matrix44::identity, camera->GetProjection(), localToClip );
spriteRenderer->Render( localToClip.m );
}
auto textRenderer = gameObject->GetComponent< TextRendererComponent >();
if (textRenderer)
{
Matrix44 localToClip;
Matrix44::Multiply( transform ? transform->GetLocalToWorldMatrix() : Matrix44::identity, camera->GetProjection(), localToClip );
textRenderer->Render( localToClip.m );
}
auto lineRenderer = gameObject->GetComponent< LineRendererComponent >();
if (lineRenderer && lineRenderer->isEnabled)
{
#if RENDERER_VULKAN
const float screenScale = 1;
#else
const float screenScale = 2;
#endif
int width = 0, height = 0;
Window::GetSize( width, height );
System::DrawLines( lineRenderer->lineHandle, camera->GetView(), camera->GetProjection(), (int)(width * screenScale), (int)(height * screenScale) );
}
auto meshRenderer = gameObject->GetComponent< MeshRendererComponent >();
if (meshRenderer)
{
gameObjectsWithMeshRenderer.push_back( gameObjectIndex );
}
}
auto meshSorterByMesh = [&](unsigned j, unsigned k)
{
return gameObjects[ j ]->GetComponent< MeshRendererComponent >()->GetMesh() <
gameObjects[ k ]->GetComponent< MeshRendererComponent >()->GetMesh();
};
std::sort( std::begin( gameObjectsWithMeshRenderer ), std::end( gameObjectsWithMeshRenderer ), meshSorterByMesh );
Array< Matrix44 > localToViews( (int)gameObjectsWithMeshRenderer.size() );
Array< Matrix44 > localToClips( (int)gameObjectsWithMeshRenderer.size() );
int i = 0;
for (auto j : gameObjectsWithMeshRenderer)
{
auto transform = gameObjects[ j ]->GetComponent< TransformComponent >();
auto meshLocalToWorld = transform ? transform->GetLocalToWorldMatrix() : Matrix44::identity;
Matrix44::Multiply( meshLocalToWorld, view, localToViews[ i ] );
Matrix44::Multiply( localToViews[ i ], camera->GetProjection(), localToClips[ i ] );
auto* meshRenderer = gameObjects[ j ]->GetComponent< MeshRendererComponent >();
meshRenderer->Cull( frustum, meshLocalToWorld );
meshRenderer->Render( localToViews[ i ], localToClips[ i ], meshLocalToWorld, SceneGlobal::shadowCameraViewMatrix, SceneGlobal::shadowCameraProjectionMatrix, nullptr, nullptr, MeshRendererComponent::RenderType::Opaque );
++i;
}
i = 0;
for (auto j : gameObjectsWithMeshRenderer)
{
auto transform = gameObjects[ j ]->GetComponent< TransformComponent >();
auto meshLocalToWorld = transform ? transform->GetLocalToWorldMatrix() : Matrix44::identity;
gameObjects[ j ]->GetComponent< MeshRendererComponent >()->Render( localToViews[ i ], localToClips[ i ], meshLocalToWorld, SceneGlobal::shadowCameraViewMatrix, SceneGlobal::shadowCameraProjectionMatrix, nullptr, nullptr, MeshRendererComponent::RenderType::Transparent );
++i;
}
GfxDevice::PopGroupMarker();
#if RENDERER_METAL
GfxDevice::SetRenderTarget( nullptr, 0 );
#endif
#if RENDERER_VULKAN
GfxDevice::SetRenderTarget( nullptr, 0 );
if (camera->GetTargetTexture())
{
if (camera->GetProjectionType() == CameraComponent::ProjectionType::Perspective)
{
EndOffscreen( 2, camera->GetTargetTexture() );
}
else
{
EndOffscreen( 3, camera->GetTargetTexture() );
}
}
#endif
if (camera->GetTargetTexture() && camera->GetProjectionType() == ae3d::CameraComponent::ProjectionType::Perspective && !camera->GetTargetTexture()->IsCube() && camera->ShouldRenderParticles())
{
ParticleSystemComponent::Draw( renderer.builtinShaders.particleDrawShader, *camera->GetTargetTexture() );
}
}
void ae3d::Scene::RenderDepthAndNormals( CameraComponent* camera, const Matrix44& worldToView, std::vector< unsigned > gameObjectsWithMeshRenderer,
int cubeMapFace, const Frustum& frustum )
{
#if RENDERER_METAL
GfxDevice::SetViewport( camera->GetViewport() );
GfxDevice::ClearScreen( GfxDevice::ClearFlags::Color | GfxDevice::ClearFlags::Depth );
GfxDevice::SetRenderTarget( &camera->GetDepthNormalsTexture(), cubeMapFace );
#else
GfxDevice::SetRenderTarget( &camera->GetDepthNormalsTexture(), cubeMapFace );
#if RENDERER_VULKAN
BeginOffscreen();
GfxDevice::SetScissor( camera->GetViewport() );
#endif
GfxDevice::SetViewport( camera->GetViewport() );
GfxDevice::ClearScreen( GfxDevice::ClearFlags::Color | GfxDevice::ClearFlags::Depth );
#endif
GfxDevice::PushGroupMarker( "DepthNormal" );
GfxDeviceGlobal::perObjectUboStruct.cameraParams = Vec4( camera->GetFovDegrees() * 3.14159265f / 180.0f, camera->GetAspect(), camera->GetNear(), camera->GetFar() );
for (auto j : gameObjectsWithMeshRenderer)
{
auto transform = gameObjects[ j ]->GetComponent< TransformComponent >();
auto meshLocalToWorld = transform ? transform->GetLocalToWorldMatrix() : Matrix44::identity;
Matrix44 localToView;
Matrix44 localToClip;
Matrix44::Multiply( meshLocalToWorld, worldToView, localToView );
Matrix44::Multiply( localToView, camera->GetProjection(), localToClip );
auto meshRenderer = gameObjects[ j ]->GetComponent< MeshRendererComponent >();
meshRenderer->Cull( frustum, meshLocalToWorld );
meshRenderer->Render( localToView, localToClip, meshLocalToWorld, SceneGlobal::shadowCameraViewMatrix, SceneGlobal::shadowCameraProjectionMatrix, &renderer.builtinShaders.depthNormalsShader, &renderer.builtinShaders.depthNormalsSkinShader, MeshRendererComponent::RenderType::Opaque );
meshRenderer->Render( localToView, localToClip, meshLocalToWorld, SceneGlobal::shadowCameraViewMatrix, SceneGlobal::shadowCameraProjectionMatrix, &renderer.builtinShaders.depthNormalsShader,
&renderer.builtinShaders.depthNormalsSkinShader, MeshRendererComponent::RenderType::Transparent );
}
GfxDevice::PopGroupMarker();
GfxDevice::SetRenderTarget( nullptr, 0 );
#if RENDERER_VULKAN
EndOffscreen( 0, camera->GetTargetTexture() );
#endif
}
void ae3d::Scene::RenderShadowsWithCamera( GameObject* cameraGo, int cubeMapFace )
{
CameraComponent* camera = cameraGo->GetComponent< CameraComponent >();
System::Assert( camera->GetTargetTexture() != nullptr, "cannot render shadows if target texture is missing!" );
int viewport[ 4 ] = { 0, 0, camera->GetTargetTexture()->GetWidth(), camera->GetTargetTexture()->GetHeight() };
#if !RENDERER_METAL
GfxDevice::SetRenderTarget( camera->GetTargetTexture(), cubeMapFace );
#endif
#ifndef RENDERER_VULKAN
GfxDevice::SetViewport( viewport );
#endif
const Vec3 color = camera->GetClearColor();
GfxDevice::SetClearColor( color.x, color.y, color.z );
if (camera->GetClearFlag() == CameraComponent::ClearFlag::DepthAndColor)
{
GfxDevice::ClearScreen( GfxDevice::ClearFlags::Color | GfxDevice::ClearFlags::Depth );
}
#if RENDERER_METAL
GfxDevice::SetRenderTarget( camera->GetTargetTexture(), cubeMapFace );
#endif
#if RENDERER_VULKAN
BeginOffscreen();
GfxDevice::SetScissor( viewport );
GfxDevice::SetViewport( viewport );
#endif
GfxDevice::PushGroupMarker( "Shadow maps" );
Matrix44 view;
auto cameraTransform = cameraGo->GetComponent< TransformComponent >();
cameraTransform->GetWorldRotation().GetMatrix( view );
Matrix44 translation;
translation.SetTranslation( -cameraTransform->GetWorldPosition() );
Matrix44::Multiply( translation, view, view );
SceneGlobal::shadowCameraViewMatrix = view;
SceneGlobal::shadowCameraProjectionMatrix = camera->GetProjection();
Frustum frustum;
if (camera->GetProjectionType() == CameraComponent::ProjectionType::Perspective)
{
frustum.SetProjection( camera->GetFovDegrees(), camera->GetAspect(), camera->GetNear(), camera->GetFar() );
}
else
{
frustum.SetProjection( camera->GetLeft(), camera->GetRight(), camera->GetBottom(), camera->GetTop(), camera->GetNear(), camera->GetFar() );
}
const Vec3 viewDir = Vec3( view.m[2], view.m[6], view.m[10] ).Normalized();
frustum.Update( cameraTransform->GetWorldPosition(), viewDir );
GfxDeviceGlobal::perObjectUboStruct.cameraParams = Vec4( camera->GetFovDegrees() * 3.14159265f / 180.0f, camera->GetAspect(), camera->GetNear(), camera->GetFar() );
std::vector< unsigned > gameObjectsWithMeshRenderer;
gameObjectsWithMeshRenderer.reserve( gameObjects.size() );
int gameObjectIndex = -1;
for (auto gameObject : gameObjects)
{
++gameObjectIndex;
if (gameObject == nullptr || !gameObject->IsEnabled())
{
continue;
}
auto meshRenderer = gameObject->GetComponent< MeshRendererComponent >();
if (meshRenderer && meshRenderer->CastsShadow())
{
gameObjectsWithMeshRenderer.push_back( gameObjectIndex );
}
}
auto meshSorterByMesh = [&](unsigned j, unsigned k)
{
return gameObjects[ j ]->GetComponent< MeshRendererComponent >()->GetMesh() <
gameObjects[ k ]->GetComponent< MeshRendererComponent >()->GetMesh();
};
std::sort( std::begin( gameObjectsWithMeshRenderer ), std::end( gameObjectsWithMeshRenderer ), meshSorterByMesh );
for (auto j : gameObjectsWithMeshRenderer)
{
auto transform = gameObjects[ j ]->GetComponent< TransformComponent >();
auto meshLocalToWorld = transform ? transform->GetLocalToWorldMatrix() : Matrix44::identity;
Matrix44 localToView;
Matrix44 localToClip;
Matrix44::Multiply( meshLocalToWorld, view, localToView );
Matrix44::Multiply( localToView, camera->GetProjection(), localToClip );
auto* meshRenderer = gameObjects[ j ]->GetComponent< MeshRendererComponent >();
meshRenderer->Cull( frustum, meshLocalToWorld );
meshRenderer->Render( localToView, localToClip, meshLocalToWorld, SceneGlobal::shadowCameraViewMatrix, SceneGlobal::shadowCameraProjectionMatrix, &renderer.builtinShaders.momentsShader,
&renderer.builtinShaders.momentsSkinShader, MeshRendererComponent::RenderType::Opaque );
}
GfxDevice::PopGroupMarker();
#if RENDERER_METAL
GfxDevice::SetRenderTarget( nullptr, 0 );
#endif
#if RENDERER_VULKAN
EndOffscreen( 1, camera->GetTargetTexture() );
#endif
}
void ae3d::Scene::SetSkybox( TextureCube* skyTexture )
{
skybox = skyTexture;
}
std::string ae3d::Scene::GetSerialized() const
{
std::string outSerialized;
for (auto gameObject : gameObjects)
{
if (gameObject == nullptr)
{
continue;
}
outSerialized += gameObject->GetSerialized();
if (gameObject->GetComponent<MeshRendererComponent>())
{
outSerialized += ::GetSerialized( gameObject->GetComponent<MeshRendererComponent>() );
}
if (gameObject->GetComponent<TransformComponent>())
{
outSerialized += ::GetSerialized( gameObject->GetComponent<TransformComponent>() );
}
if (gameObject->GetComponent<CameraComponent>())
{
outSerialized += ::GetSerialized( gameObject->GetComponent<CameraComponent>() );
}
if (gameObject->GetComponent<SpriteRendererComponent>())
{
outSerialized += gameObject->GetComponent<SpriteRendererComponent>()->GetSerialized();
}
if (gameObject->GetComponent<TextRendererComponent>())
{
outSerialized += ::GetSerialized( gameObject->GetComponent<TextRendererComponent>() );
}
if (gameObject->GetComponent<AudioSourceComponent>())
{
outSerialized += ::GetSerialized( gameObject->GetComponent<AudioSourceComponent>() );
}
if (gameObject->GetComponent<DirectionalLightComponent>())
{
outSerialized += ::GetSerialized( gameObject->GetComponent<DirectionalLightComponent>() );
}
if (gameObject->GetComponent<SpotLightComponent>())
{
outSerialized += ::GetSerialized( gameObject->GetComponent<SpotLightComponent>() );
}
if (gameObject->GetComponent<PointLightComponent>())
{
outSerialized += ::GetSerialized( gameObject->GetComponent<PointLightComponent>() );
}
}
return outSerialized;
}
ae3d::Scene::DeserializeResult ae3d::Scene::Deserialize( const FileSystem::FileContentsData& serialized, std::vector< GameObject >& outGameObjects,
std::map< std::string, Texture2D* >& outTexture2Ds,
std::map< std::string, Material* >& outMaterials,
Array< Mesh* >& outMeshes ) const
{
// TODO: It would be better to store the token strings into somewhere accessible to GetSerialized() to prevent typos etc.
outGameObjects.clear();
std::stringstream stream( std::string( std::begin( serialized.data ), std::end( serialized.data ) ) );
std::string line;
std::string currentMaterialName;
enum class CurrentLightType { Directional, Spot, Point, None };
CurrentLightType currentLightType = CurrentLightType::None;
// FIXME: These ensure that the mesh is rendered. A proper fix would be to serialize materials.
static Shader tempShader;
tempShader.Load( "unlit_vertex", "unlit_fragment",
FileSystem::FileContents( "shaders/unlit_vert.obj" ), FileSystem::FileContents( "shaders/unlit_frag.obj" ),
FileSystem::FileContents( "shaders/unlit_vert.spv" ), FileSystem::FileContents( "shaders/unlit_frag.spv" ) );
Material* tempMaterial = new Material();
tempMaterial->SetShader( &tempShader );
tempMaterial->SetTexture( Texture2D::GetDefaultTexture(), 0 );
tempMaterial->SetBackFaceCulling( true );
outMaterials[ "temp material" ] = tempMaterial;
int textureUnit = 0;
int lineNo = 0;
while (!stream.eof())
{
std::getline( stream, line );
std::stringstream lineStream( line );
std::locale c_locale( "C" );
lineStream.imbue( c_locale );
std::string token;
lineStream >> token;
++lineNo;
if (token == "gameobject")
{
outGameObjects.push_back( GameObject() );
std::string name;
lineStream >> name;
outGameObjects.back().SetName( name.c_str() );
}
else if (token.empty())
{
}
else if (token == "name")
{
if (outGameObjects.empty())
{
System::Print( "Failed to parse %s at line %d: found \"name\" but there are no game objects defined before this line.\n", serialized.path.c_str(), lineNo );
return DeserializeResult::ParseError;
}
std::string name;
std::getline( lineStream, name );
outGameObjects.back().SetName( name.c_str() );
}
else if (token == "layer")
{
if (outGameObjects.empty())
{
System::Print( "Failed to parse %s at line %d: found \"layer\" but there are no game objects defined before this line.\n", serialized.path.c_str(), lineNo );
return DeserializeResult::ParseError;
}
int layer;
lineStream >> layer;
outGameObjects.back().SetLayer( layer );
}
else if (token == "enabled")
{
if (outGameObjects.empty())
{
System::Print( "Failed to parse %s at line %d: found \"enabled\" but there are no game objects defined before this line.\n", serialized.path.c_str(), lineNo );
return DeserializeResult::ParseError;
}
int enabled;
lineStream >> enabled;
outGameObjects.back().SetEnabled( enabled != 0 );
}
else if (token == "meshrenderer_enabled")
{
if (outGameObjects.empty())
{
System::Print( "Failed to parse %s at line %d: found \"meshrenderer_enabled\" but there are no game objects defined before this line.\n", serialized.path.c_str(), lineNo );
return DeserializeResult::ParseError;
}
int enabled;
lineStream >> enabled;
auto meshRenderer = outGameObjects.back().GetComponent< MeshRendererComponent >();
if (meshRenderer == nullptr)
{
System::Print( "Failed to parse %s at line %d: found \"meshrenderer_enabled\" but the game object doesn't have a mesh renderer component.\n", serialized.path.c_str(), lineNo );
return DeserializeResult::ParseError;
}
meshRenderer->SetEnabled( enabled != 0 );
}
else if (token == "transform_enabled")
{
if (outGameObjects.empty())
{
System::Print( "Failed to parse %s at line %d: found \"transform_enabled\" but there are no game objects defined before this line.\n", serialized.path.c_str(), lineNo );
return DeserializeResult::ParseError;
}
int enabled;
lineStream >> enabled;
auto transform = outGameObjects.back().GetComponent< TransformComponent >();
if (transform == nullptr)
{
System::Print( "Failed to parse %s at line %d: found \"transform_enabled\" but the game object doesn't have a transform component.\n", serialized.path.c_str(), lineNo );
return DeserializeResult::ParseError;
}
transform->SetEnabled( enabled != 0 );
}
else if (token == "camera_enabled")
{
if (outGameObjects.empty())
{
System::Print( "Failed to parse %s at line %d: found \"camera_enabled\" but there are no game objects defined before this line.\n", serialized.path.c_str(), lineNo );
return DeserializeResult::ParseError;
}
int enabled;
lineStream >> enabled;
auto camera = outGameObjects.back().GetComponent< CameraComponent >();
if (camera == nullptr)
{
System::Print( "Failed to parse %s at line %d: found \"camera_enabled\" but the game object doesn't have a camera component.\n", serialized.path.c_str(), lineNo );
return DeserializeResult::ParseError;
}
camera->SetEnabled( enabled != 0 );
}
else if (token == "dirlight")
{
if (outGameObjects.empty())
{
System::Print( "Failed to parse %s at line %d: found dirlight but there are no game objects defined before this line.\n", serialized.path.c_str(), lineNo );
return DeserializeResult::ParseError;
}
currentLightType = CurrentLightType::Directional;
outGameObjects.back().AddComponent< DirectionalLightComponent >();
int castsShadow = 0;
std::string shadowStr;
lineStream >> shadowStr;
lineStream >> castsShadow;
outGameObjects.back().GetComponent< DirectionalLightComponent >()->SetCastShadow( castsShadow != 0, 512 );
}
else if (token == "spotlight")
{
if (outGameObjects.empty())
{
System::Print( "Failed to parse %s at line %d: found spotlight but there are no game objects defined before this line.\n", serialized.path.c_str(), lineNo );
return DeserializeResult::ParseError;
}
currentLightType = CurrentLightType::Spot;
GameObject& go = outGameObjects.back();
go.AddComponent< SpotLightComponent >();
}
else if (token == "pointlight")
{
if (outGameObjects.empty())
{
System::Print( "Failed to parse %s at line %d: found pointlight but there are no game objects defined before this line.\n", serialized.path.c_str(), lineNo );
return DeserializeResult::ParseError;
}
currentLightType = CurrentLightType::Point;
GameObject& go = outGameObjects.back();
go.AddComponent< PointLightComponent >();
}
else if (token == "dirlight_enabled")
{
if (outGameObjects.empty())
{
System::Print( "Failed to parse %s at line %d: found \"dirlight_enabled\" but there are no game objects defined before this line.\n", serialized.path.c_str(), lineNo );
return DeserializeResult::ParseError;
}
int enabled;
lineStream >> enabled;
auto dirLight = outGameObjects.back().GetComponent< DirectionalLightComponent >();
if (dirLight == nullptr)
{
System::Print( "Failed to parse %s at line %d: found \"dirlight_enabled\" but the game object doesn't have a directional light component.\n", serialized.path.c_str(), lineNo );
return DeserializeResult::ParseError;
}
dirLight->SetEnabled( enabled != 0 );
}
else if (token == "spotlight_enabled")
{
if (outGameObjects.empty())
{
System::Print( "Failed to parse %s at line %d: found \"spotlight_enabled\" but there are no game objects defined before this line.\n", serialized.path.c_str(), lineNo );
return DeserializeResult::ParseError;
}
int enabled;
lineStream >> enabled;
auto spotLight = outGameObjects.back().GetComponent< SpotLightComponent >();
if (spotLight == nullptr)
{
System::Print( "Failed to parse %s at line %d: found \"spotlight_enabled\" but the game object doesn't have a spot light component.\n", serialized.path.c_str(), lineNo );
return DeserializeResult::ParseError;
}
spotLight->SetEnabled( enabled != 0 );
}
else if (token == "pointlight_enabled")
{
if (outGameObjects.empty())
{
System::Print( "Failed to parse %s at line %d: found \"pointlight_enabled\" but there are no game objects defined before this line.\n", serialized.path.c_str(), lineNo );
return DeserializeResult::ParseError;
}
int enabled;
lineStream >> enabled;
auto pointLight = outGameObjects.back().GetComponent< PointLightComponent >();
if (pointLight == nullptr)
{
System::Print( "Failed to parse %s at line %d: found \"spotlight_enabled\" but the game object doesn't have a spot light component.\n", serialized.path.c_str(), lineNo );
return DeserializeResult::ParseError;
}
pointLight->SetEnabled( enabled != 0 );
}
else if (token == "shadow")
{
if (outGameObjects.empty())
{
System::Print( "Failed to parse %s at line %d: found shadow but there are no game objects defined before this line.\n", serialized.path.c_str(), lineNo );
return DeserializeResult::ParseError;
}
int enabled;
lineStream >> enabled;
if (currentLightType == CurrentLightType::Directional)
{
outGameObjects.back().GetComponent< DirectionalLightComponent >()->SetCastShadow( enabled != 0, 1024 );
}
else if (currentLightType == CurrentLightType::Spot)
{
outGameObjects.back().GetComponent< SpotLightComponent >()->SetCastShadow( enabled != 0, 1024 );
}
else if (currentLightType == CurrentLightType::Point)
{
outGameObjects.back().GetComponent< PointLightComponent >()->SetCastShadow( enabled != 0, 1024 );
}
}
else if (token == "camera")
{
if (outGameObjects.empty())
{
System::Print( "Failed to parse %s at line %d: found camera but there are no game objects defined before this line.\n", serialized.path.c_str(), lineNo );
return DeserializeResult::ParseError;
}
outGameObjects.back().AddComponent< CameraComponent >();
}
else if (token == "ortho")
{
if (outGameObjects.empty())
{
System::Print( "Failed to parse %s at line %d: found ortho but there are no game objects defined before this line.\n", serialized.path.c_str(), lineNo );
return DeserializeResult::ParseError;
}
float x, y, width, height, nearp, farp;
lineStream >> x >> y >> width >> height >> nearp >> farp;
outGameObjects.back().GetComponent< CameraComponent >()->SetProjection( x, y, width, height, nearp, farp );
}
else if (token == "persp")
{
if (outGameObjects.empty())
{
System::Print( "Failed to parse %s at line %d: found persp but there are no game objects defined before this line.\n", serialized.path.c_str(), lineNo );
return DeserializeResult::ParseError;
}
float fov, aspect, nearp, farp;
lineStream >> fov >> aspect >> nearp >> farp;
outGameObjects.back().GetComponent< CameraComponent >()->SetProjection( fov, aspect, nearp, farp );
}
else if (token == "projection")
{
if (outGameObjects.empty())
{
System::Print( "Failed to parse %s at line %d: found projection but there are no game objects defined before this line.\n", serialized.path.c_str(), lineNo );
return DeserializeResult::ParseError;
}
std::string type;
lineStream >> type;
if (type == "orthographic")
{
outGameObjects.back().GetComponent< CameraComponent >()->SetProjectionType( ae3d::CameraComponent::ProjectionType::Orthographic );
}
else if (type == "perspective")
{
outGameObjects.back().GetComponent< CameraComponent >()->SetProjectionType( ae3d::CameraComponent::ProjectionType::Perspective );
}
else
{
System::Print( "Camera has unknown projection type %s\n", type.c_str() );
return DeserializeResult::ParseError;
}
}
else if (token == "clearcolor")
{
if (outGameObjects.empty())
{
System::Print( "Failed to parse %s at line %d: found clearcolor but there are no game objects defined before this line.\n", serialized.path.c_str() , lineNo );
return DeserializeResult::ParseError;
}
float red, green, blue;
lineStream >> red >> green >> blue;
outGameObjects.back().GetComponent< CameraComponent >()->SetClearColor( { red, green, blue } );
}
else if (token == "layermask")
{
if (outGameObjects.empty())
{
System::Print( "Failed to parse %s at line %d: found layermask but there are no game objects defined before this line.\n", serialized.path.c_str(), lineNo );
return DeserializeResult::ParseError;
}
unsigned layerMask;
lineStream >> layerMask;
outGameObjects.back().GetComponent< CameraComponent >()->SetLayerMask( layerMask );
}
else if (token == "viewport")
{
if (outGameObjects.empty())
{
System::Print( "Failed to parse %s at line %d: found viewport but there are no game objects defined before this line.\n", serialized.path.c_str(), lineNo );
return DeserializeResult::ParseError;
}
unsigned x, y, w, h;
lineStream >> x >> y >> w >> h;
outGameObjects.back().GetComponent< CameraComponent >()->SetViewport( x, y, w, h );
}
else if (token == "order")
{
if (outGameObjects.empty())
{
System::Print( "Failed to parse %s at line %d: found order but there are no game objects defined before this line.\n", serialized.path.c_str(), lineNo );
return DeserializeResult::ParseError;
}
unsigned order = 0;
lineStream >> order;
outGameObjects.back().GetComponent< CameraComponent >()->SetRenderOrder( order );
}
else if (token == "transform")
{
if (outGameObjects.empty())
{
System::Print( "Failed to parse %s at line %d: found transform but there are no game objects defined before this line.\n", serialized.path.c_str(), lineNo );
return DeserializeResult::ParseError;
}
outGameObjects.back().AddComponent< TransformComponent >();
}
else if (token == "meshrenderer_cast_shadow")
{
if (outGameObjects.empty())
{
System::Print( "Failed to parse %s at line %d: found meshrenderer_cast_shadow but there are no game objects defined before this line.\n", serialized.path.c_str(), lineNo );
return DeserializeResult::ParseError;
}
auto meshRenderer = outGameObjects.back().GetComponent< MeshRendererComponent >();
if (meshRenderer == nullptr)
{
System::Print( "Failed to parse %s at line %d: found mesh_cast_shadow but the game object doesn't have a mesh renderer component.\n", serialized.path.c_str(), lineNo );
return DeserializeResult::ParseError;
}
std::string str;
lineStream >> str;
meshRenderer->SetCastShadow( str == std::string( "1" ) );
}
else if (token == "meshrenderer")
{
if (outGameObjects.empty())
{
System::Print( "Failed to parse %s at line %d: found meshrenderer but there are no game objects defined before this line.\n", serialized.path.c_str(), lineNo );
return DeserializeResult::ParseError;
}
outGameObjects.back().AddComponent< MeshRendererComponent >();
}
else if (token == "meshpath")
{
if (outGameObjects.empty())
{
System::Print( "Failed to parse %s at line %d: found meshFile but there are no game objects defined before this line.\n", serialized.path.c_str(), lineNo );
return DeserializeResult::ParseError;
}
auto meshRenderer = outGameObjects.back().GetComponent< MeshRendererComponent >();
if (!meshRenderer)
{
System::Print( "Failed to parse %s at line %d: found meshpath but the game object doesn't have a mesh renderer component.\n", serialized.path.c_str(), lineNo );
return DeserializeResult::ParseError;
}
std::string meshFile;
lineStream >> meshFile;
Mesh* mesh = new Mesh();
outMeshes.Add( mesh );
outMeshes[ outMeshes.count - 1 ]->Load( FileSystem::FileContents( meshFile.c_str() ) );
meshRenderer->SetMesh( outMeshes[ outMeshes.count - 1 ] );
for (unsigned i = 0; i < mesh->GetSubMeshCount(); ++i)
{
meshRenderer->SetMaterial( tempMaterial, i );
}
}
else if (token == "spriterenderer")
{
if (outGameObjects.empty())
{
System::Print( "Failed to parse %s at line %d: found spriterenderer but there are no game objects defined before this line.\n", serialized.path.c_str(), lineNo );
return DeserializeResult::ParseError;
}
outGameObjects.back().AddComponent< SpriteRendererComponent >();
}
else if (token == "sprite")
{
if (outGameObjects.empty())
{
System::Print( "Failed to parse %s at line %d: found sprite but there are no game objects defined before this line.\n", serialized.path.c_str(), lineNo );
return DeserializeResult::ParseError;
}
if (!outGameObjects.back().GetComponent< SpriteRendererComponent >())
{
System::Print( "Failed to parse %s at line %d: found sprite but the game object doesn't have a sprite renderer component.\n", serialized.path.c_str(), lineNo );
return DeserializeResult::ParseError;
}
std::string spritePath;
float x, y, width, height;
lineStream >> spritePath >> x >> y >> width >> height;
outTexture2Ds[ spritePath ] = new Texture2D();
outTexture2Ds[ spritePath ]->Load( FileSystem::FileContents( spritePath.c_str() ), TextureWrap::Repeat, TextureFilter::Linear, Mipmaps::Generate, ColorSpace::SRGB, Anisotropy::k1 );
outGameObjects.back().GetComponent< SpriteRendererComponent >()->SetTexture( outTexture2Ds[ spritePath ], Vec3( x, y, 0 ), Vec3( x, y, 1 ), Vec4( 1, 1, 1, 1 ) );
}
else if (token == "position")
{
if (outGameObjects.empty())
{
System::Print( "Failed to parse %s at line %d: found position but there are no game objects defined before this line.\n", serialized.path.c_str(), lineNo );
return DeserializeResult::ParseError;
}
if (!outGameObjects.back().GetComponent< TransformComponent >())
{
System::Print( "Failed to parse %s at line %d: found position but the game object doesn't have a transform component.\n", serialized.path.c_str(), lineNo );
return DeserializeResult::ParseError;
}
float x, y, z;
lineStream >> x >> y >> z;
outGameObjects.back().GetComponent< TransformComponent >()->SetLocalPosition( { x, y, z } );
}
else if (token == "rotation")
{
if (outGameObjects.empty())
{
System::Print( "Failed to parse %s at line %d: found rotation but there are no game objects defined before this line.\n", serialized.path.c_str(), lineNo );
return DeserializeResult::ParseError;
}
if (!outGameObjects.back().GetComponent< TransformComponent >())
{
System::Print( "Failed to parse %s at line %d: found rotation but the game object doesn't have a transform component.\n", serialized.path.c_str(), lineNo );
return DeserializeResult::ParseError;
}
float x, y, z, s;
lineStream >> x >> y >> z >> s;
outGameObjects.back().GetComponent< TransformComponent >()->SetLocalRotation( { { x, y, z }, s } );
}
else if (token == "scale")
{
if (outGameObjects.empty())
{
System::Print( "Failed to parse %s at line %d: found scale but there are no game objects defined before this line.\n", serialized.path.c_str(), lineNo );
return DeserializeResult::ParseError;
}
if (!outGameObjects.back().GetComponent< TransformComponent >())
{
System::Print( "Failed to parse %s at line %d: found scale but the game object doesn't have a transform component.\n", serialized.path.c_str(), lineNo );
return DeserializeResult::ParseError;
}
float objScale;
lineStream >> objScale;
outGameObjects.back().GetComponent< TransformComponent >()->SetLocalScale( objScale );
}
else if (token == "texture2d")
{
std::string name;
std::string path;
lineStream >> name >> path;
if (!lineStream.eof())
{
std::string compressedTexturePath;
lineStream >> compressedTexturePath;
#if !TARGET_OS_IPHONE
if (compressedTexturePath.find( ".dds" ) != std::string::npos)
{
path = compressedTexturePath;
}
else if (!lineStream.eof())
{
lineStream >> compressedTexturePath;
if (compressedTexturePath.find( ".dds" ) != std::string::npos)
{
path = compressedTexturePath;
}
}
#endif
#if TARGET_OS_IPHONE
// FIXME: Temporarily disabled because sponza.scene refers non-existing files.
/*if (compressedTexturePath.find( ".astc" ) != std::string::npos)
{
path = compressedTexturePath;
}
else if (!lineStream.eof())
{
lineStream >> compressedTexturePath;
if (compressedTexturePath.find( ".astc" ) != std::string::npos)
{
path = compressedTexturePath;
}
}*/
#endif
}
outTexture2Ds[ name ] = new Texture2D();
if (path.find( "_n." ) != std::string::npos)
{
outTexture2Ds[ name ]->Load( FileSystem::FileContents( path.c_str() ), TextureWrap::Repeat, TextureFilter::Linear, Mipmaps::Generate, ColorSpace::Linear, Anisotropy::k1 );
}
else
{
outTexture2Ds[ name ]->Load( FileSystem::FileContents( path.c_str() ), TextureWrap::Repeat, TextureFilter::Linear, Mipmaps::Generate, ColorSpace::SRGB, Anisotropy::k1 );
}
}
else if (token == "material")
{
textureUnit = 0;
std::string materialName;
lineStream >> materialName;
currentMaterialName = materialName;
outMaterials[ materialName ] = new Material();
outMaterials[ materialName ]->SetTexture( Texture2D::GetDefaultTexture(), 0 );
outMaterials[ materialName ]->SetTexture( Texture2D::GetDefaultTexture(), 1 ); // This should really be a normal map.
}
else if (token == "mesh_material")
{
if (outGameObjects.empty())
{
System::Print( "Failed to parse %s at line %d: found mesh_material but there are no game objects defined before this line.\n", serialized.path.c_str(), lineNo );
return DeserializeResult::ParseError;
}
auto mr = outGameObjects.back().GetComponent< MeshRendererComponent >();
if (!mr)
{
System::Print( "Failed to parse %s at line %d: found mesh_material but the last defined game object doesn't have a mesh renderer component.\n", serialized.path.c_str(), lineNo );
return DeserializeResult::ParseError;
}
if (!mr->GetMesh())
{
System::Print( "Failed to parse %s at line %d: found mesh_material but the last defined game object's mesh renderer doesn't have a mesh.\n", serialized.path.c_str(), lineNo );
return DeserializeResult::ParseError;
}
std::string meshName;
std::string materialName;
lineStream >> meshName >> materialName;
const unsigned subMeshCount = mr->GetMesh()->GetSubMeshCount();
for (unsigned i = 0; i < subMeshCount; ++i)
{
if (mr->GetMesh()->GetSubMeshName( i ) == meshName)
{
mr->SetMaterial( outMaterials[ materialName ], i );
}
}
}
else if (token == "param_texture")
{
std::string uniformName;
std::string textureName;
lineStream >> uniformName >> textureName;
outMaterials[ currentMaterialName ]->SetTexture( outTexture2Ds[ textureName ], textureUnit );
++textureUnit;
if (textureUnit > 12)
{
System::Print( "Material %s uses too many textures! Max number is 13.\n", currentMaterialName.c_str() );
textureUnit = 0;
}
}
else if (token == "audiosource")
{
if (outGameObjects.empty())
{
System::Print( "Failed to parse %s at line %d: found audiosource but there are no game objects defined before this line.\n", serialized.path.c_str(), lineNo );
return DeserializeResult::ParseError;
}
outGameObjects.back().AddComponent< AudioSourceComponent >();
}
else if (token == "coneangle")
{
float coneAngleDegrees;
lineStream >> coneAngleDegrees;
if (currentLightType == CurrentLightType::Spot)
{
outGameObjects.back().GetComponent< SpotLightComponent >()->SetConeAngle( coneAngleDegrees );
}
else
{
System::Print( "Found 'coneangle' at line %d but no spotlight is defined before this line.\n", lineNo );
}
}
else if (token == "radius")
{
float radius;
lineStream >> radius;
if (currentLightType == CurrentLightType::Point)
{
outGameObjects.back().GetComponent< PointLightComponent >()->SetRadius( radius );
}
else if (currentLightType == CurrentLightType::Spot)
{
outGameObjects.back().GetComponent< SpotLightComponent >()->SetRadius( radius );
}
else
{
System::Print( "Found 'radius' but no spotlight or point light is defined before this line.\n" );
}
}
else if (token == "color")
{
Vec3 color;
lineStream >> color.x >> color.y >> color.z;
if (currentLightType == CurrentLightType::Spot)
{
outGameObjects.back().GetComponent< SpotLightComponent >()->SetColor( color );
}
else if (currentLightType == CurrentLightType::Directional)
{
outGameObjects.back().GetComponent< DirectionalLightComponent >()->SetColor( color );
}
else if (currentLightType == CurrentLightType::Point)
{
outGameObjects.back().GetComponent< PointLightComponent >()->SetColor( color );
}
else
{
System::Print( "Found \"color\" at line %d but there is no light before this line!\n", lineNo );
}
}
else if (token == "shaders")
{
if (currentMaterialName.empty())
{
System::Print( "Failed to parse %s at line %d: found 'metal_shaders' but there are no materials defined before this line.\n", serialized.path.c_str(), lineNo );
return DeserializeResult::ParseError;
}
std::string vertexShaderName, fragmentShaderName;
lineStream >> vertexShaderName >> fragmentShaderName;
std::string hlslVert = vertexShaderName + std::string( ".obj" );
std::string hlslFrag = fragmentShaderName + std::string( ".obj" );
std::string spvVert = vertexShaderName + std::string( "_vert.spv" );
std::string spvFrag = fragmentShaderName + std::string( "_frag.spv" );
Shader* shader = new Shader();
shader->Load( vertexShaderName.c_str(), fragmentShaderName.c_str(),
FileSystem::FileContents( hlslVert.c_str() ), FileSystem::FileContents( hlslFrag.c_str() ),
FileSystem::FileContents( spvVert.c_str() ), FileSystem::FileContents( spvFrag.c_str() ) );
outMaterials[ currentMaterialName ]->SetShader( shader );
}
else if (token == "metal_shaders")
{
#if RENDERER_METAL
if (currentMaterialName == "")
{
System::Print( "Failed to parse %s at line %d: found 'metal_shaders' but there are no materials defined before this line.\n", serialized.path.c_str(), lineNo );
return DeserializeResult::ParseError;
}
std::string vertexShaderName, fragmentShaderName;
lineStream >> vertexShaderName >> fragmentShaderName;
Shader* shader = new Shader();
shader->Load( vertexShaderName.c_str(), fragmentShaderName.c_str(),
FileSystem::FileContents( "unlit.hlsl" ), FileSystem::FileContents( "unlit.hlsl" ),
FileSystem::FileContents( "unlit_vert.spv" ), FileSystem::FileContents( "unlit_frag.spv" ) );
outMaterials[ currentMaterialName ]->SetShader( shader );
#endif
}
else
{
System::Print( "Scene parser: Unhandled token '%s' at line %d\n", token.c_str(), lineNo );
}
}
for (const auto& go : outGameObjects)
{
const auto mr = go.GetComponent< MeshRendererComponent >();
if (mr)
{
const unsigned subMeshCount = mr->GetMesh()->GetSubMeshCount();
for (unsigned i = 0; i < subMeshCount; ++i)
{
if (!mr->GetMaterial( i ))
{
System::Print( "Scene parser: missing material for mesh renderer in game object %s in subMesh %s\n", go.GetName(), mr->GetMesh()->GetSubMeshName( i ) );
}
}
}
}
return DeserializeResult::Success;
}
void ae3d::Scene::GenerateAABB()
{
Statistics::BeginSceneAABB();
const float maxValue = 99999999.0f;
aabbMin = { maxValue, maxValue, maxValue };
aabbMax = { -maxValue, -maxValue, -maxValue };
for (auto& o : gameObjects)
{
if (!o)
{
continue;
}
auto meshRenderer = o->GetComponent< ae3d::MeshRendererComponent >();
auto meshTransform = o->GetComponent< ae3d::TransformComponent >();
if (meshRenderer == nullptr || meshTransform == nullptr)
{
continue;
}
Vec3 oAABBmin = meshRenderer->GetMesh() ? meshRenderer->GetMesh()->GetAABBMin() : Vec3( -1, -1, -1 );
Vec3 oAABBmax = meshRenderer->GetMesh() ? meshRenderer->GetMesh()->GetAABBMax() : Vec3( 1, 1, 1 );
Matrix44::TransformPoint( oAABBmin, meshTransform->GetLocalToWorldMatrix(), &oAABBmin );
Matrix44::TransformPoint( oAABBmax, meshTransform->GetLocalToWorldMatrix(), &oAABBmax );
if (oAABBmin.x < aabbMin.x)
{
aabbMin.x = oAABBmin.x;
}
if (oAABBmin.y < aabbMin.y)
{
aabbMin.y = oAABBmin.y;
}
if (oAABBmin.z < aabbMin.z)
{
aabbMin.z = oAABBmin.z;
}
if (oAABBmax.x > aabbMax.x)
{
aabbMax.x = oAABBmax.x;
}
if (oAABBmax.y > aabbMax.y)
{
aabbMax.y = oAABBmax.y;
}
if (oAABBmax.z > aabbMax.z)
{
aabbMax.z = oAABBmax.z;
}
}
Statistics::EndSceneAABB();
}
| 40.899739 | 309 | 0.599275 | [
"mesh",
"render",
"object",
"vector",
"transform"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.