2024-10-31 23:50:59 +01:00
|
|
|
|
/*
|
|
|
|
|
|
TestRandOntoloy - implementation of a test framework processing dummy data frames
|
|
|
|
|
|
|
Copyright: clarify and simplify the file headers
* Lumiera source code always was copyrighted by individual contributors
* there is no entity "Lumiera.org" which holds any copyrights
* Lumiera source code is provided under the GPL Version 2+
== Explanations ==
Lumiera as a whole is distributed under Copyleft, GNU General Public License Version 2 or above.
For this to become legally effective, the ''File COPYING in the root directory is sufficient.''
The licensing header in each file is not strictly necessary, yet considered good practice;
attaching a licence notice increases the likeliness that this information is retained
in case someone extracts individual code files. However, it is not by the presence of some
text, that legally binding licensing terms become effective; rather the fact matters that a
given piece of code was provably copyrighted and published under a license. Even reformatting
the code, renaming some variables or deleting parts of the code will not alter this legal
situation, but rather creates a derivative work, which is likewise covered by the GPL!
The most relevant information in the file header is the notice regarding the
time of the first individual copyright claim. By virtue of this initial copyright,
the first author is entitled to choose the terms of licensing. All further
modifications are permitted and covered by the License. The specific wording
or format of the copyright header is not legally relevant, as long as the
intention to publish under the GPL remains clear. The extended wording was
based on a recommendation by the FSF. It can be shortened, because the full terms
of the license are provided alongside the distribution, in the file COPYING.
2024-11-17 23:42:55 +01:00
|
|
|
|
Copyright (C)
|
|
|
|
|
|
2024, Hermann Vosseler <Ichthyostega@web.de>
|
2024-10-31 23:50:59 +01:00
|
|
|
|
|
Copyright: clarify and simplify the file headers
* Lumiera source code always was copyrighted by individual contributors
* there is no entity "Lumiera.org" which holds any copyrights
* Lumiera source code is provided under the GPL Version 2+
== Explanations ==
Lumiera as a whole is distributed under Copyleft, GNU General Public License Version 2 or above.
For this to become legally effective, the ''File COPYING in the root directory is sufficient.''
The licensing header in each file is not strictly necessary, yet considered good practice;
attaching a licence notice increases the likeliness that this information is retained
in case someone extracts individual code files. However, it is not by the presence of some
text, that legally binding licensing terms become effective; rather the fact matters that a
given piece of code was provably copyrighted and published under a license. Even reformatting
the code, renaming some variables or deleting parts of the code will not alter this legal
situation, but rather creates a derivative work, which is likewise covered by the GPL!
The most relevant information in the file header is the notice regarding the
time of the first individual copyright claim. By virtue of this initial copyright,
the first author is entitled to choose the terms of licensing. All further
modifications are permitted and covered by the License. The specific wording
or format of the copyright header is not legally relevant, as long as the
intention to publish under the GPL remains clear. The extended wording was
based on a recommendation by the FSF. It can be shortened, because the full terms
of the license are provided alongside the distribution, in the file COPYING.
2024-11-17 23:42:55 +01:00
|
|
|
|
**Lumiera** 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. See the file COPYING for further details.
|
2024-10-31 23:50:59 +01:00
|
|
|
|
|
Copyright: clarify and simplify the file headers
* Lumiera source code always was copyrighted by individual contributors
* there is no entity "Lumiera.org" which holds any copyrights
* Lumiera source code is provided under the GPL Version 2+
== Explanations ==
Lumiera as a whole is distributed under Copyleft, GNU General Public License Version 2 or above.
For this to become legally effective, the ''File COPYING in the root directory is sufficient.''
The licensing header in each file is not strictly necessary, yet considered good practice;
attaching a licence notice increases the likeliness that this information is retained
in case someone extracts individual code files. However, it is not by the presence of some
text, that legally binding licensing terms become effective; rather the fact matters that a
given piece of code was provably copyrighted and published under a license. Even reformatting
the code, renaming some variables or deleting parts of the code will not alter this legal
situation, but rather creates a derivative work, which is likewise covered by the GPL!
The most relevant information in the file header is the notice regarding the
time of the first individual copyright claim. By virtue of this initial copyright,
the first author is entitled to choose the terms of licensing. All further
modifications are permitted and covered by the License. The specific wording
or format of the copyright header is not legally relevant, as long as the
intention to publish under the GPL remains clear. The extended wording was
based on a recommendation by the FSF. It can be shortened, because the full terms
of the license are provided alongside the distribution, in the file COPYING.
2024-11-17 23:42:55 +01:00
|
|
|
|
* *****************************************************************/
|
2024-10-31 23:50:59 +01:00
|
|
|
|
|
|
|
|
|
|
/** @file test-rand-ontology.cpp
|
|
|
|
|
|
** Implementation of fake data processing to verify invocation logic.
|
2024-11-20 21:44:50 +01:00
|
|
|
|
** The emulated »media computations« work on TestFrame data buffers, which can be
|
|
|
|
|
|
** filled with deterministically generated pseudo-random data, that can be verified afterwards.
|
|
|
|
|
|
** Computations manipulate or combine individual data points, and mark the result again with a
|
|
|
|
|
|
** valid checksum. Hash-chaining computations are used in order to ensure that the resulting
|
|
|
|
|
|
** data values depend on all input- and parameter values, and the _exact order_ of processing.
|
|
|
|
|
|
** All computations are reproducible, and thus a test can verify a computation carried out
|
|
|
|
|
|
** within the context of the Render-Engine code.
|
2024-10-31 23:50:59 +01:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "steam/engine/test-rand-ontology.hpp"
|
2024-11-20 21:44:50 +01:00
|
|
|
|
#include "lib/hash-combine.hpp"
|
2024-11-27 15:31:50 +01:00
|
|
|
|
#include "lib/iter-zip.hpp"
|
2024-10-31 23:50:59 +01:00
|
|
|
|
|
2024-11-27 15:31:50 +01:00
|
|
|
|
#include <cmath>
|
2024-10-31 23:50:59 +01:00
|
|
|
|
|
2024-11-27 15:31:50 +01:00
|
|
|
|
using std::lround;
|
|
|
|
|
|
using lib::zip;
|
2024-10-31 23:50:59 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace steam {
|
|
|
|
|
|
namespace engine{
|
|
|
|
|
|
namespace test {
|
|
|
|
|
|
// namespace err = lumiera::error;
|
|
|
|
|
|
|
2025-01-06 19:47:51 +01:00
|
|
|
|
using ont::FraNo;
|
|
|
|
|
|
using ont::ChaNo;
|
|
|
|
|
|
using ont::Flavr;
|
|
|
|
|
|
using ont::Factr;
|
|
|
|
|
|
using ont::Param;
|
|
|
|
|
|
|
2024-10-31 23:50:59 +01:00
|
|
|
|
namespace { // hidden local support facilities....
|
|
|
|
|
|
|
|
|
|
|
|
} // (End) hidden impl details
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-11-03 23:58:25 +01:00
|
|
|
|
const string DUMMY_FUN_ID{"dummyFun(TestFrame)"};
|
2024-10-31 23:50:59 +01:00
|
|
|
|
|
2024-11-05 21:23:13 +01:00
|
|
|
|
/* ========= Dummy implementation of Media processing ========= */
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* @param buff a sufficiently sized allocation to place the result data into
|
|
|
|
|
|
* @param frameNr the frame of the »source feed« to generate (determines actual random data)
|
|
|
|
|
|
* @param flavour a further seed parameter to determine the actual (reproducibly) random data
|
|
|
|
|
|
*/
|
|
|
|
|
|
void
|
2025-01-06 19:47:51 +01:00
|
|
|
|
generateFrame (TestFrame* buff, FraNo frameNr, Flavr flavour)
|
2024-11-05 21:23:13 +01:00
|
|
|
|
{
|
|
|
|
|
|
REQUIRE (buff);
|
|
|
|
|
|
new(buff) TestFrame{uint(frameNr), flavour};
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* @param chanCnt size of the array of frames to generate
|
|
|
|
|
|
* @param buffArry pointer to an allocation sufficiently sized to hold `TestFrame[chanCnt]`
|
|
|
|
|
|
* @param frameNr the frame of the »source feed« to use commonly on all those frames in the output
|
|
|
|
|
|
* @param flavour a further seed parameter used as starting offest for the output's `family` parameters
|
|
|
|
|
|
* @remark this is a variation of the [dummy data generator](\ref #generateFrame),
|
|
|
|
|
|
* which immediately generates a planar block of related frames with random data,
|
|
|
|
|
|
* all seeded with the _same_ `frameNr` and _consecutive_ `family` parameters,
|
|
|
|
|
|
* which will be offset commonly by adding the \a flavour parameter.
|
|
|
|
|
|
*/
|
|
|
|
|
|
void
|
2025-01-06 19:47:51 +01:00
|
|
|
|
generateMultichan (TestFrame* buffArry, ChaNo chanCnt, FraNo frameNr, Flavr flavour)
|
2024-11-05 21:23:13 +01:00
|
|
|
|
{
|
|
|
|
|
|
REQUIRE (buffArry);
|
|
|
|
|
|
for (uint i=0; i<chanCnt; ++i)
|
|
|
|
|
|
new(buffArry+i) TestFrame{uint(frameNr), flavour+i};
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-11-28 02:15:59 +01:00
|
|
|
|
/**
|
|
|
|
|
|
* @param chanCnt size of the array of frames to clone
|
|
|
|
|
|
* @param inArry pointer to storage holding a TestFrame[chanCnt]
|
|
|
|
|
|
* @param outArry pointer to allocated storage sufficient to hold a clone copy of these
|
|
|
|
|
|
*/
|
|
|
|
|
|
void
|
2025-01-06 19:47:51 +01:00
|
|
|
|
duplicateMultichan (TestFrame* outArry, TestFrame* inArry, ChaNo chanCnt)
|
2024-11-28 02:15:59 +01:00
|
|
|
|
{
|
|
|
|
|
|
REQUIRE (inArry);
|
|
|
|
|
|
REQUIRE (outArry);
|
|
|
|
|
|
for (uint i=0; i<chanCnt; ++i)
|
|
|
|
|
|
new(outArry+i) TestFrame{inArry[i]};
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* @param chanCnt size of the array of frames to manipulate
|
|
|
|
|
|
* @param buffArry pointer to an array of several frames (channels)
|
|
|
|
|
|
* @param param parameter to control or »mark« the data manipulation (hash-combining)
|
|
|
|
|
|
* @remark this function in-place processing of several channels in one step: data is processed
|
|
|
|
|
|
* in 64-bit words, by hash-chaining with \a param and then joining in the data items.
|
|
|
|
|
|
* All data buffers will be manipulated and marked with as valid with a new checksum.
|
|
|
|
|
|
*/
|
|
|
|
|
|
void
|
2025-01-06 19:47:51 +01:00
|
|
|
|
manipulateMultichan (TestFrame* buffArry, ChaNo chanCnt, Param param)
|
2024-11-28 02:15:59 +01:00
|
|
|
|
{
|
|
|
|
|
|
REQUIRE (buffArry);
|
|
|
|
|
|
const uint SIZ = buffArry->data64().size();
|
|
|
|
|
|
for (uint i=0; i<SIZ; ++i)
|
|
|
|
|
|
{
|
|
|
|
|
|
uint64_t feed{param};
|
|
|
|
|
|
for (uint c=0; c<chanCnt; ++c)
|
|
|
|
|
|
{
|
|
|
|
|
|
auto& data = buffArry[c].data64()[i];
|
|
|
|
|
|
lib::hash::combine(feed, data);
|
|
|
|
|
|
data = feed;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
for (uint c=0; c<chanCnt; ++c)
|
|
|
|
|
|
buffArry[c].markChecksum();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-11-05 21:23:13 +01:00
|
|
|
|
/**
|
|
|
|
|
|
* @param out existing allocation to place the generated TestFrame into
|
|
|
|
|
|
* @param in allocation holding the input TestFrame data
|
2024-11-20 21:44:50 +01:00
|
|
|
|
* @param param parameter to control or »mark« the data manipulation (hash-combining)
|
|
|
|
|
|
* @remark this function emulates „media data processing“: data is processed in 64-bit words,
|
|
|
|
|
|
* by hash-chaining with \a param. The generated result is marked with a valid checksum.
|
2024-11-05 21:23:13 +01:00
|
|
|
|
*/
|
|
|
|
|
|
void
|
2025-01-06 19:47:51 +01:00
|
|
|
|
manipulateFrame (TestFrame* out, TestFrame const* in, Param param)
|
2024-11-05 21:23:13 +01:00
|
|
|
|
{
|
|
|
|
|
|
REQUIRE (in);
|
|
|
|
|
|
REQUIRE (out);
|
2024-11-20 21:44:50 +01:00
|
|
|
|
auto calculate = [](uint64_t chain, uint64_t val){ lib::hash::combine(chain,val); return chain; };
|
2024-11-27 15:31:50 +01:00
|
|
|
|
for (auto& [res,src] : zip (out->data64(), in->data64()))
|
|
|
|
|
|
res = calculate(param, src);
|
2024-11-20 21:44:50 +01:00
|
|
|
|
out->markChecksum();
|
2024-11-05 21:23:13 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* @param out existing allocation to receive the calculated result TestFrame
|
|
|
|
|
|
* @param srcA a buffer holding the input data for feed-A
|
|
|
|
|
|
* @param srcB a buffer holding the input data for feed-B
|
|
|
|
|
|
* @param mix degree of mixing (by integer arithmetics): 100 means 100% feed-B
|
|
|
|
|
|
* @remark this function emulates a mixing or overlaying operation:
|
|
|
|
|
|
* each result byte is the linear interpolation between the corresponding inputs.
|
|
|
|
|
|
*/
|
|
|
|
|
|
void
|
2025-01-06 19:47:51 +01:00
|
|
|
|
combineFrames (TestFrame* out, TestFrame const* srcA, TestFrame const* srcB, Factr mix)
|
2024-11-05 21:23:13 +01:00
|
|
|
|
{
|
|
|
|
|
|
REQUIRE (srcA);
|
|
|
|
|
|
REQUIRE (srcB);
|
|
|
|
|
|
REQUIRE (out);
|
2024-11-27 15:31:50 +01:00
|
|
|
|
for (auto& [res,inA,inB] : zip (out->data()
|
|
|
|
|
|
,srcA->data()
|
|
|
|
|
|
,srcB->data()))
|
|
|
|
|
|
res = lround((1-mix)*inA + mix*inB);
|
2024-11-20 21:44:50 +01:00
|
|
|
|
out->markChecksum();
|
2024-11-05 21:23:13 +01:00
|
|
|
|
}
|
2024-10-31 23:50:59 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-11-28 23:41:56 +01:00
|
|
|
|
/* =========== Test-Rand-Ontology ================ */
|
|
|
|
|
|
|
|
|
|
|
|
/** Storage for the Singleton-Accessor/Factory */
|
|
|
|
|
|
lib::Depend<TestRandOntology> testRand;
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-10-31 23:50:59 +01:00
|
|
|
|
|
|
|
|
|
|
}}} // namespace steam::engine::test
|