MythTV master
mythopenglvideo.h
Go to the documentation of this file.
1#ifndef MYTH_OPENGL_VIDEO_H_
2#define MYTH_OPENGL_VIDEO_H_
3
4// Qt
5#include <QRect>
6#include <QObject>
7
8// MythTV
10#include "mythvideoout.h"
11#include "mythvideogpu.h"
12#include "videoouttypes.h"
13#include "mythavutil.h"
15
16// Std
17#include <vector>
18#include <map>
19
21
23{
24 Q_OBJECT
25
26 public:
27 enum VideoShaderType : std::uint8_t
28 {
29 Default = 0, // Plain blit
30 Progressive = 1, // Progressive video frame
31 InterlacedTop = 2, // Deinterlace with top field first
32 InterlacedBot = 3, // Deinterlace with bottom field first
34 ShaderCount = 5
35 };
36
37 static QString TypeToProfile(VideoFrameType Type);
38
40 MythVideoBounds* Bounds, const MythVideoProfilePtr& VideoProfile, const QString &Profile);
41 ~MythOpenGLVideo() override;
42
43 void StartFrame () override {}
45 void RenderFrame (MythVideoFrame* Frame, bool TopFieldFirst, FrameScanType Scan,
46 StereoscopicMode StereoOverride, bool DrawBorder = false) override;
47 void EndFrame () override {}
48 QString GetProfile () const override;
49 void ResetFrameFormat () override;
50 void ResetTextures () override;
51
52 public slots:
54
55 protected:
56 void ColourSpaceUpdate(bool PrimariesChanged) override;
57
58 private:
59 bool SetupFrameFormat (VideoFrameType InputType, VideoFrameType OutputType,
60 QSize Size, GLenum TextureTarget);
62 void BindTextures (bool Deinterlacing, std::vector<MythVideoTextureOpenGL*>& Current,
63 std::vector<MythGLTexture*>& Textures);
65 MythDeintType Filter = DEINT_SHADER, bool CreateReferences = true);
67 void SetupBicubic(VideoResizing& Resize);
68
70 int m_gles { 0 };
72 std::array<QOpenGLShaderProgram*,ShaderCount> m_shaders { nullptr };
73 std::array<int,ShaderCount> m_shaderCost { 1 };
74 std::vector<MythVideoTextureOpenGL*> m_inputTextures;
75 std::vector<MythVideoTextureOpenGL*> m_prevTextures;
76 std::vector<MythVideoTextureOpenGL*> m_nextTextures;
77 QOpenGLFramebufferObject* m_frameBuffer { nullptr };
79 QOpenGLFunctions::OpenGLFeatures m_features;
80 int m_extraFeatures { 0 };
81 GLenum m_textureTarget { QOpenGLTexture::Target2D };
84};
85#endif
MythOpenGLVideo is responsible for displaying video frames on screen using OpenGL.
std::vector< MythVideoTextureOpenGL * > m_prevTextures
MythVideoTextureOpenGL * m_frameBufferTexture
bool SetupFrameFormat(VideoFrameType InputType, VideoFrameType OutputType, QSize Size, GLenum TextureTarget)
QOpenGLFramebufferObject * m_frameBuffer
MythOpenGLVideo(MythRenderOpenGL *Render, MythVideoColourSpace *ColourSpace, MythVideoBounds *Bounds, const MythVideoProfilePtr &VideoProfile, const QString &Profile)
~MythOpenGLVideo() override
void BindTextures(bool Deinterlacing, std::vector< MythVideoTextureOpenGL * > &Current, std::vector< MythGLTexture * > &Textures)
bool m_chromaUpsamplingFilter
void StartFrame() override
std::array< int, ShaderCount > m_shaderCost
std::array< QOpenGLShaderProgram *, ShaderCount > m_shaders
static QString TypeToProfile(VideoFrameType Type)
QOpenGLFunctions::OpenGLFeatures m_features
MythOpenGLTonemap * m_toneMap
std::vector< MythVideoTextureOpenGL * > m_inputTextures
void ResetTextures() override
Clear reference frames after a seek as they will contain old images.
std::vector< MythVideoTextureOpenGL * > m_nextTextures
void PrepareFrame(MythVideoFrame *Frame, FrameScanType Scan=kScan_Progressive) override
Update the current input texture using the data from the given video frame.
void ColourSpaceUpdate(bool PrimariesChanged) override
MythDeintType m_fallbackDeinterlacer
void SetupBicubic(VideoResizing &Resize)
void RenderFrame(MythVideoFrame *Frame, bool TopFieldFirst, FrameScanType Scan, StereoscopicMode StereoOverride, bool DrawBorder=false) override
void UpdateShaderParameters()
void EndFrame() override
bool AddDeinterlacer(const MythVideoFrame *Frame, FrameScanType Scan, MythDeintType Filter=DEINT_SHADER, bool CreateReferences=true)
MythRenderOpenGL * m_openglRender
void ResetFrameFormat() override
bool CreateVideoShader(VideoShaderType Type, MythDeintType Deint=DEINT_NONE)
Create the appropriate shader for the operation Type.
QString GetProfile() const override
MythVideoColourSpace contains a QMatrix4x4 that can convert YCbCr data to RGB.
MythDeintType
Definition: mythframe.h:67
@ DEINT_NONE
Definition: mythframe.h:68
@ DEINT_SHADER
Definition: mythframe.h:73
VideoFrameType
Definition: mythframe.h:20
std::shared_ptr< MythVideoProfile > MythVideoProfilePtr
Definition: mythvideogpu.h:18
FrameScanType
Definition: videoouttypes.h:95
@ kScan_Progressive
StereoscopicMode