MythTV  master
Public Types | Public Slots | Signals | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
MythOpenGLVideo Class Reference

#include <mythopenglvideo.h>

Inheritance diagram for MythOpenGLVideo:
Inheritance graph
[legend]
Collaboration diagram for MythOpenGLVideo:
Collaboration graph
[legend]

Public Types

enum  VideoShaderType {
  Default = 0, Progressive = 1, InterlacedTop = 2, InterlacedBot = 3,
  ShaderCount = 4
}
 
enum  VideoResize {
  None = 0x000, Deinterlacer = 0x001, Sampling = 0x002, Performance = 0x004,
  Framebuffer = 0x008, ToneMap = 0x010
}
 

Public Slots

void SetVideoDimensions (const QSize &VideoDim, const QSize &VideoDispDim)
 
void SetVideoRects (const QRect &DisplayVideoRect, const QRect &VideoRect)
 
void SetViewportRect (const QRect &DisplayVisibleRect)
 
void UpdateColourSpace (bool PrimariesChanged)
 
void UpdateShaderParameters (void)
 

Signals

void OutputChanged (QSize VideoDim, QSize VideoDispDim, float)
 

Public Member Functions

 MythOpenGLVideo (MythRenderOpenGL *Render, VideoColourSpace *ColourSpace, QSize VideoDim, QSize VideoDispDim, QRect DisplayVisibleRect, QRect DisplayVideoRect, QRect videoRect, bool ViewportControl, QString Profile)
 
 ~MythOpenGLVideo () override
 
bool IsValid (void) const
 
void ProcessFrame (VideoFrame *Frame, FrameScanType Scan=kScan_Progressive)
 Update the current input texture using the data from the given video frame. More...
 
void PrepareFrame (VideoFrame *Frame, bool TopFieldFirst, FrameScanType Scan, StereoscopicMode Stereo, bool DrawBorder=false)
 
void SetMasterViewport (QSize Size)
 
QSize GetVideoSize (void) const
 
QString GetProfile () const
 
void SetProfile (const QString &Profile)
 
void ResetFrameFormat (void)
 
void ResetTextures (void)
 Clear reference frames after a seek as they will contain old images. More...
 

Static Public Member Functions

static QString TypeToProfile (VideoFrameType Type)
 
static QString VideoResizeToString (VideoResizing Resize)
 

Private Member Functions

bool SetupFrameFormat (VideoFrameType InputType, VideoFrameType OutputType, QSize Size, GLenum TextureTarget)
 
bool CreateVideoShader (VideoShaderType Type, MythDeintType Deint=DEINT_NONE)
 Create the appropriate shader for the operation Type. More...
 
void BindTextures (bool Deinterlacing, vector< MythVideoTexture * > &Current, MythGLTexture **Textures, uint &TextureCount)
 
bool AddDeinterlacer (const VideoFrame *Frame, FrameScanType Scan, MythDeintType Filter=DEINT_SHADER, bool CreateReferences=true)
 
QOpenGLFramebufferObject * CreateVideoFrameBuffer (VideoFrameType OutputType, QSize Size)
 
void CleanupDeinterlacers (void)
 

Private Attributes

bool m_valid { false }
 
QString m_profile
 
VideoFrameType m_inputType { FMT_NONE }
 Usually YV12 for software, VDPAU etc for hardware. More...
 
VideoFrameType m_outputType { FMT_NONE }
 Set by profile for software or decoder for hardware. More...
 
MythRenderOpenGLm_render { nullptr }
 
int m_gles { 0 }
 
QSize m_videoDispDim
 Useful video frame size e.g. 1920x1080. More...
 
QSize m_videoDim
 Total video frame size e.g. 1920x1088. More...
 
QSize m_masterViewportSize
 Current viewport into which OpenGL is rendered, usually the window size. More...
 
QRect m_displayVideoRect
 Sub-rect of display_visible_rect for video. More...
 
QRect m_videoRect
 Sub-rect of video_disp_dim to display (after zoom adjustments etc) More...
 
MythDeintType m_deinterlacer { MythDeintType::DEINT_NONE }
 
bool m_deinterlacer2x { false }
 
MythDeintType m_fallbackDeinterlacer { MythDeintType::DEINT_NONE }
 Only used if there are insufficient texture units (for kernel) More...
 
VideoColourSpacem_videoColourSpace
 
