MythTV  master
mythvideoout.h
Go to the documentation of this file.
1 #ifndef MYTH_VIDEOOUT_H_
2 #define MYTH_VIDEOOUT_H_
3 
4 // Qt
5 #include <QSize>
6 #include <QRect>
7 #include <QString>
8 #include <QPoint>
9 #include <QMap>
10 #include <qwindowdefs.h>
11 
12 // MythTV
13 #include "mythframe.h"
14 #include "videobuffers.h"
15 #include "mythcodecid.h"
16 #include "videoouttypes.h"
17 #include "mythvideobounds.h"
18 #include "mythdisplay.h"
19 #include "mythvideoprofile.h"
20 #include "mythvideocolourspace.h"
21 #include "mythavutil.h"
22 #include "mythdeinterlacer.h"
23 
24 // Std
25 #include <memory>
26 
27 class MythPlayer;
28 class OSD;
29 class AudioPlayer;
30 class MythRender;
31 class MythPainter;
32 
33 using MythVideoProfilePtr = std::shared_ptr<MythVideoProfile>;
34 
36 {
37  Q_OBJECT
38 
39  public:
40  static void GetRenderOptions(RenderOptions& Options, MythRender* Render);
41 
42  ~MythVideoOutput() override = default;
43 
44  virtual bool Init(QSize VideoDim, QSize VideoDispDim,
45  float VideoAspect, QRect WindowRect, MythCodecID CodecID);
46  virtual void SetVideoFrameRate(float VideoFrameRate);
47  virtual void SetDeinterlacing(bool Enable, bool DoubleRate, MythDeintType Force = DEINT_NONE);
48  virtual void PrepareFrame (MythVideoFrame* Frame, FrameScanType Scan = kScan_Ignore) = 0;
49  virtual void RenderFrame (MythVideoFrame* Frame, FrameScanType) = 0;
50  virtual void RenderEnd () = 0;
51  virtual void EndFrame () = 0;
52  virtual bool InputChanged(QSize VideoDim, QSize VideoDispDim,
53  float VideoAspect, MythCodecID CodecID,
54  bool& AspectChanged, int ReferenceFrames, bool ForceChange);
55  virtual void GetOSDBounds(QRect& Total, QRect& Visible,
56  float& VisibleAspect, float& FontScaling,
57  float ThemeAspect) const;
58  virtual void SetFramesPlayed(long long FramesPlayed);
59  virtual long long GetFramesPlayed();
60  bool IsErrored() const;
61  VideoErrorState GetError() const;
62 
63  void SetPrebuffering(bool Normal);
64  virtual void ClearAfterSeek();
65  virtual int ValidVideoFrames() const;
66  int FreeVideoFrames();
67  bool EnoughFreeFrames();
68  bool EnoughDecodedFrames();
70  virtual void ReleaseFrame(MythVideoFrame* Frame);
71  virtual void DeLimboFrame(MythVideoFrame* Frame);
72  virtual void StartDisplayingFrame();
74  virtual void DiscardFrame(MythVideoFrame* Frame);
75  virtual void DiscardFrames(bool KeyFrame, bool Flushed);
76  virtual void CheckFrameStates() { }
79  QString GetFrameStatus() const;
80  QRect GetImageRect(QRect Rect, QRect* DisplayRect = nullptr);
81  QRect GetSafeRect();
82 
83  // These methods are only required by MythPlayerUI
85  virtual void InitPictureAttributes () { }
86  bool HasSoftwareFrames () const { return codec_sw_copy(m_videoCodecID); }
87  virtual void UpdatePauseFrame (std::chrono::milliseconds& /*DisplayTimecode*/,
88  FrameScanType /*Scan*/ = kScan_Progressive) {}
89 
90  protected:
92  QRect GetVisibleOSDBounds(float& VisibleAspect, float& FontScaling, float ThemeAspect) const;
93 
96  uint8_t m_clearColor { 0 };
97  uint8_t m_clearAlpha { 255 };
103  long long m_framesPlayed { 0 };
107  bool m_deinterlacing { false };
108  bool m_deinterlacing2X { false };
110 
111  private:
112  Q_DISABLE_COPY(MythVideoOutput)
113 };
114 
115 #endif
MythVideoOutput::GetOSDBounds
virtual void GetOSDBounds(QRect &Total, QRect &Visible, float &VisibleAspect, float &FontScaling, float ThemeAspect) const
Definition: mythvideoout.cpp:206
MythVideoOutput::m_dbLetterboxColour
LetterBoxColour m_dbLetterboxColour
Definition: mythvideoout.h:95
MythVideoOutput::InputChanged
virtual bool InputChanged(QSize VideoDim, QSize VideoDispDim, float VideoAspect, MythCodecID CodecID, bool &AspectChanged, int ReferenceFrames, bool ForceChange)
Tells video output to discard decoded frames and wait for new ones.
Definition: mythvideoout.cpp:186
PictureAttributeSupported
PictureAttributeSupported
Definition: videoouttypes.h:116
MythVideoOutput
Definition: mythvideoout.h:35
AudioPlayer
Definition: audioplayer.h:28
kCodec_NONE
@ kCodec_NONE
Definition: mythcodecid.h:14
MythVideoOutput::FreeVideoFrames
int FreeVideoFrames()
Returns number of frames available for decoding onto.
Definition: mythvideoout.cpp:283
MythVideoOutput::GetError
VideoErrorState GetError() const
Definition: mythvideoout.cpp:259
MythVideoOutput::m_framesPlayed
long long m_framesPlayed
Definition: mythvideoout.h:103
kError_None
@ kError_None
Definition: videoouttypes.h:184
VideoBuffers
Definition: videobuffers.h:42
MythVideoOutput::m_errorState
VideoErrorState m_errorState
Definition: mythvideoout.h:102
Frame
Definition: zmdefines.h:93
kLetterBoxColour_Black
@ kLetterBoxColour_Black
Definition: videoouttypes.h:89
VideoErrorState
VideoErrorState
Definition: videoouttypes.h:182
MythVideoOutput::PrepareFrame
virtual void PrepareFrame(MythVideoFrame *Frame, FrameScanType Scan=kScan_Ignore)=0
DEINT_NONE
@ DEINT_NONE
Definition: mythframe.h:69
FrameScanType
FrameScanType
Definition: videoouttypes.h:94
MythVideoOutput::~MythVideoOutput
~MythVideoOutput() override=default
MythVideoOutput::m_forcedDeinterlacer
MythDeintType m_forcedDeinterlacer
Definition: mythvideoout.h:109
MythVideoOutput::SetFramesPlayed
virtual void SetFramesPlayed(long long FramesPlayed)
Definition: mythvideoout.cpp:244
mythframe.h
MythPlayer
Definition: mythplayer.h:86
Visible
Definition: channelsettings.cpp:391
mythdeinterlacer.h
MythVideoOutput::SetPrebuffering
void SetPrebuffering(bool Normal)
Sets whether to use a normal number of buffers or fewer buffers.
Definition: mythvideoout.cpp:265
videobuffers.h
MythVideoOutput::m_copyFrame
MythAVCopy m_copyFrame
Definition: mythvideoout.h:104
MythCodecID
MythCodecID
Definition: mythcodecid.h:10
MythVideoOutput::EndFrame
virtual void EndFrame()=0
mythvideocolourspace.h
mythdisplay.h
MythVideoOutput::Init
virtual bool Init(QSize VideoDim, QSize VideoDispDim, float VideoAspect, QRect WindowRect, MythCodecID CodecID)
Definition: mythvideoout.cpp:109
RenderOptions
Definition: mythvideoprofile.h:45
MythVideoOutput::m_clearAlpha
uint8_t m_clearAlpha
Definition: mythvideoout.h:97
MythVideoOutput::ValidVideoFrames
virtual int ValidVideoFrames() const
Returns number of frames that are fully decoded.
Definition: mythvideoout.cpp:277
videoouttypes.h
kScan_Progressive
@ kScan_Progressive
Definition: videoouttypes.h:100
MythVideoOutput::CheckFrameStates
virtual void CheckFrameStates()
Definition: mythvideoout.h:76
MythVideoOutput::ClearAfterSeek
virtual void ClearAfterSeek()
Tells video output to toss decoded buffers due to a seek.
Definition: mythvideoout.cpp:271
MythVideoOutput::DeLimboFrame
virtual void DeLimboFrame(MythVideoFrame *Frame)
Releases a frame for reuse if it is in limbo.
Definition: mythvideoout.cpp:402
VideoFrameTypes
std::vector< VideoFrameType > VideoFrameTypes
Definition: mythframe.h:83
MythVideoOutput::GetFrameStatus
QString GetFrameStatus() const
Returns string with status of each frame for debugging.
Definition: mythvideoout.cpp:308
MythVideoOutput::m_videoProfile
MythVideoProfilePtr m_videoProfile
Definition: mythvideoout.h:100
MythVideoOutput::GetNextFreeFrame
virtual MythVideoFrame * GetNextFreeFrame()
Blocks until it is possible to return a frame for decoding onto.
Definition: mythvideoout.cpp:389
MythVideoOutput::GetImageRect
QRect GetImageRect(QRect Rect, QRect *DisplayRect=nullptr)
translates caption/dvd button rectangle into 'screen' space
Definition: mythvideoout.cpp:321
MythDeinterlacer
Handles software based deinterlacing of video frames.
Definition: mythdeinterlacer.h:15
mythcodecid.h
MythVideoOutput::GetFramesPlayed
virtual long long GetFramesPlayed()
Definition: mythvideoout.cpp:249
mythvideoprofile.h
MythVideoOutput::DiscardFrames
virtual void DiscardFrames(bool KeyFrame, bool Flushed)
Releases all frames not being actively displayed from any queue onto the queue of frames ready for de...
Definition: mythvideoout.cpp:430
MythVideoOutput::GetLastDecodedFrame
virtual MythVideoFrame * GetLastDecodedFrame()
Definition: mythvideoout.cpp:302
MythVideoOutput::m_videoCodecID
MythCodecID m_videoCodecID
Definition: mythvideoout.h:98
MythVideoOutput::m_deinterlacer
MythDeinterlacer m_deinterlacer
Definition: mythvideoout.h:105
MythVideoBounds
Definition: mythvideobounds.h:23
codec_sw_copy
#define codec_sw_copy(id)
Definition: mythcodecid.h:349
MythVideoOutput::EnoughFreeFrames
bool EnoughFreeFrames()
Returns true iff enough frames are available to decode onto.
Definition: mythvideoout.cpp:289
MythVideoOutput::ReleaseFrame
virtual void ReleaseFrame(MythVideoFrame *Frame)
Releases a frame from the ready for decoding queue onto the queue of frames ready for display.
Definition: mythvideoout.cpp:396
MythVideoOutput::StartDisplayingFrame
virtual void StartDisplayingFrame()
Tell GetLastShownFrame() to return the next frame from the head of the queue of frames to display.
Definition: mythvideoout.cpp:409
MythVideoOutput::IsErrored
bool IsErrored() const
Definition: mythvideoout.cpp:254
MythDeintType
MythDeintType
Definition: mythframe.h:67
MythVideoOutput::RenderFrame
virtual void RenderFrame(MythVideoFrame *Frame, FrameScanType)=0
MythVideoOutput::m_renderFormats
const VideoFrameTypes * m_renderFormats
Definition: mythvideoout.h:106
MythVideoOutput::DiscardFrame
virtual void DiscardFrame(MythVideoFrame *Frame)
Releases frame from any queue onto the queue of frames ready for decoding onto.
Definition: mythvideoout.cpp:423
MythVideoFrame::kDefaultRenderFormats
static const VideoFrameTypes kDefaultRenderFormats
Definition: mythframe.h:91
MythVideoOutput::GetSupportedPictureAttributes
PictureAttributeSupported GetSupportedPictureAttributes()
Definition: mythvideoout.cpp:239
MythRender
Definition: mythrender_base.h:23
MythPainter
Definition: mythpainter.h:32
LetterBoxColour
LetterBoxColour
Definition: videoouttypes.h:86
MythVideoOutput::m_clearColor
uint8_t m_clearColor
Definition: mythvideoout.h:96
mythavutil.h
MythVideoOutput::MythVideoOutput
MythVideoOutput()
Definition: mythvideoout.cpp:98
MythVideoOutput::GetSafeRect
QRect GetSafeRect()
Returns a QRect describing an area of the screen on which it is 'safe' to render the On Screen Displa...
Definition: mythvideoout.cpp:375
MythAVCopy
Definition: mythavutil.h:47
MythVideoOutput::HasSoftwareFrames
bool HasSoftwareFrames() const
Definition: mythvideoout.h:86
MythVideoProfilePtr
std::shared_ptr< MythVideoProfile > MythVideoProfilePtr
Definition: mythvideogpu.h:18
MythVideoOutput::GetRenderOptions
static void GetRenderOptions(RenderOptions &Options, MythRender *Render)
Definition: mythvideoout.cpp:23
MythVideoOutput::SetDeinterlacing
virtual void SetDeinterlacing(bool Enable, bool DoubleRate, MythDeintType Force=DEINT_NONE)
Definition: mythvideoout.cpp:140
MythVideoFrame
Definition: mythframe.h:88
MythVideoOutput::EnoughDecodedFrames
bool EnoughDecodedFrames()
Returns true iff there are plenty of decoded frames ready for display.
Definition: mythvideoout.cpp:296
MythVideoOutput::InitPictureAttributes
virtual void InitPictureAttributes()
Definition: mythvideoout.h:85
MythVideoOutput::GetLastShownFrame
virtual MythVideoFrame * GetLastShownFrame()
Returns frame from the head of the ready to be displayed queue, if StartDisplayingFrame has been call...
Definition: mythvideoout.cpp:315
MythVideoOutput::RenderEnd
virtual void RenderEnd()=0
MythVideoOutput::m_maxReferenceFrames
int m_maxReferenceFrames
Definition: mythvideoout.h:99
mythvideobounds.h
MythVideoOutput::GetVisibleOSDBounds
QRect GetVisibleOSDBounds(float &VisibleAspect, float &FontScaling, float ThemeAspect) const
Returns visible portions of total OSD bounds.
Definition: mythvideoout.cpp:221
MythVideoColourSpace
MythVideoColourSpace contains a QMatrix4x4 that can convert YCbCr data to RGB.
Definition: mythvideocolourspace.h:18
OSD
Definition: osd.h:94
MythVideoOutput::UpdatePauseFrame
virtual void UpdatePauseFrame(std::chrono::milliseconds &, FrameScanType=kScan_Progressive)
Definition: mythvideoout.h:87
MythVideoOutput::SetVideoFrameRate
virtual void SetVideoFrameRate(float VideoFrameRate)
Definition: mythvideoout.cpp:134
MythVideoOutput::m_deinterlacing2X
bool m_deinterlacing2X
Definition: mythvideoout.h:108
MythVideoOutput::m_videoBuffers
VideoBuffers m_videoBuffers
Definition: mythvideoout.h:101
kScan_Ignore
@ kScan_Ignore
Definition: videoouttypes.h:96
MythVideoOutput::m_videoColourSpace
MythVideoColourSpace m_videoColourSpace
Definition: mythvideoout.h:94
MythVideoOutput::m_deinterlacing
bool m_deinterlacing
Definition: mythvideoout.h:107
MythVideoOutput::DoneDisplayingFrame
virtual void DoneDisplayingFrame(MythVideoFrame *Frame)
Releases frame returned from GetLastShownFrame() onto the queue of frames ready for decoding onto.
Definition: mythvideoout.cpp:416