MythTV  master
mythvideogpu.cpp
Go to the documentation of this file.
1 // MythTV
3 #include "mythvideobounds.h"
4 #include "mythvideoprofile.h"
5 #include "mythvideogpu.h"
6 
7 #define LOC QString("VideoGPU: ")
8 
10  MythVideoBounds* Bounds, const MythVideoProfilePtr &VideoProfile,
11  QString Profile)
12  : m_render(Render),
13  m_profile(std::move(Profile)),
14  m_videoDispDim(Bounds->GetVideoDispDim()),
15  m_videoDim(Bounds->GetVideoDim()),
16  m_masterViewportSize(Bounds->GetDisplayVisibleRect().size()),
17  m_displayVideoRect(Bounds->GetDisplayVideoRect()),
18  m_videoRect(Bounds->GetVideoRect()),
19  m_videoColourSpace(ColourSpace),
20  m_inputTextureSize(Bounds->GetVideoDim())
21 {
22  if (m_render)
23  m_render->IncrRef();
24 
26  {
28  // Not a call to UpdateColourSpace. Only a callback registration.
31  }
32 
33  m_stereoMode = gCoreContext->GetBoolSetting("DiscardStereo3D", true) ?
35  LOG(VB_PLAYBACK, LOG_INFO, LOC + QString("Discard stereoscopic fields: %1")
36  .arg(m_stereoMode == kStereoscopicModeIgnore3D ? "No" : "Yes"));
37 
42 
43  if (VideoProfile)
44  {
45  UpscalerChanged(VideoProfile->GetUpscaler());
46  connect(VideoProfile.get(), &MythVideoProfile::UpscalerChanged, this, &MythVideoGPU::UpscalerChanged);
47  }
48 }
49 
51 {
52  if (m_render)
53  m_render->DecrRef();
56 }
57 
60 void MythVideoGPU::UpdateColourSpace(bool PrimariesChanged)
61 {
62  ColourSpaceUpdate(PrimariesChanged);
63 }
64 
65 void MythVideoGPU::UpscalerChanged(const QString& Upscaler)
66 {
67  auto oldbicubic = m_bicubicUpsize;
68  m_bicubicUpsize = Upscaler == UPSCALE_HQ1;
69  if (m_bicubicUpsize != oldbicubic)
70  LOG(VB_PLAYBACK, LOG_INFO, LOC + QString("New upscaler preference: '%1'").arg(Upscaler));
71 }
72 
74 {
75  return m_valid;
76 }
77 
78 void MythVideoGPU::SetProfile(const QString& Profile)
79 {
80  m_profile = Profile;
81 }
82 
83 QString MythVideoGPU::GetProfile() const
84 {
85  return m_profile;
86 }
87 
89 {
90  m_masterViewportSize = Size;
91 }
92 
94 {
95  return m_videoDim;
96 }
97 
99 {
102  m_inputTextureSize = QSize();
104  // textures are created with Linear filtering - which matches no resize
105  m_resizing = None;
106 }
107 
108 QString MythVideoGPU::VideoResizeToString(VideoResizing Resize)
109 {
110  QStringList reasons;
111  if ((Resize & Deinterlacer) == Deinterlacer) reasons << "Deinterlacer";
112  if ((Resize & Sampling) == Sampling) reasons << "Sampling";
113  if ((Resize & Performance) == Performance) reasons << "Performance";
114  if ((Resize & Framebuffer) == Framebuffer) reasons << "Framebuffer";
115  if ((Resize & ToneMap) == ToneMap) reasons << "Tonemapping";
116  if ((Resize & Bicubic) == Bicubic) reasons << "Bicubic";
117  return reasons.join(",");
118 }
119 
120 void MythVideoGPU::SetVideoDimensions(QSize VideoDim, QSize VideoDispDim)
121 {
122  m_videoDim = VideoDim;
123  m_videoDispDim = VideoDispDim;
124 }
125 
126 void MythVideoGPU::SetVideoRects(QRect DisplayVideoRect, QRect VideoRect)
127 {
128  m_displayVideoRect = DisplayVideoRect;
129  m_videoRect = VideoRect;
130 }
131 
132 void MythVideoGPU::SetViewportRect(QRect DisplayVisibleRect)
133 {
134  SetMasterViewport(DisplayVisibleRect.size());
135 }
MythVideoGPU::MythVideoGPU
MythVideoGPU(MythRender *Render, MythVideoColourSpace *ColourSpace, MythVideoBounds *Bounds, const MythVideoProfilePtr &VideoProfile, QString Profile)
Definition: mythvideogpu.cpp:9
MythVideoGPU::m_inputTextureSize
QSize m_inputTextureSize
Definition: mythvideogpu.h:88
MythVideoGPU::Sampling
@ Sampling
Definition: mythvideogpu.h:29
ReferenceCounter::DecrRef
virtual int DecrRef(void)
Decrements reference count and deletes on 0.
Definition: referencecounter.cpp:125
MythVideoGPU::~MythVideoGPU
~MythVideoGPU() override
Definition: mythvideogpu.cpp:50
MythVideoGPU::m_resizing
VideoResizing m_resizing
Definition: mythvideogpu.h:89
MythVideoGPU::IsValid
bool IsValid() const
Definition: mythvideogpu.cpp:73
DEINT_NONE
@ DEINT_NONE
Definition: mythframe.h:69
MythVideoGPU::m_videoColourSpace
MythVideoColourSpace * m_videoColourSpace
Definition: mythvideogpu.h:87
MythVideoGPU::m_bicubicUpsize
bool m_bicubicUpsize
Definition: mythvideogpu.h:97
LOG
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:39
MythVideoBounds::VideoRectsChanged
void VideoRectsChanged(const QRect &DisplayVideoRect, const QRect &VideoRect)
MythVideoGPU::ToneMap
@ ToneMap
Definition: mythvideogpu.h:32
MythVideoGPU::m_videoDim
QSize m_videoDim
Definition: mythvideogpu.h:83
FMT_NONE
@ FMT_NONE
Definition: mythframe.h:22
MythVideoGPU::ColourSpaceUpdate
virtual void ColourSpaceUpdate(bool PrimariesChanged)=0
MythVideoGPU::m_profile
QString m_profile
Definition: mythvideogpu.h:79
MythVideoGPU::Bicubic
@ Bicubic
Definition: mythvideogpu.h:33
UPSCALE_HQ1
static constexpr const char * UPSCALE_HQ1
Definition: mythvideoprofile.h:28
MythVideoBounds::SourceChanged
void SourceChanged(QSize VideoDim, QSize VideoDispDim, float Aspect)
Update for new source video dimensions and aspect ratio.
Definition: mythvideobounds.cpp:525
MythVideoGPU::m_videoDispDim
QSize m_videoDispDim
Definition: mythvideogpu.h:82
MythVideoGPU::SetVideoRects
void SetVideoRects(QRect DisplayVideoRect, QRect VideoRect)
Definition: mythvideogpu.cpp:126
kStereoscopicModeIgnore3D
@ kStereoscopicModeIgnore3D
Definition: videoouttypes.h:137
MythVideoGPU::SetViewportRect
void SetViewportRect(QRect DisplayVisibleRect)
Definition: mythvideogpu.cpp:132
MythVideoGPU::SetMasterViewport
void SetMasterViewport(QSize Size)
Definition: mythvideogpu.cpp:88
MythVideoGPU::VideoResizeToString
static QString VideoResizeToString(VideoResizing Resize)
Definition: mythvideogpu.cpp:108
MythVideoGPU::m_deinterlacer
MythDeintType m_deinterlacer
Definition: mythvideogpu.h:91
MythVideoGPU::m_outputType
VideoFrameType m_outputType
Definition: mythvideogpu.h:81
mythvideoprofile.h
gCoreContext
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
Definition: mythcorecontext.cpp:55
MythVideoGPU::m_videoRect
QRect m_videoRect
Definition: mythvideogpu.h:86
MythVideoBounds::VideoSizeChanged
void VideoSizeChanged(const QSize &VideoDim, const QSize &VideoDispDim)
MythVideoGPU::Deinterlacer
@ Deinterlacer
Definition: mythvideogpu.h:28
MythVideoGPU::OutputChanged
void OutputChanged(QSize VideoDim, QSize VideoDispDim, float)
mythvideogpu.h
LOC
#define LOC
Definition: mythvideogpu.cpp:7
MythVideoGPU::m_stereoMode
StereoscopicMode m_stereoMode
Definition: mythvideogpu.h:96
MythVideoBounds
Definition: mythvideobounds.h:23
MythCoreContext::GetBoolSetting
bool GetBoolSetting(const QString &key, bool defaultval=false)
Definition: mythcorecontext.cpp:905
MythVideoGPU::m_displayVideoRect
QRect m_displayVideoRect
Definition: mythvideogpu.h:85
MythVideoGPU::m_render
MythRender * m_render
Definition: mythvideogpu.h:77
MythVideoGPU::GetProfile
virtual QString GetProfile() const
Definition: mythvideogpu.cpp:83
mythcorecontext.h
MythVideoColourSpace::Updated
void Updated(bool PrimariesChanged)
MythRender
Definition: mythrender_base.h:23
std
Definition: mythchrono.h:23
MythVideoGPU::UpscalerChanged
void UpscalerChanged(const QString &Upscaler)
Definition: mythvideogpu.cpp:65
MythVideoGPU::SetProfile
void SetProfile(const QString &Profile)
Definition: mythvideogpu.cpp:78
MythVideoGPU::m_valid
bool m_valid
Definition: mythvideogpu.h:93
MythVideoGPU::ResetFrameFormat
virtual void ResetFrameFormat()
Definition: mythvideogpu.cpp:98
MythVideoGPU::UpdateColourSpace
void UpdateColourSpace(bool PrimariesChanged)
Definition: mythvideogpu.cpp:60
MythVideoProfilePtr
std::shared_ptr< MythVideoProfile > MythVideoProfilePtr
Definition: mythvideogpu.h:18
MythVideoBounds::WindowRectChanged
void WindowRectChanged(const QRect &WindowRect)
MythVideoGPU::None
@ None
Definition: mythvideogpu.h:27
MythVideoGPU::SetVideoDimensions
void SetVideoDimensions(QSize VideoDim, QSize VideoDispDim)
Definition: mythvideogpu.cpp:120
MythVideoProfile::UpscalerChanged
void UpscalerChanged(const QString &Upscaler)
MythVideoGPU::m_masterViewportSize
QSize m_masterViewportSize
Definition: mythvideogpu.h:84
ReferenceCounter::IncrRef
virtual int IncrRef(void)
Increments reference count.
Definition: referencecounter.cpp:101
mythvideobounds.h
kStereoscopicModeSideBySideDiscard
@ kStereoscopicModeSideBySideDiscard
Definition: videoouttypes.h:138
MythVideoColourSpace
MythVideoColourSpace contains a QMatrix4x4 that can convert YCbCr data to RGB.
Definition: mythvideocolourspace.h:18
MythVideoGPU::m_inputType
VideoFrameType m_inputType
Definition: mythvideogpu.h:80
MythVideoGPU::Performance
@ Performance
Definition: mythvideogpu.h:30
MythVideoGPU::GetVideoDim
QSize GetVideoDim() const
Definition: mythvideogpu.cpp:93
MythVideoGPU::Framebuffer
@ Framebuffer
Definition: mythvideogpu.h:31