MythTV  master
mythvideotextureopengl.h
Go to the documentation of this file.
1 #ifndef MYTHVIDEOTEXTURE_H
2 #define MYTHVIDEOTEXTURE_H
3 
4 // MythTV
6 #include "mythavutil.h"
7 #include "mythframe.h"
8 
9 // FFmpeg
10 extern "C" {
11 #include "libavutil/pixfmt.h"
12 }
13 
14 // Std
15 #include <vector>
16 
17 class QMatrix4x4;
19 using VideoFramebuffer = std::pair<QOpenGLFramebufferObject*, MythVideoTextureOpenGL*>;
20 
22 {
23  public:
24  explicit MythVideoTextureOpenGL(GLuint Texture);
25  static std::vector<MythVideoTextureOpenGL*> CreateTextures(MythRenderOpenGL* Context,
26  VideoFrameType Type,
28  std::vector<QSize> Sizes,
29  GLenum Target = QOpenGLTexture::Target2D);
30  static void UpdateTextures(MythRenderOpenGL* Context, const MythVideoFrame *Frame,
31  const std::vector<MythVideoTextureOpenGL*> &Textures);
32  static void DeleteTexture (MythRenderOpenGL* Context, MythVideoTextureOpenGL *Texture);
33  static void DeleteTextures(MythRenderOpenGL* Context, std::vector<MythVideoTextureOpenGL*> &Textures);
34  static void SetTextureFilters(MythRenderOpenGL* Context, const std::vector<MythVideoTextureOpenGL*> &Textures,
35  QOpenGLTexture::Filter Filter,
36  QOpenGLTexture::WrapMode Wrap = QOpenGLTexture::ClampToEdge);
37  static MythVideoTextureOpenGL* CreateTexture(MythRenderOpenGL *Context, QSize Size,
38  GLenum Target = QOpenGLTexture::Target2D,
39  QOpenGLTexture::PixelType PixelType = QOpenGLTexture::UInt8,
40  QOpenGLTexture::PixelFormat PixelFormat = QOpenGLTexture::RGBA,
41  QOpenGLTexture::TextureFormat Format = QOpenGLTexture::NoFormat,
42  QOpenGLTexture::Filter Filter = QOpenGLTexture::Linear,
43  QOpenGLTexture::WrapMode Wrap = QOpenGLTexture::ClampToEdge);
45  QSize Size, bool HighPrecision = true);
46  ~MythVideoTextureOpenGL() = default;
47 
48  public:
49  bool m_valid { false };
50  QOpenGLTexture::Filter m_filter { QOpenGLTexture::Linear };
53  uint m_plane { 0 };
55  bool m_allowGLSLDeint { false };
56 #ifdef USING_MEDIACODEC
57  QMatrix4x4 *m_transform { nullptr };
58 #endif
59  MythAVCopy *m_copyContext { nullptr };
60 
61  protected:
62  explicit MythVideoTextureOpenGL(QOpenGLTexture* Texture);
63 
64  private:
65  static std::vector<MythVideoTextureOpenGL*> CreateHardwareTextures(MythRenderOpenGL* Context,
67  std::vector<QSize> Sizes, GLenum Target);
68  static std::vector<MythVideoTextureOpenGL*> CreateSoftwareTextures(MythRenderOpenGL* Context,
70  std::vector<QSize> Sizes, GLenum Target);
71 
72  Q_DISABLE_COPY(MythVideoTextureOpenGL)
73  static void YV12ToYV12 (MythRenderOpenGL *Context, const MythVideoFrame *Frame,
74  MythVideoTextureOpenGL* Texture, uint Plane);
75  static void YV12ToYUYV (const MythVideoFrame *Frame, MythVideoTextureOpenGL* Texture);
76  static void NV12ToNV12 (MythRenderOpenGL *Context, const MythVideoFrame *Frame,
77  MythVideoTextureOpenGL* Texture, uint Plane);
78  static bool CreateBuffer (MythVideoTextureOpenGL* Texture, int Size);
79 };
80 
81 #endif
MythGLTexture
Definition: mythrenderopengl.h:56
MythVideoTextureOpenGL
Definition: mythvideotextureopengl.h:21
MythVideoTextureOpenGL::m_planeCount
uint m_planeCount
Definition: mythvideotextureopengl.h:54
Frame
Definition: zmdefines.h:93
MythVideoTextureOpenGL::MythVideoTextureOpenGL
MythVideoTextureOpenGL(GLuint Texture)
Definition: mythvideotextureopengl.cpp:12
MythDate::Format
Format
Definition: mythdate.h:15
MythVideoTextureOpenGL::m_frameFormat
VideoFrameType m_frameFormat
Definition: mythvideotextureopengl.h:52
FMT_NONE
@ FMT_NONE
Definition: mythframe.h:22
mythframe.h
MythVideoTextureOpenGL::SetTextureFilters
static void SetTextureFilters(MythRenderOpenGL *Context, const std::vector< MythVideoTextureOpenGL * > &Textures, QOpenGLTexture::Filter Filter, QOpenGLTexture::WrapMode Wrap=QOpenGLTexture::ClampToEdge)
Definition: mythvideotextureopengl.cpp:40
MythVideoTextureOpenGL::UpdateTextures
static void UpdateTextures(MythRenderOpenGL *Context, const MythVideoFrame *Frame, const std::vector< MythVideoTextureOpenGL * > &Textures)
Update the contents of the given Textures for data held in Frame.
Definition: mythvideotextureopengl.cpp:281
MythVideoTextureOpenGL::~MythVideoTextureOpenGL
~MythVideoTextureOpenGL()=default
mythrenderopengl.h
MythVideoTextureOpenGL::CreateSoftwareTextures
static std::vector< MythVideoTextureOpenGL * > CreateSoftwareTextures(MythRenderOpenGL *Context, VideoFrameType Type, VideoFrameType Format, std::vector< QSize > Sizes, GLenum Target)
Create a set of OpenGL textures to represent the given Format.
Definition: mythvideotextureopengl.cpp:133
VideoFrameType
VideoFrameType
Definition: mythframe.h:20
MythVideoTextureOpenGL::m_allowGLSLDeint
bool m_allowGLSLDeint
Definition: mythvideotextureopengl.h:55
MythVideoTextureOpenGL::DeleteTexture
static void DeleteTexture(MythRenderOpenGL *Context, MythVideoTextureOpenGL *Texture)
Definition: mythvideotextureopengl.cpp:17
uint
unsigned int uint
Definition: compat.h:81
MythVideoTextureOpenGL::m_plane
uint m_plane
Definition: mythvideotextureopengl.h:53
VideoFramebuffer
std::pair< QOpenGLFramebufferObject *, MythVideoTextureOpenGL * > VideoFramebuffer
Definition: mythvideotextureopengl.h:19
MythRenderOpenGL
Definition: mythrenderopengl.h:96
MythVideoTextureOpenGL::CreateHardwareTextures
static std::vector< MythVideoTextureOpenGL * > CreateHardwareTextures(MythRenderOpenGL *Context, VideoFrameType Type, VideoFrameType Format, std::vector< QSize > Sizes, GLenum Target)
Create a set of hardware textures suitable for the given format.
Definition: mythvideotextureopengl.cpp:85
MythVideoTextureOpenGL::DeleteTextures
static void DeleteTextures(MythRenderOpenGL *Context, std::vector< MythVideoTextureOpenGL * > &Textures)
Definition: mythvideotextureopengl.cpp:31
MythVideoTextureOpenGL::CreateVideoFrameBuffer
static VideoFramebuffer CreateVideoFrameBuffer(MythRenderOpenGL *Context, VideoFrameType OutputType, QSize Size, bool HighPrecision=true)
Definition: mythvideotextureopengl.cpp:583
mythavutil.h
MythVideoTextureOpenGL::YV12ToYV12
static void YV12ToYV12(MythRenderOpenGL *Context, const MythVideoFrame *Frame, MythVideoTextureOpenGL *Texture, uint Plane)
Copy YV12 frame data to 'YV12' textures.
Definition: mythvideotextureopengl.cpp:485
MythVideoTextureOpenGL::CreateBuffer
static bool CreateBuffer(MythVideoTextureOpenGL *Texture, int Size)
Create a data buffer for holding CPU side texture data.
Definition: mythvideotextureopengl.cpp:566
MythAVCopy
Definition: mythavutil.h:42
MythVideoTextureOpenGL::m_frameType
VideoFrameType m_frameType
Definition: mythvideotextureopengl.h:51
MythVideoTextureOpenGL::CreateTexture
static MythVideoTextureOpenGL * CreateTexture(MythRenderOpenGL *Context, QSize Size, GLenum Target=QOpenGLTexture::Target2D, QOpenGLTexture::PixelType PixelType=QOpenGLTexture::UInt8, QOpenGLTexture::PixelFormat PixelFormat=QOpenGLTexture::RGBA, QOpenGLTexture::TextureFormat Format=QOpenGLTexture::NoFormat, QOpenGLTexture::Filter Filter=QOpenGLTexture::Linear, QOpenGLTexture::WrapMode Wrap=QOpenGLTexture::ClampToEdge)
Create and initialise a MythVideoTexture that is backed by a QOpenGLTexture.
Definition: mythvideotextureopengl.cpp:432
MythVideoFrame
Definition: mythframe.h:88
MythVideoTextureOpenGL::NV12ToNV12
static void NV12ToNV12(MythRenderOpenGL *Context, const MythVideoFrame *Frame, MythVideoTextureOpenGL *Texture, uint Plane)
Copy NV12 video frame data to 'NV12' textures.
Definition: mythvideotextureopengl.cpp:540
MythVideoTextureOpenGL::m_filter
QOpenGLTexture::Filter m_filter
Definition: mythvideotextureopengl.h:50
MythVideoTextureOpenGL::YV12ToYUYV
static void YV12ToYUYV(const MythVideoFrame *Frame, MythVideoTextureOpenGL *Texture)
Copy YV12 frame data to a YUYV texture.
Definition: mythvideotextureopengl.cpp:513
MythVideoTextureOpenGL::CreateTextures
static std::vector< MythVideoTextureOpenGL * > CreateTextures(MythRenderOpenGL *Context, VideoFrameType Type, VideoFrameType Format, std::vector< QSize > Sizes, GLenum Target=QOpenGLTexture::Target2D)
Create a set of textures suitable for the given Type and Format.
Definition: mythvideotextureopengl.cpp:57
MythVideoTextureOpenGL::m_copyContext
MythAVCopy * m_copyContext
Definition: mythvideotextureopengl.h:59
MythVideoTextureOpenGL::m_valid
bool m_valid
Definition: mythvideotextureopengl.h:49