bool m_viewportControl
 Video has control over view port. More...
 
QOpenGLShaderProgram * m_shaders [ShaderCount] { nullptr }
 
int m_shaderCost [ShaderCount] { 1 }
 
vector< MythVideoTexture * > m_inputTextures
 Current textures with raw video data. More...
 
vector< MythVideoTexture * > m_prevTextures
 Previous textures with raw video data. More...
 
vector< MythVideoTexture * > m_nextTextures
 Next textures with raw video data. More...
 
QOpenGLFramebufferObject * m_frameBuffer { nullptr }
 
MythVideoTexturem_frameBufferTexture { nullptr }
 
QSize m_inputTextureSize
 Actual size of input texture(s) More...
 
QOpenGLFunctions::OpenGLFeatures m_features
 Default features available from Qt. More...
 
int m_extraFeatures { 0 }
 OR'd list of extra, Myth specific features. More...
 
VideoResizing m_resizing { None }
 
GLenum m_textureTarget { QOpenGLTexture::Target2D }
 Some interops require custom texture targets. More...
 
long long m_discontinuityCounter { 0 }
 Check when to release reference frames after a skip. More...
 
int m_lastRotation { 0 }
 Track rotation for pause frame. More...
 
bool m_chromaUpsamplingFilter { false }
 
MythOpenGLTonemapm_toneMap { nullptr }
 Attempt to fix Chroma Upsampling Error in shaders. More...
 

Detailed Description

MythOpenGLVideo is responsible for displaying video frames on screen using OpenGL. Frames may be sourced from main or graphics memory and MythOpenGLVideo must handle colourspace conversion, deinterlacing and scaling as required.

Note
MythOpenGLVideo has no knowledge of buffering, timing and other presentation state. Its role is to render video frames on screen.

Definition at line 23 of file mythopenglvideo.h.

Member Enumeration Documentation

◆ VideoShaderType

Enumerator
Default 
Progressive 
InterlacedTop 
InterlacedBot 
ShaderCount 

Definition at line 28 of file mythopenglvideo.h.

◆ VideoResize

Enumerator
None 
Deinterlacer 
Sampling 
Performance 
Framebuffer 
ToneMap 

Definition at line 37 of file mythopenglvideo.h.

Constructor & Destructor Documentation

◆ MythOpenGLVideo()

MythOpenGLVideo::MythOpenGLVideo ( MythRenderOpenGL Render,
VideoColourSpace ColourSpace,
QSize  VideoDim,
QSize  VideoDispDim,
QRect  DisplayVisibleRect,
QRect  DisplayVideoRect,
QRect  videoRect,
bool  ViewportControl,
QString  Profile 
)

Definition at line 26 of file mythopenglvideo.cpp.

◆ ~MythOpenGLVideo()

MythOpenGLVideo::~MythOpenGLVideo ( )
override

Definition at line 62 of file mythopenglvideo.cpp.

Member Function Documentation

◆ TypeToProfile()

QString MythOpenGLVideo::TypeToProfile ( VideoFrameType  Type)
static

Definition at line 1058 of file mythopenglvideo.cpp.

Referenced by GetProfile().

◆ VideoResizeToString()

QString MythOpenGLVideo::VideoResizeToString ( VideoResizing  Resize)
static

Definition at line 1073 of file mythopenglvideo.cpp.

Referenced by PrepareFrame().

◆ IsValid()

bool MythOpenGLVideo::IsValid ( void  ) const

◆ ProcessFrame()

void MythOpenGLVideo::ProcessFrame ( VideoFrame Frame,
FrameScanType  Scan = kScan_Progressive 
)

Update the current input texture using the data from the given video frame.

Definition at line 586 of file mythopenglvideo.cpp.

Referenced by MythVideoOutputOpenGL::ProcessFrame(), MythVideoOutputOpenGL::ShowPIP(), and MythVideoOutputOpenGL::UpdatePauseFrame().

◆ PrepareFrame()

void MythOpenGLVideo::PrepareFrame ( VideoFrame Frame,
bool  TopFieldFirst,
FrameScanType  Scan,
StereoscopicMode  Stereo,
bool  DrawBorder = false 
)

Definition at line 687 of file mythopenglvideo.cpp.

Referenced by MythVideoOutputOpenGL::PrepareFrame().

◆ SetMasterViewport()

void MythOpenGLVideo::SetMasterViewport ( QSize  Size)

