GCC Code Coverage Report


Directory: ./
File: channeltester/RGBChase.cpp
Date: 2026-12-01 12:27:28
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 43 TestPatternRGBChase::TestPatternRGBChase() :
25
1/2
✓ Branch 0 taken 43 times.
✗ Branch 1 not taken.
43 m_colorPatternStr(""),
26 43 m_colorPatternSize(0),
27 43 m_patternOffset(0),
28 43 m_rgbTriplets(0),
29 43 m_lastTripletOffset(0),
30 43 m_lastPatternOffset(0),
31 86 m_channelsPerNode(3) {
32
1/2
✓ Branch 0 taken 43 times.
✗ Branch 1 not taken.
43 LogExcess(VB_CHANNELOUT, "TestPatternRGBChase::TestPatternRGBChase()\n");
33
34
1/2
✓ Branch 0 taken 43 times.
✗ Branch 1 not taken.
43 m_testPatternName = "RGBChase";
35 43 }
36
37 /*
38 *
39 */
40 156 TestPatternRGBChase::~TestPatternRGBChase() {
41 78 LogExcess(VB_CHANNELOUT, "TestPatternRGBChase::~TestPatternRGBChase()\n");
42 156 }
43
44 /*
45 *
46 */
47 44 int TestPatternRGBChase::Init(Json::Value config) {
48 44 m_configChanged = 0;
49
50
3/6
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 44 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 44 times.
✗ Branch 5 not taken.
132 std::string colorPattern = JsonString(config, "colorPattern");
51
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 3 times.
44 if (m_colorPatternStr != colorPattern) {
52
1/2
✓ Branch 0 taken 41 times.
✗ Branch 1 not taken.
41 m_colorPatternStr = colorPattern;
53 41 m_configChanged = 1;
54 }
55
56
2/4
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 44 times.
✗ Branch 3 not taken.
44 int cpn = JsonInt(config, "channelsPerNode", 3);
57
4/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 41 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 1 times.
44 if (cpn != 3 && cpn != 4) {
58 2 cpn = 3;
59 }
60
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 43 times.
44 if (m_channelsPerNode != cpn) {
61 1 m_channelsPerNode = cpn;
62 1 m_configChanged = 1;
63 }
64
65
2/4
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 44 times.
✗ Branch 3 not taken.
88 return TestPatternBase::Init(config);
66 44 }
67
68 /*
69 *
70 */
71 43 int TestPatternRGBChase::SetupTest(void) {
72 43 bzero(m_testData, m_channelCount);
73
74 43 m_colorPattern.clear();
75
76 43 char digit = 0;
77
2/2
✓ Branch 0 taken 369 times.
✓ Branch 1 taken 43 times.
412 for (int i = 0; i < m_colorPatternStr.size(); i += 2) {
78
1/2
✓ Branch 0 taken 369 times.
✗ Branch 1 not taken.
369 digit = (char)strtol(m_colorPatternStr.substr(i, 2).c_str(), NULL, 16);
79
1/2
✓ Branch 0 taken 369 times.
✗ Branch 1 not taken.
369 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 43 const int stride = m_channelsPerNode;
84
5/6
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 43 times.
✓ Branch 4 taken 7 times.
✓ Branch 5 taken 43 times.
50 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 40 times.
43 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 43 char* c = m_testData;
100 43 int offset = 0;
101
2/2
✓ Branch 0 taken 17672 times.
✓ Branch 1 taken 43 times.
17715 for (int i = 0; i < m_channelCount; i += stride) {
102 17672 int count = std::min(stride, m_channelCount - i);
103
2/2
✓ Branch 0 taken 53014 times.
✓ Branch 1 taken 17672 times.
70686 for (int j = 0; j < count; j++)
104 53014 *(c++) = m_colorPattern[offset + j];
105
106 17672 offset += stride;
107
2/2
✓ Branch 0 taken 5919 times.
✓ Branch 1 taken 11753 times.
17672 if (offset >= m_colorPattern.size())
108 5919 offset = 0;
109 }
110
111 43 m_patternOffset = 0;
112 43 m_colorPatternSize = m_colorPattern.size() / stride;
113 43 m_rgbTriplets = m_channelCount / stride;
114 43 m_lastTripletOffset = (m_rgbTriplets - 1) * stride;
115 43 m_lastPatternOffset = m_lastTripletOffset % m_colorPattern.size();
116
117
1/2
✓ Branch 0 taken 43 times.
✗ Branch 1 not taken.
86 return TestPatternBase::SetupTest();
118 }
119
120 /*
121 *
122 */
123 2190 void TestPatternRGBChase::CycleData(void) {
124 2190 const int stride = m_channelsPerNode;
125 2190 memmove(m_testData + stride, m_testData, m_channelCount - stride);
126
127 2190 m_patternOffset -= stride;
128
129
2/2
✓ Branch 0 taken 739 times.
✓ Branch 1 taken 1451 times.
2190 if (m_patternOffset < 0)
130 739 m_patternOffset = m_colorPattern.size() - stride;
131
132 2190 int offset = m_patternOffset;
133
134
2/2
✓ Branch 0 taken 6580 times.
✓ Branch 1 taken 2190 times.
8770 for (int j = 0; j < stride; j++)
135 6580 m_testData[j] = m_colorPattern[offset++];
136 2190 }
137
138 /*
139 *
140 */
141 44 void TestPatternRGBChase::DumpConfig(void) {
142 44 LogDebug(VB_CHANNELOUT, "TestPatternRGBChase::DumpConfig\n");
143 44 LogDebug(VB_CHANNELOUT, " colorPattern : %s\n", m_colorPatternStr.c_str());
144 44 LogDebug(VB_CHANNELOUT, " colorPatternSize: %d\n", m_colorPatternSize);
145
146 44 TestPatternBase::DumpConfig();
147 44 }
148