Lumiera  0.pre.03
»edit your freedom«
test-rand-ontology.cpp
Go to the documentation of this file.
1 /*
2  TestRandOntoloy - implementation of a test framework processing dummy data frames
3 
4  Copyright (C)
5  2024, Hermann Vosseler <Ichthyostega@web.de>
6 
7   **Lumiera** is free software; you can redistribute it and/or modify it
8   under the terms of the GNU General Public License as published by the
9   Free Software Foundation; either version 2 of the License, or (at your
10   option) any later version. See the file COPYING for further details.
11 
12 * *****************************************************************/
13 
27 #include "lib/hash-combine.hpp"
28 #include "lib/iter-zip.hpp"
29 
30 #include <cmath>
31 
32 using std::lround;
33 using lib::zip;
34 
35 
36 namespace steam {
37 namespace engine{
38 namespace test {
39 // namespace err = lumiera::error;
40 
41  namespace { // hidden local support facilities....
42 
43  } // (End) hidden impl details
44 
45 
46  const string DUMMY_FUN_ID{"dummyFun(TestFrame)"};
47 
48  /* ========= Dummy implementation of Media processing ========= */
49 
55  void
56  generateFrame (TestFrame* buff, size_t frameNr, uint flavour)
57  {
58  REQUIRE (buff);
59  new(buff) TestFrame{uint(frameNr), flavour};
60  }
61 
72  void
73  generateMultichan (TestFrame* buffArry, uint chanCnt, size_t frameNr, uint flavour)
74  {
75  REQUIRE (buffArry);
76  for (uint i=0; i<chanCnt; ++i)
77  new(buffArry+i) TestFrame{uint(frameNr), flavour+i};
78  }
79 
85  void
86  duplicateMultichan (TestFrame* outArry, TestFrame* inArry, uint chanCnt)
87  {
88  REQUIRE (inArry);
89  REQUIRE (outArry);
90  for (uint i=0; i<chanCnt; ++i)
91  new(outArry+i) TestFrame{inArry[i]};
92  }
93 
102  void
103  manipulateMultichan (TestFrame* buffArry, uint chanCnt, uint64_t param)
104  {
105  REQUIRE (buffArry);
106  const uint SIZ = buffArry->data64().size();
107  for (uint i=0; i<SIZ; ++i)
108  {
109  uint64_t feed{param};
110  for (uint c=0; c<chanCnt; ++c)
111  {
112  auto& data = buffArry[c].data64()[i];
113  lib::hash::combine(feed, data);
114  data = feed;
115  }
116  }
117  for (uint c=0; c<chanCnt; ++c)
118  buffArry[c].markChecksum();
119  }
120 
128  void
129  manipulateFrame (TestFrame* out, TestFrame const* in, uint64_t param)
130  {
131  REQUIRE (in);
132  REQUIRE (out);
133  auto calculate = [](uint64_t chain, uint64_t val){ lib::hash::combine(chain,val); return chain; };
134  for (auto& [res,src] : zip (out->data64(), in->data64()))
135  res = calculate(param, src);
136  out->markChecksum();
137  }
138 
147  void
148  combineFrames (TestFrame* out, TestFrame const* srcA, TestFrame const* srcB, double mix)
149  {
150  REQUIRE (srcA);
151  REQUIRE (srcB);
152  REQUIRE (out);
153  for (auto& [res,inA,inB] : zip (out->data()
154  ,srcA->data()
155  ,srcB->data()))
156  res = lround((1-mix)*inA + mix*inB);
157  out->markChecksum();
158  }
159 
160 
161 
162  /* =========== Test-Rand-Ontology ================ */
163 
166 
167 
168 
169 }}} // namespace steam::engine::test
void manipulateMultichan(TestFrame *buffArry, uint chanCnt, uint64_t param)
»process« a planar multi channel array of data frames in-place.
Mock data frame for simulated rendering.
Definition: testframe.hpp:68
void generateMultichan(TestFrame *buffArry, uint chanCnt, size_t frameNr, uint flavour)
produce planar multi channel output of random data frames
Definition: run.hpp:40
_Arr & data()
Array-style direct access to the payload data.
Definition: testframe.hpp:132
void combine(size_t &combinedHash, size_t additionalHash)
meld the additional hash value into the given base hash value.
A faked »media calculation« environment to validate the render node network.
void generateFrame(TestFrame *buff, size_t frameNr, uint flavour)
produce sequences of frames with (reproducible) random data
Steam-Layer implementation namespace root.
void duplicateMultichan(TestFrame *outArry, TestFrame *inArry, uint chanCnt)
create an identical clone copy of the planar multi channel frame array
Access point to singletons and other kinds of dependencies designated by type.
Definition: depend.hpp:280
Iterator builder to combine several iterables into a tuple sequence.
void manipulateFrame(TestFrame *out, TestFrame const *in, uint64_t param)
»process« random frame date by hash-chaining with a parameter.
void combineFrames(TestFrame *out, TestFrame const *srcA, TestFrame const *srcB, double mix)
mix two random data frames by a parameter-controlled proportion
HashVal markChecksum()
recompute and store checksum based on current contents
Definition: testframe.cpp:364
lib::Depend< TestRandOntology > testRand
Storage for the Singleton-Accessor/Factory.
auto zip(ITS &&...iters)
Build a tuple-combining iterator builder.
Definition: iter-zip.hpp:138