A class used to display video frames and associated imagery using the OpenGL API. More...
#include <openglvideo.h>
Public Member Functions | |
| OpenGLVideo () | |
| Create a new OpenGLVideo instance that must be initialised with a call to OpenGLVideo::Init(). | |
| ~OpenGLVideo () | |
| bool | Init (MythRenderOpenGL *glcontext, VideoColourSpace *colourspace, QSize videoDim, QSize videoDispDim, QRect displayVisibleRect, QRect displayVideoRect, QRect videoRect, bool viewport_control, QString options, bool hwaccel) |
| uint | GetInputTexture (void) const |
| uint | GetTextureType (void) const |
| void | SetInputUpdated (void) |
| void | UpdateInputFrame (const VideoFrame *frame, bool soft_bob=false) |
| Update the current input texture using the data from the given YV12 video frame. | |
| bool | AddFilter (const QString &filter) |
| Public interface to AddFilter(OpenGLFilterType filter). | |
| bool | RemoveFilter (const QString &filter) |
| bool | AddDeinterlacer (const QString &deinterlacer) |
| Extends the functionality of the basic YUV->RGB filter stage to include deinterlacing (combining the stages is significantly more efficient than 2 separate stages). | |
| void | SetDeinterlacing (bool deinterlacing) |
| QString | GetDeinterlacer (void) const |
| void | SetSoftwareDeinterlacer (const QString &filter) |
| void | PrepareFrame (bool topfieldfirst, FrameScanType scan, bool softwareDeinterlacing, long long frame, StereoscopicMode stereo, bool draw_border=false) |
| void | SetMasterViewport (QSize size) |
| QSize | GetViewPort (void) const |
| void | SetVideoRect (const QRect &dispvidrect, const QRect &vidrect) |
| QSize | GetVideoSize (void) const |
Private Member Functions | |
| void | Teardown (void) |
| void | SetViewPort (const QSize &new_viewport_size) |
| bool | AddFilter (OpenGLFilterType filter) |
| Add a new filter stage and create any additional resources needed. | |
| bool | RemoveFilter (OpenGLFilterType filter) |
| void | CheckResize (bool deinterlacing, bool allow=true) |
| Determine if the output is to be scaled at all and create or destroy the appropriate filter as necessary. | |
| bool | OptimiseFilters (void) |
| Ensure the current chain of OpenGLFilters is logically correct and has the resources required to complete rendering. | |
| bool | AddFrameBuffer (uint &framebuffer, uint &texture, QSize vid_size) |
| Add a FrameBuffer object of the correct size to the given texture. | |
| uint | AddFragmentProgram (OpenGLFilterType name, QString deint=QString::null, FrameScanType field=kScan_Progressive) |
| Create the correct fragment program for the given filter type. | |
| uint | CreateVideoTexture (QSize size, QSize &tex_size) |
| Create and initialise an OpenGL texture suitable for a YV12 video frame of the given size. | |
| QString | GetProgramString (OpenGLFilterType filter, QString deint=QString::null, FrameScanType field=kScan_Progressive) |
| void | GetProgramStrings (QString &vertex, QString &fragment, OpenGLFilterType filter, QString deint=QString::null, FrameScanType field=kScan_Progressive) |
| void | CustomiseProgramString (QString &string) |
| QSize | GetTextureSize (const QSize &size) |
| void | SetFiltering (void) |
| Set the OpenGL texture mapping functions to optimise speed and quality. | |
| void | RotateTextures (void) |
| void | SetTextureFilters (vector< GLuint > *textures, int filt, int clamp) |
| void | DeleteTextures (vector< GLuint > *textures) |
| void | TearDownDeinterlacer (void) |
Static Private Member Functions | |
| static QString | FilterToString (OpenGLFilterType filter) |
| static OpenGLFilterType | StringToFilter (const QString &filter) |
Private Attributes | |
| MythRenderOpenGL * | gl_context |
| QSize | video_disp_dim |
| QSize | video_dim |
| QSize | viewportSize |
| QSize | masterViewportSize |
| QRect | display_visible_rect |
| QRect | display_video_rect |
| QRect | video_rect |
| QRect | frameBufferRect |
| QString | softwareDeinterlacer |
| QString | hardwareDeinterlacer |
| bool | hardwareDeinterlacing |
| VideoColourSpace * | colourSpace |
| bool | viewportControl |
| vector< GLuint > | referenceTextures |
| vector< GLuint > | inputTextures |
| QSize | inputTextureSize |
| glfilt_map_t | filters |
| long long | currentFrameNum |
| bool | inputUpdated |
| int | refsNeeded |
| bool | textureRects |
| uint | textureType |
| uint | helperTexture |
| OpenGLFilterType | defaultUpsize |
| uint | gl_features |
| uint | videoTextureType |
| bool | preferYCBCR |
A class used to display video frames and associated imagery using the OpenGL API.
The basic operational concept is to use a series of filter stages to generate the desired video output, using limited software assistance alongside OpenGL fragment programs (deinterlacing and YUV->RGB conversion) , FrameBuffer Objects (flexible GPU storage) and PixelBuffer Objects (faster CPU->GPU memory transfers).
In the most basic case, for example, a YV12 frame pre-converted in software to BGRA format is simply blitted to the frame buffer. Currently, the most complicated example is the rendering of a standard definition, interlaced frame to a high(er) definition display using OpenGL (i.e. hardware based) deinterlacing, colourspace conversion and bicubic upsampling.
Higher level tasks such as coordination between OpenGLVideo instances, video buffer management, audio/video synchronisation etc are handled by the higher level classes VideoOutput and NuppelVideoPlayer. The bulk of the lower level interface with the window system and OpenGL is handled by MythRenderOpenGL.
N.B. Direct use of OpenGL calls is minimised to maintain platform independance. The only member function where this is impractical is PrepareFrame().
Definition at line 37 of file openglvideo.h.
| OpenGLVideo::OpenGLVideo | ( | ) |
Create a new OpenGLVideo instance that must be initialised with a call to OpenGLVideo::Init().
Definition at line 65 of file openglvideo.cpp.
| OpenGLVideo::~OpenGLVideo | ( | ) |
Definition at line 82 of file openglvideo.cpp.
| bool OpenGLVideo::Init | ( | MythRenderOpenGL * | glcontext, | |
| VideoColourSpace * | colourspace, | |||
| QSize | videoDim, | |||
| QSize | videoDispDim, | |||
| QRect | displayVisibleRect, | |||
| QRect | displayVideoRect, | |||
| QRect | videoRect, | |||
| bool | viewport_control, | |||
| QString | options, | |||
| bool | hwaccel | |||
| ) |
Definition at line 126 of file openglvideo.cpp.
Referenced by VideoOutputOpenGL::SetupOpenGL(), and VideoOutputOpenGL::ShowPIP().
| uint OpenGLVideo::GetInputTexture | ( | void | ) | const |
Definition at line 770 of file openglvideo.cpp.
Referenced by VideoOutputOpenGLVAAPI::ProcessFrame().
| uint OpenGLVideo::GetTextureType | ( | void | ) | const |
Definition at line 775 of file openglvideo.cpp.
Referenced by VideoOutputOpenGLVAAPI::ProcessFrame().
| void OpenGLVideo::SetInputUpdated | ( | void | ) |
Definition at line 780 of file openglvideo.cpp.
Referenced by VideoOutputOpenGLVAAPI::ProcessFrame().
| void OpenGLVideo::UpdateInputFrame | ( | const VideoFrame * | frame, | |
| bool | soft_bob = false | |||
| ) |
Update the current input texture using the data from the given YV12 video frame.
If the required hardware support is not available, fall back to software YUV->RGB conversion.
Definition at line 792 of file openglvideo.cpp.
Referenced by VideoOutputOpenGL::ProcessFrame(), and VideoOutputOpenGL::ShowPIP().
| bool OpenGLVideo::AddFilter | ( | const QString & | filter | ) | [inline] |
Public interface to AddFilter(OpenGLFilterType filter).
Definition at line 55 of file openglvideo.h.
Referenced by AddFilter(), CheckResize(), and Init().
| bool OpenGLVideo::RemoveFilter | ( | const QString & | filter | ) | [inline] |
Definition at line 57 of file openglvideo.h.
Referenced by AddFilter(), CheckResize(), RemoveFilter(), and Teardown().
| bool OpenGLVideo::AddDeinterlacer | ( | const QString & | deinterlacer | ) |
Extends the functionality of the basic YUV->RGB filter stage to include deinterlacing (combining the stages is significantly more efficient than 2 separate stages).
Create 2 deinterlacing fragment programs, 1 for each required field.
Definition at line 561 of file openglvideo.cpp.
Referenced by VideoOutputOpenGL::SetupDeinterlace().
| void OpenGLVideo::SetDeinterlacing | ( | bool | deinterlacing | ) |
Definition at line 846 of file openglvideo.cpp.
Referenced by VideoOutputOpenGL::SetDeinterlacingEnabled(), and VideoOutputOpenGL::SetupDeinterlace().
| QString OpenGLVideo::GetDeinterlacer | ( | void | ) | const [inline] |
Definition at line 62 of file openglvideo.h.
Referenced by VideoOutputOpenGL::SetDeinterlacingEnabled(), and VideoOutputOpenGL::SetupDeinterlace().
| void OpenGLVideo::SetSoftwareDeinterlacer | ( | const QString & | filter | ) |
Definition at line 853 of file openglvideo.cpp.
Referenced by VideoOutputOpenGL::SetupDeinterlace(), and VideoOutputOpenGL::SetupOpenGL().
| void OpenGLVideo::PrepareFrame | ( | bool | topfieldfirst, | |
| FrameScanType | scan, | |||
| bool | softwareDeinterlacing, | |||
| long long | frame, | |||
| StereoscopicMode | stereo, | |||
| bool | draw_border = false | |||
| ) |
Definition at line 877 of file openglvideo.cpp.
Referenced by VideoOutputOpenGL::PrepareFrame().
| void OpenGLVideo::SetMasterViewport | ( | QSize | size | ) | [inline] |
Definition at line 71 of file openglvideo.h.
Referenced by VideoOutputOpenGL::ShowPIP().
| QSize OpenGLVideo::GetViewPort | ( | void | ) | const [inline] |
Definition at line 72 of file openglvideo.h.
Referenced by VideoOutputOpenGL::ShowPIP().
| void OpenGLVideo::SetVideoRect | ( | const QRect & | dispvidrect, | |
| const QRect & | vidrect | |||
| ) | [inline] |
Definition at line 73 of file openglvideo.h.
Referenced by VideoOutputOpenGL::MoveResize(), VideoOutputOpenGL::PrepareFrame(), and VideoOutputOpenGL::ShowPIP().
| QSize OpenGLVideo::GetVideoSize | ( | void | ) | const [inline] |
Definition at line 75 of file openglvideo.h.
Referenced by VideoOutputOpenGL::ShowPIP().
| void OpenGLVideo::Teardown | ( | void | ) | [private] |
Definition at line 88 of file openglvideo.cpp.
Referenced by Init(), and ~OpenGLVideo().
| void OpenGLVideo::SetViewPort | ( | const QSize & | new_viewport_size | ) | [private] |
Definition at line 697 of file openglvideo.cpp.
Referenced by Init().
| bool OpenGLVideo::AddFilter | ( | OpenGLFilterType | filter | ) | [private] |
Add a new filter stage and create any additional resources needed.
Definition at line 422 of file openglvideo.cpp.
| bool OpenGLVideo::RemoveFilter | ( | OpenGLFilterType | filter | ) | [private] |
Definition at line 501 of file openglvideo.cpp.
Determine if the output is to be scaled at all and create or destroy the appropriate filter as necessary.
Definition at line 280 of file openglvideo.cpp.
Referenced by AddDeinterlacer(), Init(), SetDeinterlacing(), and SetSoftwareDeinterlacer().
| bool OpenGLVideo::OptimiseFilters | ( | void | ) | [private] |
Ensure the current chain of OpenGLFilters is logically correct and has the resources required to complete rendering.
Definition at line 323 of file openglvideo.cpp.
Referenced by AddFilter(), and CheckResize().
Add a FrameBuffer object of the correct size to the given texture.
Definition at line 678 of file openglvideo.cpp.
Referenced by OptimiseFilters().
| uint OpenGLVideo::AddFragmentProgram | ( | OpenGLFilterType | name, | |
| QString | deint = QString::null, |
|||
| FrameScanType | field = kScan_Progressive | |||
| ) | [private] |
Create the correct fragment program for the given filter type.
Definition at line 648 of file openglvideo.cpp.
Referenced by AddDeinterlacer(), and AddFilter().
| uint OpenGLVideo::CreateVideoTexture | ( | QSize | size, | |
| QSize & | tex_size | |||
| ) | [private] |
Create and initialise an OpenGL texture suitable for a YV12 video frame of the given size.
Definition at line 717 of file openglvideo.cpp.
Referenced by AddDeinterlacer(), and Init().
| QString OpenGLVideo::GetProgramString | ( | OpenGLFilterType | filter, | |
| QString | deint = QString::null, |
|||
| FrameScanType | field = kScan_Progressive | |||
| ) | [private] |
Definition at line 1278 of file openglvideo.cpp.
Referenced by AddFragmentProgram().
| void OpenGLVideo::GetProgramStrings | ( | QString & | vertex, | |
| QString & | fragment, | |||
| OpenGLFilterType | filter, | |||
| QString | deint = QString::null, |
|||
| FrameScanType | field = kScan_Progressive | |||
| ) | [private] |
Definition at line 1577 of file openglvideo.cpp.
Referenced by AddFragmentProgram().
| void OpenGLVideo::CustomiseProgramString | ( | QString & | string | ) | [private] |
Definition at line 1355 of file openglvideo.cpp.
Referenced by GetProgramString(), and GetProgramStrings().
| QString OpenGLVideo::FilterToString | ( | OpenGLFilterType | filter | ) | [static, private] |
Definition at line 1127 of file openglvideo.cpp.
Referenced by AddFilter(), GetProgramString(), and RemoveFilter().
| OpenGLFilterType OpenGLVideo::StringToFilter | ( | const QString & | filter | ) | [static, private] |
Definition at line 1113 of file openglvideo.cpp.
Referenced by AddFilter(), and RemoveFilter().
| QSize OpenGLVideo::GetTextureSize | ( | const QSize & | size | ) | [private] |
Definition at line 749 of file openglvideo.cpp.
Referenced by CustomiseProgramString(), and PrepareFrame().
| void OpenGLVideo::SetFiltering | ( | void | ) | [private] |
Set the OpenGL texture mapping functions to optimise speed and quality.
Definition at line 386 of file openglvideo.cpp.
Referenced by OptimiseFilters().
| void OpenGLVideo::RotateTextures | ( | void | ) | [private] |
Definition at line 1076 of file openglvideo.cpp.
Referenced by UpdateInputFrame().
| void OpenGLVideo::SetTextureFilters | ( | vector< GLuint > * | textures, | |
| int | filt, | |||
| int | clamp | |||
| ) | [private] |
Definition at line 1103 of file openglvideo.cpp.
Referenced by SetFiltering().
| void OpenGLVideo::DeleteTextures | ( | vector< GLuint > * | textures | ) | [private] |
Definition at line 1093 of file openglvideo.cpp.
Referenced by RemoveFilter(), Teardown(), and TearDownDeinterlacer().
| void OpenGLVideo::TearDownDeinterlacer | ( | void | ) | [private] |
Definition at line 530 of file openglvideo.cpp.
Referenced by AddDeinterlacer().
MythRenderOpenGL* OpenGLVideo::gl_context [private] |
Definition at line 107 of file openglvideo.h.
Referenced by AddDeinterlacer(), AddFilter(), AddFragmentProgram(), AddFrameBuffer(), CreateVideoTexture(), DeleteTextures(), Init(), OptimiseFilters(), PrepareFrame(), RemoveFilter(), SetDeinterlacing(), SetTextureFilters(), SetViewPort(), Teardown(), TearDownDeinterlacer(), UpdateInputFrame(), and ~OpenGLVideo().
QSize OpenGLVideo::video_disp_dim [private] |
Definition at line 108 of file openglvideo.h.
Referenced by CheckResize(), CustomiseProgramString(), Init(), OptimiseFilters(), PrepareFrame(), and SetViewPort().
QSize OpenGLVideo::video_dim [private] |
Definition at line 109 of file openglvideo.h.
Referenced by AddDeinterlacer(), GetVideoSize(), Init(), PrepareFrame(), and UpdateInputFrame().
QSize OpenGLVideo::viewportSize [private] |
Definition at line 110 of file openglvideo.h.
Referenced by GetViewPort(), and SetViewPort().
QSize OpenGLVideo::masterViewportSize [private] |
Definition at line 111 of file openglvideo.h.
Referenced by Init(), PrepareFrame(), and SetMasterViewport().
QRect OpenGLVideo::display_visible_rect [private] |
Definition at line 112 of file openglvideo.h.
Referenced by Init(), and PrepareFrame().
QRect OpenGLVideo::display_video_rect [private] |
Definition at line 113 of file openglvideo.h.
Referenced by CheckResize(), Init(), PrepareFrame(), and SetVideoRect().
QRect OpenGLVideo::video_rect [private] |
Definition at line 114 of file openglvideo.h.
Referenced by Init(), PrepareFrame(), and SetVideoRect().
QRect OpenGLVideo::frameBufferRect [private] |
Definition at line 115 of file openglvideo.h.
Referenced by Init(), and PrepareFrame().
QString OpenGLVideo::softwareDeinterlacer [private] |
Definition at line 116 of file openglvideo.h.
Referenced by Init(), PrepareFrame(), and SetSoftwareDeinterlacer().
QString OpenGLVideo::hardwareDeinterlacer [private] |
Definition at line 117 of file openglvideo.h.
Referenced by AddDeinterlacer(), GetDeinterlacer(), and PrepareFrame().
bool OpenGLVideo::hardwareDeinterlacing [private] |
Definition at line 118 of file openglvideo.h.
Referenced by AddDeinterlacer(), Init(), PrepareFrame(), SetDeinterlacing(), and UpdateInputFrame().
VideoColourSpace* OpenGLVideo::colourSpace [private] |
Definition at line 119 of file openglvideo.h.
Referenced by Init(), and PrepareFrame().
bool OpenGLVideo::viewportControl [private] |
Definition at line 120 of file openglvideo.h.
Referenced by Init(), PrepareFrame(), and SetViewPort().
vector<GLuint> OpenGLVideo::referenceTextures [private] |
Definition at line 121 of file openglvideo.h.
Referenced by AddDeinterlacer(), PrepareFrame(), RotateTextures(), SetFiltering(), Teardown(), and TearDownDeinterlacer().
vector<GLuint> OpenGLVideo::inputTextures [private] |
Definition at line 122 of file openglvideo.h.
Referenced by GetInputTexture(), Init(), PrepareFrame(), RotateTextures(), SetFiltering(), Teardown(), and UpdateInputFrame().
QSize OpenGLVideo::inputTextureSize [private] |
Definition at line 123 of file openglvideo.h.
Referenced by AddDeinterlacer(), CustomiseProgramString(), Init(), and PrepareFrame().
glfilt_map_t OpenGLVideo::filters [private] |
Definition at line 124 of file openglvideo.h.
Referenced by AddDeinterlacer(), AddFilter(), CheckResize(), Init(), OptimiseFilters(), PrepareFrame(), RemoveFilter(), SetFiltering(), Teardown(), TearDownDeinterlacer(), and UpdateInputFrame().
long long OpenGLVideo::currentFrameNum [private] |
Definition at line 125 of file openglvideo.h.
Referenced by Init(), and PrepareFrame().
bool OpenGLVideo::inputUpdated [private] |
Definition at line 126 of file openglvideo.h.
Referenced by Init(), PrepareFrame(), SetInputUpdated(), and UpdateInputFrame().
int OpenGLVideo::refsNeeded [private] |
Definition at line 127 of file openglvideo.h.
Referenced by AddDeinterlacer(), PrepareFrame(), RotateTextures(), and TearDownDeinterlacer().
bool OpenGLVideo::textureRects [private] |
Definition at line 128 of file openglvideo.h.
Referenced by CustomiseProgramString(), GetTextureSize(), Init(), and PrepareFrame().
uint OpenGLVideo::textureType [private] |
Definition at line 129 of file openglvideo.h.
Referenced by AddFrameBuffer(), CreateVideoTexture(), GetTextureType(), and Init().
uint OpenGLVideo::helperTexture [private] |
Definition at line 130 of file openglvideo.h.
Referenced by AddFilter(), PrepareFrame(), and Teardown().
OpenGLFilterType OpenGLVideo::defaultUpsize [private] |
Definition at line 131 of file openglvideo.h.
Referenced by CheckResize(), and Init().
uint OpenGLVideo::gl_features [private] |
Definition at line 132 of file openglvideo.h.
Referenced by AddDeinterlacer(), AddFilter(), AddFragmentProgram(), AddFrameBuffer(), CreateVideoTexture(), and Init().
uint OpenGLVideo::videoTextureType [private] |
Definition at line 133 of file openglvideo.h.
Referenced by CheckResize(), CreateVideoTexture(), GetProgramString(), GetProgramStrings(), Init(), PrepareFrame(), and UpdateInputFrame().
bool OpenGLVideo::preferYCBCR [private] |
Definition at line 134 of file openglvideo.h.
Referenced by Init().
1.6.3