Definition at line 133 of file mythopenglvideo.cpp.

Referenced by SetViewportRect(), and MythVideoOutputOpenGL::ShowPIP().

◆ GetVideoSize()

QSize MythOpenGLVideo::GetVideoSize ( void  ) const

Definition at line 167 of file mythopenglvideo.cpp.

Referenced by MythVideoOutputOpenGL::ShowPIP().

◆ GetProfile()

QString MythOpenGLVideo::GetProfile ( ) const

Definition at line 155 of file mythopenglvideo.cpp.

Referenced by SetupFrameFormat().

◆ SetProfile()

void MythOpenGLVideo::SetProfile ( const QString &  Profile)

Definition at line 162 of file mythopenglvideo.cpp.

Referenced by MythVideoOutputOpenGL::Init().

◆ ResetFrameFormat()

void MythOpenGLVideo::ResetFrameFormat ( void  )

◆ ResetTextures()

void MythOpenGLVideo::ResetTextures ( void  )

Clear reference frames after a seek as they will contain old images.

Definition at line 1015 of file mythopenglvideo.cpp.

Referenced by MythVideoOutputOpenGL::ClearAfterSeek(), and ProcessFrame().

◆ OutputChanged

void MythOpenGLVideo::OutputChanged ( QSize  VideoDim,
QSize  VideoDispDim,
float   
)
signal

◆ SetVideoDimensions

void MythOpenGLVideo::SetVideoDimensions ( const QSize &  VideoDim,
const QSize &  VideoDispDim 
)
slot

Definition at line 138 of file mythopenglvideo.cpp.

Referenced by MythVideoOutputOpenGL::MythVideoOutputOpenGL().

◆ SetVideoRects

void MythOpenGLVideo::SetVideoRects ( const QRect &  DisplayVideoRect,
const QRect &  VideoRect 
)
slot

◆ SetViewportRect

void MythOpenGLVideo::SetViewportRect ( const QRect &  DisplayVisibleRect)
slot

Definition at line 150 of file mythopenglvideo.cpp.

Referenced by MythVideoOutputOpenGL::MythVideoOutputOpenGL().

◆ UpdateColourSpace

void MythOpenGLVideo::UpdateColourSpace ( bool  PrimariesChanged)
slot

Definition at line 82 of file mythopenglvideo.cpp.

Referenced by AddDeinterlacer(), MythOpenGLVideo(), and SetupFrameFormat().

◆ UpdateShaderParameters

void MythOpenGLVideo::UpdateShaderParameters ( void  )
slot

Definition at line 108 of file mythopenglvideo.cpp.

Referenced by AddDeinterlacer(), and SetupFrameFormat().

◆ SetupFrameFormat()

bool MythOpenGLVideo::SetupFrameFormat ( VideoFrameType  InputType,
VideoFrameType  OutputType,
QSize  Size,
GLenum  TextureTarget 
)
private

◆ CreateVideoShader()

bool MythOpenGLVideo::CreateVideoShader ( VideoShaderType  Type,
MythDeintType  Deint = DEINT_NONE 
)
private

Create the appropriate shader for the operation Type.

Note
Shader cost is calculated as 1 per texture read and 2 per dependent read. If there are alternative shader conditions, the worst case is used. (A dependent read is defined as any texture read that does not use the exact texture coordinates passed into the fragment shader)

Definition at line 334 of file mythopenglvideo.cpp.

Referenced by AddDeinterlacer(), and SetupFrameFormat().

◆ BindTextures()

void MythOpenGLVideo::BindTextures ( bool  Deinterlacing,
vector< MythVideoTexture * > &  Current,
MythGLTexture **  Textures,
uint TextureCount 
)
private

Definition at line 1025 of file mythopenglvideo.cpp.

Referenced by PrepareFrame().

◆ AddDeinterlacer()

bool MythOpenGLVideo::AddDeinterlacer ( const VideoFrame Frame,
FrameScanType  Scan,
MythDeintType  Filter = DEINT_SHADER,
bool  CreateReferences = true 
)
private

Definition at line 194 of file mythopenglvideo.cpp.

Referenced by PrepareFrame(), and ProcessFrame().

◆ CreateVideoFrameBuffer()

QOpenGLFramebufferObject * MythOpenGLVideo::CreateVideoFrameBuffer ( VideoFrameType  OutputType,
QSize  Size 
)
private

