MythTV master
videovisualmonoscope.cpp
Go to the documentation of this file.
1#include <algorithm>
2
3// MythTV
4#include "libmythbase/mythconfig.h"
7
8#if CONFIG_OPENGL
10#endif
11#if CONFIG_VULKAN
13#endif
14
16 : VideoVisual(Audio, Render),
17 m_fade(Fade)
18{
19}
20
22{
23 return m_fade ? FADE_NAME : SIMPLE_NAME;
24}
25
27{
28 m_hue = 0.0;
29 m_area = Area;
30 m_rate = 1.0;
31 m_lastTime = nowAsDuration<std::chrono::milliseconds>();
32 m_lineWidth = std::max(1.0F, m_area.height() * 0.004F);
33}
34
36{
37 if (!Buffer)
38 return false;
39
40 QMutexLocker locker(mutex());
41 auto * node = GetNode();
42
43 if (m_area.isEmpty() || !node)
44 return false;
45
46 float y = (static_cast<float>(m_area.height()) / 2.0F) + m_area.top();
47 float x = m_area.left();
48 float xstep = static_cast<float>(m_area.width()) / (NUM_SAMPLES - 1);
49
50 double index = 0;
51 double const step = static_cast<double>(node->m_length) / NUM_SAMPLES;
52 for (size_t i = 0; i < NUM_SAMPLES; i++)
53 {
54 auto indexTo = static_cast<long>(index + step);
55 if (indexTo == static_cast<long>(index))
56 indexTo = static_cast<long>(index + 1);
57
58 double value = 0.0;
59 for (auto s = static_cast<long>(index); s < indexTo && s < node->m_length; s++)
60 {
61 double temp = (static_cast<double>(node->m_left[s]) +
62 ((node->m_right ? static_cast<double>(node->m_right[s]) : 0.0) *
63 (static_cast<double>(m_area.height()))) ) / 65536.0;
64 value = temp > 0.0 ? std::max(temp, value) : std::min(temp, value);
65 }
66
67 index += step;
68 Buffer[i * 2] = x;
69 Buffer[(i * 2) + 1] = y + static_cast<float>(value);
70 x += xstep;
71 }
72 return true;
73}
74
76{
77 // try and give a similar rate of transitions for different playback speeds
78 auto timenow = nowAsDuration<std::chrono::milliseconds>();
79 m_rate = (timenow - m_lastTime).count();
80 m_lastTime = timenow;
81 m_hue += m_rate / 7200.0F;
82 if (m_hue > 1.0F)
83 m_hue -= static_cast<uint>(m_hue);
84}
85
87{
88 public:
89 const QString& name() const override
90 {
91 static QString s_name(FADE_NAME);
92 return s_name;
93 }
94
95 VideoVisual* Create([[maybe_unused]] AudioPlayer* Audio,
96 [[maybe_unused]] MythRender* Render) const override
97 {
98#if CONFIG_OPENGL
99 auto * render1 = dynamic_cast<MythRenderOpenGL*>(Render);
100 if (render1)
101 return new MythVisualMonoScopeOpenGL(Audio, Render, true);
102#endif
103#if CONFIG_VULKAN
104 auto * render2 = dynamic_cast<MythRenderVulkan*>(Render);
105 if (render2)
106 return new MythVisualMonoScopeVulkan(Audio, Render, true);
107#endif
108 return nullptr;
109 }
110
111 bool SupportedRenderer(RenderType Type) override;
113
115{
116 return ((Type == kRenderOpenGL) || (Type == kRenderVulkan));
117}
118
120{
121 public:
122 const QString& name() const override
123 {
124 static QString s_name(SIMPLE_NAME);
125 return s_name;
126 }
127
128 VideoVisual* Create([[maybe_unused]] AudioPlayer* Audio,
129 [[maybe_unused]] MythRender* Render) const override
130 {
131#if CONFIG_OPENGL
132 auto * render1 = dynamic_cast<MythRenderOpenGL*>(Render);
133 if (render1)
134 return new MythVisualMonoScopeOpenGL(Audio, Render, false);
135#endif
136#if CONFIG_VULKAN
137 auto * render2 = dynamic_cast<MythRenderVulkan*>(Render);
138 if (render2)
139 return new MythVisualMonoScopeVulkan(Audio, Render, false);
140#endif
141 return nullptr;
142 }
143
144 bool SupportedRenderer(RenderType Type) override;
146
148{
149 return ((Type == kRenderOpenGL) || (Type == kRenderVulkan));
150}
VideoVisual * Create(AudioPlayer *Audio, MythRender *Render) const override
bool SupportedRenderer(RenderType Type) override
const QString & name() const override
bool UpdateVertices(float *Buffer)
VideoVisualMonoScope(AudioPlayer *Audio, MythRender *Render, bool Fade)
std::chrono::milliseconds m_lastTime
const QString & name() const override
VideoVisual * Create(AudioPlayer *Audio, MythRender *Render) const override
bool SupportedRenderer(RenderType Type) override
VisualNode * GetNode(void)
Definition: videovisual.cpp:85
QRect m_area
Definition: videovisual.h:71
QMutex * mutex()
Definition: visualization.h:24
unsigned int uint
Definition: compat.h:60
RenderType
@ kRenderOpenGL
@ kRenderVulkan
VideoVisualSimpleScopeFactory VideoVisualSimpleScopeFactory
VideoVisualMonoScopeFactory VideoVisualMonoScopeFactory
#define FADE_NAME
static constexpr size_t NUM_SAMPLES
#define SIMPLE_NAME