111 TEST_EXPECT_EQUAL(px->mix(0.5, *py)->mix(2/3.0, *pz)->inspect(),
"(0.333,0.333,0.333)");
134 TEST_EXPECT_EQUAL(pxy->mix(INFINITY, *PonlyZ)->inspect(),
"(0.500,0.500,0.500)");
135 TEST_EXPECT_EQUAL(pyz->mix(INFINITY, *PonlyX)->inspect(),
"(0.500,0.500,0.500)");
136 TEST_EXPECT_EQUAL(pzx->mix(INFINITY, *PonlyY)->inspect(),
"(0.500,0.500,0.500)");
172 void TEST_value_color_mapping() {
175 const float NOSHIFT = 0.0;
179 Phaser halfPhase (0.5,
false, NOSHIFT, NOSHIFT);
180 Phaser halfPhasePreShiftPos(0.5,
false, +0.25, NOSHIFT);
181 Phaser halfPhasePreShiftNeg(0.5,
false, +0.75, NOSHIFT);
182 Phaser halfPhasePstShiftPos(0.5,
false, NOSHIFT, +0.25);
183 Phaser halfPhasePstShiftNeg(0.5,
false, NOSHIFT, +0.75);
185 Phaser twoPhase (2.0,
false, NOSHIFT, NOSHIFT);
186 Phaser alt3Phase(3.0,
true, NOSHIFT, NOSHIFT);
187 Phaser alt4Phase(4.0,
true, NOSHIFT, NOSHIFT);
219 #define PQS(c) (AW_PLANAR_COLORS*(c)/4)
220 #define PLANAR_QUARTER_SHIFT(x,y) (PQS(x)*AW_PLANAR_COLORS + PQS(y))
224 #define DOCQS(x,y,res) TEST_EXPECT_EQUAL(PLANAR_QUARTER_SHIFT(x,y), res)
226 DOCQS(0,0,0); DOCQS(1,0,1024); DOCQS(2,0,2048); DOCQS(3,0,3072); DOCQS(4,0,4096);
227 DOCQS(0,1,16); DOCQS(1,1,1040); DOCQS(2,1,2064); DOCQS(3,1,3088); DOCQS(4,1,4112);
228 DOCQS(0,2,32); DOCQS(1,2,1056); DOCQS(2,2,2080); DOCQS(3,2,3104); DOCQS(4,2,4128);
229 DOCQS(0,3,48); DOCQS(1,3,1072); DOCQS(2,3,2096); DOCQS(3,3,3120); DOCQS(4,3,4144);
230 DOCQS(0,4,64); DOCQS(1,4,1088); DOCQS(2,4,2112); DOCQS(3,4,3136); DOCQS(4,4,4160);
256 TEST_EXPECT_EQUAL(px->range_offset(halfPhasePreShiftPos), PLANAR_QUARTER_SHIFT(3, 3)/2);
257 TEST_EXPECT_EQUAL(px->range_offset(halfPhasePreShiftNeg), PLANAR_QUARTER_SHIFT(1, 1)/2);
258 TEST_EXPECT_EQUAL(px->range_offset(halfPhasePstShiftPos), PLANAR_QUARTER_SHIFT(3, 1));
259 TEST_EXPECT_EQUAL(px->range_offset(halfPhasePstShiftNeg), PLANAR_QUARTER_SHIFT(1, 3));
263 TEST_EXPECT_EQUAL(py->range_offset(halfPhasePreShiftPos), PLANAR_QUARTER_SHIFT(3, 3)/2);
264 TEST_EXPECT_EQUAL(py->range_offset(halfPhasePreShiftNeg), PLANAR_QUARTER_SHIFT(1, 1)/2);
265 TEST_EXPECT_EQUAL(py->range_offset(halfPhasePstShiftPos), PLANAR_QUARTER_SHIFT(1, 3));
266 TEST_EXPECT_EQUAL(py->range_offset(halfPhasePstShiftNeg), PLANAR_QUARTER_SHIFT(3, 1));
271 TEST_EXPECT_EQUAL(PonlyX->range_offset(halfPhasePreShiftPos), PLANAR_QUARTER_SHIFT(1, 0)/2);
272 TEST_EXPECT_EQUAL(PonlyX->range_offset(halfPhasePreShiftNeg), PLANAR_QUARTER_SHIFT(3, 0)/2);
273 TEST_EXPECT_EQUAL(PonlyX->range_offset(halfPhasePstShiftPos), PLANAR_QUARTER_SHIFT(2, 0));
274 TEST_EXPECT_EQUAL(PonlyX->range_offset(halfPhasePstShiftNeg), PLANAR_QUARTER_SHIFT(4,-4));
276 TEST_EXPECT_EQUAL(PonlyY->range_offset(twoPhase), PLANAR_QUARTER_SHIFT(0, 4) - 1);
278 TEST_EXPECT_EQUAL(PonlyY->range_offset(halfPhasePreShiftPos), PLANAR_QUARTER_SHIFT(0, 1)/2);
279 TEST_EXPECT_EQUAL(PonlyY->range_offset(halfPhasePreShiftNeg), PLANAR_QUARTER_SHIFT(0, 3)/2);
280 TEST_EXPECT_EQUAL(PonlyY->range_offset(halfPhasePstShiftPos), PLANAR_QUARTER_SHIFT(0, 2));
281 TEST_EXPECT_EQUAL(PonlyY->range_offset(halfPhasePstShiftNeg), PLANAR_QUARTER_SHIFT(0, 4) - 1);
320 template<
int RANGE_SIZE>
323 int off = val>=1.0 ? RANGE_SIZE-1 : val*RANGE_SIZE;
335 void TEST_range_mapping() {
367 #if defined(UNIT_TESTS)
368 const char *inspect() const
OVERRIDE {
return "<undef>"; }
393 #if defined(UNIT_TESTS)
394 const char *inspect() const
OVERRIDE {
395 static SmartCharPtr buf;
403 return new LinearTuple(other_ratio*other.val + (1-other_ratio)*val);
408 inline float mix_floats(
float me,
float my_ratio,
float other) {
409 if (
is_nan(me))
return other;
410 if (
is_nan(other))
return me;
411 return my_ratio*me + (1-my_ratio)*other;
431 int c1 =
is_nan(val1) ? 0 : fixed_range_offset<AW_PLANAR_COLORS>(phaser.rephase(val1));
432 int c2 =
is_nan(val2) ? 0 : fixed_range_offset<AW_PLANAR_COLORS>(phaser.rephase(val2));
436 #if defined(UNIT_TESTS)
437 const char *inspect() const
OVERRIDE {
438 static SmartCharPtr buf;
446 return new PlanarTuple(
mix_floats(other.val1, other_ratio, val1),
453 float val1, val2, val3;
471 int c1 =
is_nan(val1) ? 0 : fixed_range_offset<AW_SPATIAL_COLORS>(phaser.rephase(val1));
472 int c2 =
is_nan(val2) ? 0 : fixed_range_offset<AW_SPATIAL_COLORS>(phaser.rephase(val2));
473 int c3 =
is_nan(val3) ? 0 : fixed_range_offset<AW_SPATIAL_COLORS>(phaser.rephase(val3));
477 #if defined(UNIT_TESTS)
478 const char *inspect() const
OVERRIDE {
479 static SmartCharPtr buf;
487 return new SpatialTuple(
mix_floats(other.val1, other_ratio, val1),
static ShadedValue make(float f)
ShadedValue clone() const OVERRIDE
PlanarTuple(float val1_, float val2_)
#define TEST_PUBLISH(testfunction)
#define TEST_EXPECT(cond)
int range_offset(const Phaser &phaser) const OVERRIDE
#define TEST_REJECT(cond)
ShadedValue reverse_mix(float other_ratio, const PlanarTuple &other) const OVERRIDE
ShadedValue reverse_mix(float other_ratio, const SpatialTuple &other) const OVERRIDE
float mix_floats(float me, float my_ratio, float other)
int CHECKED_RANGE_OFFSET(int off)
ShadedValue reverse_mix(float other_ratio, const LinearTuple &other) const OVERRIDE
ShadedValue reverse_mix(float, const LinearTuple &other) const OVERRIDE
int fixed_range_offset(float val)
int range_offset(const Phaser &) const OVERRIDE
ShadedValue mix(float, const ValueTuple &other) const OVERRIDE
static ShadedValue undefined()
ShadedValue clone() const OVERRIDE
ShadedValue mix(float my_ratio, const ValueTuple &other) const OVERRIDE
#define __ATTR__REDUCED_OPTIMIZE__NO_GCSE
SpatialTuple(float val1_, float val2_, float val3_)
bool is_defined() const OVERRIDE
#define AW_SPATIAL_COLORS
bool is_defined() const OVERRIDE
#define TEST_EXPECT_EQUAL(expr, want)
char * GBS_global_string_copy(const char *templat,...)