Definition at line 1083 of file mythopenglvideo.cpp.

Referenced by PrepareFrame().

◆ CleanupDeinterlacers()

void MythOpenGLVideo::CleanupDeinterlacers ( void  )
private

Definition at line 172 of file mythopenglvideo.cpp.

Referenced by AddDeinterlacer().

Member Data Documentation

◆ m_valid

bool MythOpenGLVideo::m_valid { false }
private

Definition at line 90 of file mythopenglvideo.h.

Referenced by IsValid(), and MythOpenGLVideo().

◆ m_profile

QString MythOpenGLVideo::m_profile
private

Definition at line 91 of file mythopenglvideo.h.

Referenced by CleanupDeinterlacers(), ProcessFrame(), and SetProfile().

◆ m_inputType

VideoFrameType MythOpenGLVideo::m_inputType { FMT_NONE }
private

◆ m_outputType

VideoFrameType MythOpenGLVideo::m_outputType { FMT_NONE }
private

Set by profile for software or decoder for hardware.

Definition at line 93 of file mythopenglvideo.h.

Referenced by AddDeinterlacer(), CleanupDeinterlacers(), CreateVideoShader(), GetProfile(), PrepareFrame(), ResetFrameFormat(), SetupFrameFormat(), and UpdateColourSpace().

◆ m_render

MythRenderOpenGL* MythOpenGLVideo::m_render { nullptr }
private

◆ m_gles

int MythOpenGLVideo::m_gles { 0 }
private

Definition at line 95 of file mythopenglvideo.h.

Referenced by CreateVideoShader(), MythOpenGLVideo(), and PrepareFrame().

◆ m_videoDispDim

QSize MythOpenGLVideo::m_videoDispDim
private

Useful video frame size e.g. 1920x1080.

Definition at line 96 of file mythopenglvideo.h.

Referenced by PrepareFrame(), SetVideoDimensions(), and UpdateShaderParameters().

◆ m_videoDim

QSize MythOpenGLVideo::m_videoDim
private

Total video frame size e.g. 1920x1088.

Definition at line 97 of file mythopenglvideo.h.

Referenced by AddDeinterlacer(), CleanupDeinterlacers(), GetVideoSize(), ProcessFrame(), SetupFrameFormat(), SetVideoDimensions(), and UpdateColourSpace().

◆ m_masterViewportSize

QSize MythOpenGLVideo::m_masterViewportSize
private

Current viewport into which OpenGL is rendered, usually the window size.

Definition at line 98 of file mythopenglvideo.h.

Referenced by PrepareFrame(), and SetMasterViewport().

◆ m_displayVideoRect

QRect MythOpenGLVideo::m_displayVideoRect
private

Sub-rect of display_visible_rect for video.

Definition at line 99 of file mythopenglvideo.h.

Referenced by PrepareFrame(), and SetVideoRects().

◆ m_videoRect

QRect MythOpenGLVideo::m_videoRect
private

Sub-rect of video_disp_dim to display (after zoom adjustments etc)

Definition at line 100 of file mythopenglvideo.h.

Referenced by PrepareFrame(), and SetVideoRects().

◆ m_deinterlacer

MythDeintType MythOpenGLVideo::m_deinterlacer { MythDeintType::DEINT_NONE }
private

◆ m_deinterlacer2x

bool MythOpenGLVideo::m_deinterlacer2x { false }
private

Definition at line 102 of file mythopenglvideo.h.

Referenced by AddDeinterlacer(), CleanupDeinterlacers(), and PrepareFrame().

◆ m_fallbackDeinterlacer

MythDeintType MythOpenGLVideo::m_fallbackDeinterlacer { MythDeintType::DEINT_NONE }
private

Only used if there are insufficient texture units (for kernel)

Definition at line 103 of file mythopenglvideo.h.

Referenced by AddDeinterlacer(), CleanupDeinterlacers(), and ResetFrameFormat().

◆ m_videoColourSpace

VideoColourSpace* MythOpenGLVideo::m_videoColourSpace
private

◆ m_viewportControl

bool MythOpenGLVideo::m_viewportControl
private

Video has control over view port.

Definition at line 105 of file mythopenglvideo.h.

◆ m_shaders

QOpenGLShaderProgram* MythOpenGLVideo::m_shaders[ShaderCount] { nullptr }
private

◆ m_shaderCost

