GCC Code Coverage Report


Directory: ./
File: channeltester/RGBChase.cpp
Date: 2026-10-29 08:11:58
Exec Total Coverage
Lines: 72 72 100.0%
Functions: 6 6 100.0%
Branches: 42 58 72.4%

Line Branch Exec Source
1 /*
2 * This file is part of the Falcon Player (FPP) and is Copyright (C)
3 * 2013-2022 by the Falcon Player Developers.
4 *
5 * The Falcon Player (FPP) is free software, and is covered under
6 * multiple Open Source licenses. Please see the included 'LICENSES'
7 * file for descriptions of what files are covered by each license.
8 *
9 * This source file is covered under the LGPL v2.1 as described in the
10 * included LICENSE.LGPL file.
11 */
12
13 #include "fpp-pch.h"
14
15 #include "fpp-json.h"
16
17 #include "../log.h"
18
19 #include "RGBChase.h"
20
21 /*
22 *
23 */
24 32 TestPatternRGBChase::TestPatternRGBChase() :
25
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 m_colorPatternStr(""),
26 32 m_colorPatternSize(0),
27 32 m_patternOffset(0),
28 32 m_rgbTriplets(0),
29 32 m_lastTripletOffset(0),
30 32 m_lastPatternOffset(0),
31 64 m_channelsPerNode(3) {
32
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 LogExcess(VB_CHANNELOUT, "TestPatternRGBChase::TestPatternRGBChase()\n");
33
34
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 m_testPatternName = "RGBChase";
35 32 }
36
37 /*
38 *
39 */
40 112 TestPatternRGBChase::~TestPatternRGBChase() {
41 56 LogExcess(VB_CHANNELOUT, "TestPatternRGBChase::~TestPatternRGBChase()\n");
42 112 }
43
44 /*
45 *
46 */
47 32 int TestPatternRGBChase::Init(Json::Value config) {
48 32 m_configChanged = 0;
49
50
3/6
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 32 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 32 times.
✗ Branch 5 not taken.
96 std::string colorPattern = JsonString(config, "colorPattern");
51
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 2 times.
32 if (m_colorPatternStr != colorPattern) {
52
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 m_colorPatternStr = colorPattern;
53 30 m_configChanged = 1;
54 }
55
56
2/4
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 32 times.
✗ Branch 3 not taken.
32 int cpn = JsonInt(config, "channelsPerNode", 3);
57
4/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 29 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 1 times.
32 if (cpn != 3 && cpn != 4) {
58 2 cpn = 3;
59 }
60
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 31 times.
32 if (m_channelsPerNode != cpn) {
61 1 m_channelsPerNode = cpn;
62 1 m_configChanged = 1;
63 }
64
65
2/4
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 32 times.
✗ Branch 3 not taken.
64 return TestPatternBase::Init(config);
66 32 }
67
68 /*
69 *
70 */
71 32 int TestPatternRGBChase::SetupTest(void) {
72 32 bzero(m_testData, m_channelCount);
73
74 32 m_colorPattern.clear();
75
76 32 char digit = 0;
77
2/2
✓ Branch 0 taken 270 times.
✓ Branch 1 taken 32 times.
302 for (int i = 0; i < m_colorPatternStr.size(); i += 2) {
78
1/2
✓ Branch 0 taken 270 times.
✗ Branch 1 not taken.
270 digit = (char)strtol(m_colorPatternStr.substr(i, 2).c_str(), NULL, 16);
79
1/2
✓ Branch 0 taken 270 times.
✗ Branch 1 not taken.
270 m_colorPattern.push_back(digit);
80 }
81
82 // Make sure we have a valid set of color groups (3 channels for RGB, 4 for RGBW)
83 32 const int stride = m_channelsPerNode;
84
5/6
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 32 times.
✓ Branch 4 taken 7 times.
✓ Branch 5 taken 32 times.
39 while (m_colorPattern.size() < stride || m_colorPattern.size() % stride)
85
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 m_colorPattern.push_back(0);
86
87 // Need at least two pixels for a chase; bump before filling so the whole
88 // (possibly expanded) range gets initialized
89
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 29 times.
32 if (m_channelCount < (2 * stride)) {
90 3 m_channelCount = 2 * stride;
91 3 bzero(m_testData, m_channelCount);
92 }
93
94 // A trailing partial pixel (a channel count that is not a multiple of the
95 // stride, as an arbitrary set of discrete channels gives) is filled with as
96 // much of its color as fits instead of being skipped and left dark. The
97 // pattern offset still advances by a whole stride so the wrap point is
98 // unchanged for the whole-pixel case.
99 32 char* c = m_testData;
100 32 int offset = 0;
101
2/2
✓ Branch 0 taken 4686 times.
✓ Branch 1 taken 32 times.
4718 for (int i = 0; i < m_channelCount; i += stride) {
102 4686 int count = std::min(stride, m_channelCount - i);
103
2/2
✓ Branch 0 taken 14056 times.
✓ Branch 1 taken 4686 times.
18742 for (int j = 0; j < count; j++)
104 14056 *(c++) = m_colorPattern[offset + j];
105
106 4686 offset += stride;
107
2/2
✓ Branch 0 taken 1595 times.
✓ Branch 1 taken 3091 times.
4686 if (offset >= m_colorPattern.size())
108 1595 offset = 0;
109 }
110
111 32 m_patternOffset = 0;
112 32 m_colorPatternSize = m_colorPattern.size() / stride;
113 32 m_rgbTriplets = m_channelCount / stride;
114 32 m_lastTripletOffset = (m_rgbTriplets - 1) * stride;
115 32 m_lastPatternOffset = m_lastTripletOffset % m_colorPattern.size();
116
117
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
64 return TestPatternBase::SetupTest();
118 }
119
120 /*
121 *
122 */
123 802 void TestPatternRGBChase::CycleData(void) {
124 802 const int stride = m_channelsPerNode;
125 802 memmove(m_testData + stride, m_testData, m_channelCount - stride);
126
127 802 m_patternOffset -= stride;
128
129
2/2
✓ Branch 0 taken 275 times.
✓ Branch 1 taken 527 times.
802 if (m_patternOffset < 0)
130 275 m_patternOffset = m_colorPattern.size() - stride;
131
132 802 int offset = m_patternOffset;
133
134
2/2
✓ Branch 0 taken 2415 times.
✓ Branch 1 taken 802 times.
3217 for (int j = 0; j < stride; j++)
135 2415 m_testData[j] = m_colorPattern[offset++];
136 802 }
137
138 /*
139 *
140 */
141 32 void TestPatternRGBChase::DumpConfig(void) {
142 32 LogDebug(VB_CHANNELOUT, "TestPatternRGBChase::DumpConfig\n");
143 32 LogDebug(VB_CHANNELOUT, " colorPattern : %s\n", m_colorPatternStr.c_str());
144 32 LogDebug(VB_CHANNELOUT, " colorPatternSize: %d\n", m_colorPatternSize);
145
146 32 TestPatternBase::DumpConfig();
147 32 }
148