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(AudioPlayer* Audio, MythRender* Render) const override
96 {
97#if CONFIG_OPENGL
98 auto * render1 = dynamic_cast<MythRenderOpenGL*>(Render);
99 if (render1)
100 return new MythVisualMonoScopeOpenGL(Audio, Render, true);
101#endif
102#if CONFIG_VULKAN
103 auto * render2 = dynamic_cast<MythRenderVulkan*>(Render);
104 if (render2)
105 return new MythVisualMonoScopeVulkan(Audio, Render, true);
106#endif
107 return nullptr;
108 }
109
110 bool SupportedRenderer(RenderType Type) override;
112
114{
115 return ((Type == kRenderOpenGL) || (Type == kRenderVulkan));
116}
117
119{
120 public:
121 const QString& name() const override
122 {
123 static QString s_name(SIMPLE_NAME);
124 return s_name;
125 }
126
127 VideoVisual* Create(AudioPlayer* Audio, MythRender* Render) const override
128 {
129#if CONFIG_OPENGL
130 auto * render1 = dynamic_cast<MythRenderOpenGL*>(Render);
131 if (render1)
132 return new MythVisualMonoScopeOpenGL(Audio, Render, false);
133#endif
134#if CONFIG_VULKAN
135 auto * render2 = dynamic_cast<MythRenderVulkan*>(Render);
136 if (render2)
137 return new MythVisualMonoScopeVulkan(Audio, Render, false);
138#endif
139 return nullptr;
140 }
141
142 bool SupportedRenderer(RenderType Type) override;
144
146{
147 return ((Type == kRenderOpenGL) || (Type == kRenderVulkan));
148}
QMutex * mutex()
Definition: visual.h:26
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
unsigned int uint
Definition: freesurround.h:24
RenderType
@ kRenderOpenGL
@ kRenderVulkan
VideoVisualSimpleScopeFactory VideoVisualSimpleScopeFactory
VideoVisualMonoScopeFactory VideoVisualMonoScopeFactory
#define FADE_NAME
static constexpr size_t NUM_SAMPLES
#define SIMPLE_NAME