int MythOpenGLVideo::m_shaderCost[ShaderCount] { 1 }
private

Definition at line 107 of file mythopenglvideo.h.

Referenced by CreateVideoShader(), PrepareFrame(), and ResetFrameFormat().

◆ m_inputTextures

vector<MythVideoTexture*> MythOpenGLVideo::m_inputTextures
private

Current textures with raw video data.

Definition at line 108 of file mythopenglvideo.h.

Referenced by AddDeinterlacer(), PrepareFrame(), ProcessFrame(), ResetFrameFormat(), ResetTextures(), and SetupFrameFormat().

◆ m_prevTextures

vector<MythVideoTexture*> MythOpenGLVideo::m_prevTextures
private

Previous textures with raw video data.

Definition at line 109 of file mythopenglvideo.h.

Referenced by AddDeinterlacer(), BindTextures(), PrepareFrame(), ProcessFrame(), ResetFrameFormat(), and ResetTextures().

◆ m_nextTextures

vector<MythVideoTexture*> MythOpenGLVideo::m_nextTextures
private

Next textures with raw video data.

Definition at line 110 of file mythopenglvideo.h.

Referenced by AddDeinterlacer(), BindTextures(), PrepareFrame(), ProcessFrame(), ResetFrameFormat(), and ResetTextures().

◆ m_frameBuffer

QOpenGLFramebufferObject* MythOpenGLVideo::m_frameBuffer { nullptr }
private

Definition at line 111 of file mythopenglvideo.h.

Referenced by PrepareFrame(), and ResetFrameFormat().

◆ m_frameBufferTexture

MythVideoTexture* MythOpenGLVideo::m_frameBufferTexture { nullptr }
private

Definition at line 112 of file mythopenglvideo.h.

Referenced by PrepareFrame(), and ResetFrameFormat().

◆ m_inputTextureSize

QSize MythOpenGLVideo::m_inputTextureSize
private

Actual size of input texture(s)

Definition at line 113 of file mythopenglvideo.h.

Referenced by PrepareFrame(), ResetFrameFormat(), SetupFrameFormat(), and UpdateShaderParameters().

◆ m_features

QOpenGLFunctions::OpenGLFeatures MythOpenGLVideo::m_features
private

Default features available from Qt.

Definition at line 114 of file mythopenglvideo.h.

Referenced by CreateVideoShader(), and MythOpenGLVideo().

◆ m_extraFeatures

int MythOpenGLVideo::m_extraFeatures { 0 }
private

OR'd list of extra, Myth specific features.

Definition at line 115 of file mythopenglvideo.h.

Referenced by CreateVideoFrameBuffer(), MythOpenGLVideo(), and PrepareFrame().

◆ m_resizing

VideoResizing MythOpenGLVideo::m_resizing { None }
private

Definition at line 116 of file mythopenglvideo.h.

Referenced by AddDeinterlacer(), PrepareFrame(), and ResetFrameFormat().

◆ m_textureTarget

GLenum MythOpenGLVideo::m_textureTarget { QOpenGLTexture::Target2D }
private

Some interops require custom texture targets.

Definition at line 117 of file mythopenglvideo.h.

Referenced by CleanupDeinterlacers(), CreateVideoShader(), PrepareFrame(), ResetFrameFormat(), SetupFrameFormat(), UpdateColourSpace(), and UpdateShaderParameters().

◆ m_discontinuityCounter

long long MythOpenGLVideo::m_discontinuityCounter { 0 }
private

Check when to release reference frames after a skip.

Definition at line 118 of file mythopenglvideo.h.

Referenced by ProcessFrame().

◆ m_lastRotation

int MythOpenGLVideo::m_lastRotation { 0 }
private

Track rotation for pause frame.

Definition at line 119 of file mythopenglvideo.h.

Referenced by PrepareFrame().

◆ m_chromaUpsamplingFilter

bool MythOpenGLVideo::m_chromaUpsamplingFilter { false }
private

Definition at line 120 of file mythopenglvideo.h.

Referenced by CreateVideoShader(), and MythOpenGLVideo().

◆ m_toneMap

MythOpenGLTonemap* MythOpenGLVideo::m_toneMap { nullptr }
private

Attempt to fix Chroma Upsampling Error in shaders.

Definition at line 121 of file mythopenglvideo.h.

Referenced by PrepareFrame(), and ~MythOpenGLVideo().


The documentation for this class was generated from the following files: