GCC Code Coverage Report


Directory: ./
File: channeloutput/processors/ThreeToFourOutputProcessor.cpp
Date: 2026-10-29 08:11:58
Exec Total Coverage
Lines: 35 65 53.8%
Functions: 2 3 66.7%
Branches: 19 45 42.2%

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 "ThreeToFourOutputProcessor.h"
20
21 3 ThreeToFourOutputProcessor::ThreeToFourOutputProcessor(const Json::Value& config) {
22
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 description = config["description"].asString();
23
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 active = config["active"].asInt() ? true : false;
24
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 start = config["start"].asInt();
25
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 count = config["count"].asInt();
26
27
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 order = config["colorOrder"].asInt();
28
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 algorithm = config["algorithm"].asInt();
29
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 ProcessModelConfig(config, model, start, count);
30
31
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 LogInfo(VB_CHANNELOUT, "ThreeToFour: %d-%d, Model: %s\n",
32 start + 1, start + count,
33 model.c_str());
34 3 }
35
36 ✗ ThreeToFourOutputProcessor::~ThreeToFourOutputProcessor() {
37 ✗ }
38
39 30 void ThreeToFourOutputProcessor::ProcessData(unsigned char* channelData) const {
40 30 int curDest = start + (count - 1) * 4;
41 30 int curSrc = start + (count - 1) * 3;
42
43
2/2
✓ Branch 0 taken 150 times.
✓ Branch 1 taken 30 times.
180 for (int x = 0; x < count; x++, curSrc -= 3, curDest -= 4) {
44 150 int r = channelData[curSrc];
45 150 int g = channelData[curSrc + 1];
46 150 int b = channelData[curSrc + 2];
47 150 int w = 0;
48
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 150 times.
150 switch (algorithm) {
49 ✗ case 1: // r == g == b -> w
50 ✗ if (r == g && r == b) {
51 ✗ w = r;
52 ✗ r = 0;
53 ✗ g = 0;
54 ✗ b = 0;
55 }
56 ✗ break;
57 ✗ case 2: {
58 ✗ int maxc = std::max(r, std::max(g, b));
59 ✗ if (maxc == 0) {
60 ✗ w = 0;
61 } else {
62 ✗ int minc = std::min(r, std::min(g, b));
63 // find colour with 100% hue
64 ✗ float multiplier = 255.0f / maxc;
65 ✗ float h0 = r * multiplier;
66 ✗ float h1 = g * multiplier;
67 ✗ float h2 = b * multiplier;
68
69 ✗ float maxW = std::max(h0, std::max(h1, h2));
70 ✗ float minW = std::min(h0, std::min(h1, h2));
71 ✗ int whiteness = ((maxW + minW) / 2.0f - 127.5f) * (255.0f / 127.5f) / multiplier;
72 ✗ if (whiteness < 0)
73 ✗ whiteness = 0;
74 ✗ else if (whiteness > minc)
75 ✗ whiteness = minc;
76 ✗ w = whiteness;
77 ✗ r -= whiteness;
78 ✗ g -= whiteness;
79 ✗ b -= whiteness;
80 }
81 ✗ } break;
82 150 default: // no white
83 150 break;
84 }
85
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 75 times.
150 switch (order) {
86 75 case 4123:
87 75 channelData[curDest] = w;
88 75 channelData[curDest + 1] = r;
89 75 channelData[curDest + 2] = g;
90 75 channelData[curDest + 3] = b;
91 75 break;
92 75 case 1234:
93 default:
94 75 channelData[curDest] = r;
95 75 channelData[curDest + 1] = g;
96 75 channelData[curDest + 2] = b;
97 75 channelData[curDest + 3] = w;
98 75 break;
99 }
100 }
101 30 }
102