18 #include <QCoreApplication>
55 double scale = (fgRed + fgGreen + fgBlue) / 2.0;
64 scale = (bgRed + bgGreen + bgBlue) / 2.0;
69 for (
int i = 0; i < 256; i++) {
76 double red = (b * bgRed * 16) + (f * fgRed * 16);
77 double green = (b * bgGreen * 16) + (f * fgGreen * 16);
78 double blue = (b * bgBlue * 16) + (f * fgBlue * 16);
81 for (
int j = 0; j < 5; j++)
89 if (red > 255) { excess += red - 255; red = 255; }
90 if (green > 255) { excess += green - 255; green = 255; }
91 if (blue > 255) { excess += blue - 255; blue = 255; }
94 double scale2 = (0.5 + (red + green + blue) / 768.0) / 1.5;
124 LOG(VB_GENERAL, LOG_ERR,
125 "outputImage in Synaesthesia::resize() is NULL");
129 for (
size_t i = 0; i < 256; i++)
134 surface = SDL_SetVideoMode(size.width(), size.height(), 8, 0);
138 LOG(VB_GENERAL, LOG_ERR,
"Couldn't get SDL surface");
142 SDL_Color sdlPalette[256];
144 for (
int i = 0; i < 256; i++)
151 SDL_SetColors(surface, sdlPalette, 0, 256);
158 for (
size_t j = 0; j <
LogSize; j++)
160 sum = (i & 1) + sum * 2;
170 for (
size_t twoToTheK = 1; twoToTheK <
NumSamples; twoToTheK *= 2)
174 for (
size_t j = 0; j < n2; j++)
181 double xt = x[i] - x[l];
182 x[i] = (x[i] + x[l]);
183 double yt = y[i] - y[l];
184 y[i] = (y[i] + y[l]);
185 x[l] = xt * c - yt * s;
186 y[l] = xt * s + yt * c;
194 double fadeModeFudge { 0.78 };
202 factor = int(exp(
log(fadeModeFudge) / (lsize * 8.0)) * 255);
203 factor = std::min(factor, 255);
205 for (
int i = 0; i < 256; i++)
223 #define output ((unsigned char*)m_outputBmp.data)
224 #define lastOutput ((unsigned char*)m_lastOutputBmp.data)
225 #define lastLastOutput ((unsigned char*)m_lastLastOutputBmp.data)
232 unsigned char *
p =
output + (
static_cast<ptrdiff_t
>(x) * 2) +
234 if (
p[0] + br1 < 255)
238 if (
p[1] + br2 < 255)
246 if (
p[0] + br1 < 255)
250 if (
p[1] + br2 < 255)
266 auto *ptr = (uint32_t *)
output;
272 *(ptr++) = x - ((x & (uintptr_t)0xf0f0f0f0) >> 4) -
273 ((x & (uintptr_t)0xe0e0e0e0) >> 5);
284 short j = short((
int(
getPixel(x - 1, y, where - 2)) +
285 int(
getPixel(x + 1, y, where + 2)) +
286 int(
getPixel(x, y - 1, where - step)) +
287 int(
getPixel(x, y + 1, where + step))) >> 2) +
298 else if (j & (255 * 256))
331 y <
m_outHeight - 1; y++, start += step, end += step)
350 else if (j2 & (255*256))
361 short j = short((
int(
getPixel(x - 1, y, where - 2)) +
362 int(
getPixel(x + 1, y, where + 2)) +
363 int(
getPixel(x, y - 1, where - step)) +
364 int(
getPixel(x, y + 1, where + step))) >> 2) +
374 else if (j & (255 * 256))
398 y++, i += step, j += step)
407 y <
m_outHeight - 1; y++, start += step, end += step)
425 else if (j2 & (255*256))
464 for (
size_t i = 0; i < numSamps; i++)
473 fft(x.data(), y.data());
477 for (
size_t i = 0 + 1; i <
NumSamples / 2; i++)
483 double aa = ((
x1 +
x2) * (
x1 +
x2)) + ((y1 - y2) * (y1 - y2));
484 double bb = ((
x1 -
x2) * (
x1 -
x2)) + ((y2 + y2) * (y1 + y2));
489 clarity[i] = (int)(((
x1 +
x2) * (
x1 -
x2) + (y1 + y2) * (y1 - y2)) /
497 energy += (aa + bb) * i * i;
506 double brightFactor2 = (brightFactor / 65536.0 /
NumSamples) *
515 if (a[i] > 0 || b[i] > 0)
517 int h = (int)(b[i] *
m_outWidth / (a[i] + b[i]));
518 int br = (int)((a[i] + b[i]) * i * brightFactor2);
519 int br1 = br * (clarity[i] + 128) >> 8;
520 int br2 = br * (128 - clarity[i]) >> 8;
521 if (br1 < 0) br1 = 0;
else if (br1 > 255) br1 = 255;
522 if (br2 < 0) br2 = 0;
else if (br2 > 255) br2 = 255;
533 for(
int j = 1; br1 > 0 || br2 > 0;
536 for (
int k = 0; k < j; k++)
538 addPixel(px - j + k,py - k, br1, br2);
539 addPixel(px + k, py - j + k, br1, br2);
540 addPixel(px + j - k, py + k, br1, br2);
541 addPixel(px - k, py + j - k, br1, br2);
552 for(
int j = 1; br1 > 0 || br2 > 0;
563 unsigned char *
p =
output + (
static_cast<ptrdiff_t
>(px) * 2) +
564 (
static_cast<ptrdiff_t
>(py) *
m_outWidth * 2);
565 unsigned char *
p1 =
p;
566 unsigned char *
p2 =
p;
567 unsigned char *p3 =
p;
568 unsigned char *p4 =
p;
570 for (; br1 > 0 || br2 > 0;
595 auto *ptrOutput = (uint32_t *)
output;
606 unsigned int const r1 = *(ptrOutput++);
607 unsigned int const r2 = *(ptrOutput++);
609 unsigned int const v = ((r1 & 0x000000f0UL) >> 4) |
610 ((r1 & 0x0000f000UL) >> 8) |
611 ((r1 & 0x00f00000UL) >> 12) |
612 ((r1 & 0xf0000000UL) >> 16);
614 *(ptrTop++) = v | (((r2 & 0x000000f0UL) << 12) |
615 ((r2 & 0x0000f000UL) << 8) |
616 ((r2 & 0x00f00000UL) << 4) |
617 ((r2 & 0xf0000000UL)));
619 *(ptrBot++) = v | (((r2 & 0x000000f0UL) << 12) |
620 ((r2 & 0x0000f000UL) << 8) |
621 ((r2 & 0x00f00000UL) << 4) |
622 ((r2 & 0xf0000000UL)));
634 const QString &
name(
void)
const override
636 static QString s_name = QCoreApplication::translate(
"Visualizers",
648 [[maybe_unused]]
const QString &pluginName)
const override