MythTV  master
mythvideooutnull.cpp
Go to the documentation of this file.
1 // MythTV
2 #include "mythlogging.h"
3 #include "mythvideooutnull.h"
4 
5 // Std
6 #include <map>
7 #include <iostream>
8 
9 const int kNeedFreeFrames = 1;
10 const int kPrebufferFramesNormal = 12;
11 const int kPrebufferFramesSmall = 4;
12 
13 #define LOC QString("VidOutNull: ")
14 
16 {
17  Options.renderers->append("null");
18  (*Options.safe_renderers)["dummy"].append("null");
19  if (Options.decoders->contains("ffmpeg"))
20  (*Options.safe_renderers)["ffmpeg"].append("null");
21 #ifdef USING_VTB
22  if (Options.decoders->contains("vtb-dec"))
23  (*Options.safe_renderers)["vtb-dec"].append("null");
24 #endif
25 #ifdef USING_VDPAU
26  if (Options.decoders->contains("vdpau-dec"))
27  (*Options.safe_renderers)["vdpau-dec"].append("null");
28 #endif
29 #ifdef USING_NVDEC
30  if (Options.decoders->contains("nvdec-dec"))
31  (*Options.safe_renderers)["nvdec-dec"].append("null");
32 #endif
33 #ifdef USING_VAAPI
34  if (Options.decoders->contains("vaapi-dec"))
35  (*Options.safe_renderers)["vaapi-dec"].append("null");
36 #endif
37 #ifdef USING_MEDIACODEC
38  if (Options.decoders->contains("mediacodec-dec"))
39  (*Options.safe_renderers)["mediacodec-dec"].append("null");
40 #endif
41 #ifdef USING_V4L2
42  if (Options.decoders->contains("v4l2-dec"))
43  (*Options.safe_renderers)["v4l2-dec"].append("null");
44 #endif
45 #ifdef USING_MMAL
46  if (Options.decoders->contains("mmal-dec"))
47  (*Options.safe_renderers)["mmal-dec"].append("null");
48 #endif
49  Options.priorities->insert("null", 10);
50 }
51 
52 MythVideoOutputNull* MythVideoOutputNull::Create(QSize VideoDim, QSize VideoDispDim,
53  float VideoAspect, MythCodecID CodecID)
54 {
55  auto * result = new MythVideoOutputNull();
56  if (result->Init(VideoDim, VideoDispDim, VideoAspect, QRect(), CodecID))
57  return result;
58  delete result;
59  return nullptr;
60 }
61 
63  QSize VideoDispDim,
64  float Aspect,
65  MythCodecID CodecID,
66  bool& AspectOnly,
67  int ReferenceFrames,
68  bool ForceChange)
69 {
70  LOG(VB_PLAYBACK, LOG_INFO, LOC + QString("InputChanged(WxH = %1x%2, aspect = %3)")
71  .arg(VideoDispDim.width()).arg(VideoDispDim.height()).arg(static_cast<qreal>(Aspect)));
72 
73  if (!codec_is_std(CodecID))
74  {
75  LOG(VB_GENERAL, LOG_ERR, LOC +
76  QString("VideoOutputNull::InputChanged(): new video codec is not supported."));
78  return false;
79  }
80 
81  if (VideoDispDim == GetVideoDim())
82  {
83  MoveResize();
84  return true;
85  }
86 
87  MythVideoOutput::InputChanged(VideoDim, VideoDispDim,
88  Aspect, CodecID, AspectOnly,
89  ReferenceFrames, ForceChange);
90  MoveResize();
91 
92  const QSize video_dim = GetVideoDim();
93 
94  bool ok = m_videoBuffers.CreateBuffers(FMT_YV12, video_dim.width(), video_dim.height(), m_renderFormats);
95  if (!ok)
96  {
97  LOG(VB_GENERAL, LOG_ERR, LOC +
98  "VideoOutputNull::InputChanged(): Failed to recreate buffers");
100  }
101 
102  return ok;
103 }
104 
105 bool MythVideoOutputNull::Init(const QSize VideoDim, const QSize VideoDispDim,
106  float Aspect, const QRect DisplayVisibleRect, MythCodecID CodecID)
107 {
108  if (VideoDispDim.isEmpty())
109  return false;
110 
111  if (!codec_is_std(CodecID))
112  {
113  LOG(VB_GENERAL, LOG_ERR, LOC + QString("Cannot create VideoOutputNull for codec %1")
114  .arg(toString(CodecID)));
115  return false;
116  }
117 
118  MythVideoOutput::Init(VideoDim, VideoDispDim, Aspect, DisplayVisibleRect, CodecID);
121 
122  const QSize videodim = GetVideoDim();
123 
124  if (!m_videoBuffers.CreateBuffers(FMT_YV12, videodim.width(), videodim.height(), m_renderFormats))
125  return false;
126 
127  MoveResize();
128  return true;
129 }
130 
131 void MythVideoOutputNull::SetDeinterlacing(bool Enable, bool DoubleRate, MythDeintType Force /*=DEINT_NONE*/)
132 {
133  if (DEINT_NONE != Force)
134  {
135  MythVideoOutput::SetDeinterlacing(Enable, DoubleRate, Force);
136  return;
137  }
138 
139  m_deinterlacing = false;
140  m_deinterlacing2X = false;
143 }
144 
146 {
147  if (Frame)
148  m_framesPlayed = Frame->m_frameNumber + 1;
149  else
150  LOG(VB_GENERAL, LOG_ERR, LOC + "No frame in PrepareFrame!");
151 }
152 
153 
155 {
156  if (Frame && !Frame->m_dummy)
157  m_deinterlacer.Filter(Frame, Scan, nullptr);
158 }
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
MythVideoOutputNull::Create
static MythVideoOutputNull * Create(QSize VideoDim, QSize VideoDispDim, float VideoAspect, MythCodecID CodecID)
Definition: mythvideooutnull.cpp:52
RenderOptions::renderers
QStringList * renderers
Definition: mythvideoprofile.h:47
MythVideoOutputNull::MythVideoOutputNull
MythVideoOutputNull()=default
MythVideoOutput::m_framesPlayed
long long m_framesPlayed
Definition: mythvideoout.h:103
MythVideoOutput::m_errorState
VideoErrorState m_errorState
Definition: mythvideoout.h:102
Frame
Definition: zmdefines.h:93
DEINT_NONE
@ DEINT_NONE
Definition: mythframe.h:69
VideoBuffers::SetDeinterlacing
void SetDeinterlacing(MythDeintType Single, MythDeintType Double, MythCodecID CodecID)
Definition: videobuffers.cpp:199
MythVideoOutputNull::Init
bool Init(QSize VideoDim, QSize VideoDispDim, float Aspect, QRect DisplayVisibleRect, MythCodecID CodecID) override
Definition: mythvideooutnull.cpp:105
FrameScanType
FrameScanType
Definition: videoouttypes.h:94
MythVideoOutput::m_forcedDeinterlacer
MythDeintType m_forcedDeinterlacer
Definition: mythvideoout.h:109
kPrebufferFramesSmall
const int kPrebufferFramesSmall
Definition: mythvideooutnull.cpp:11
LOG
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:23
MythVideoOutputNull
Definition: mythvideooutnull.h:7
VideoBuffers::CreateBuffers
bool CreateBuffers(VideoFrameType Type, const VideoFrameTypes *RenderFormats, QSize Size, uint NeedFree, uint NeedprebufferNormal, uint NeedPrebufferSmall, int MaxReferenceFrames=16)
Definition: videobuffers.cpp:940
kError_Unknown
@ kError_Unknown
Definition: videoouttypes.h:185
MythVideoOutputNull::PrepareFrame
void PrepareFrame(MythVideoFrame *Frame, FrameScanType Scan) override
Definition: mythvideooutnull.cpp:154
MythCodecID
MythCodecID
Definition: mythcodecid.h:10
toString
QString toString(MarkTypes type)
Definition: programtypes.cpp:26
RenderOptions::decoders
QStringList * decoders
Definition: mythvideoprofile.h:51
MythVideoOutput::Init
virtual bool Init(QSize VideoDim, QSize VideoDispDim, float VideoAspect, QRect WindowRect, MythCodecID CodecID)
Definition: mythvideoout.cpp:109
mythvideooutnull.h
mythlogging.h
RenderOptions
Definition: mythvideoprofile.h:45
MythVideoOutputNull::InputChanged
bool InputChanged(QSize VideoDim, QSize VideoDispDim, float Aspect, MythCodecID CodecID, bool &AspectOnly, int ReferenceFrames, bool ForceChange) override
Tells video output to discard decoded frames and wait for new ones.
Definition: mythvideooutnull.cpp:62
FMT_YV12
@ FMT_YV12
Definition: mythframe.h:24
MythDeinterlacer::Filter
void Filter(MythVideoFrame *Frame, FrameScanType Scan, MythVideoProfile *Profile, bool Force=false)
Deinterlace Frame if needed.
Definition: mythdeinterlacer.cpp:70
RenderOptions::safe_renderers
QMap< QString, QStringList > * safe_renderers
Definition: mythvideoprofile.h:48
MythVideoOutput::m_videoCodecID
MythCodecID m_videoCodecID
Definition: mythvideoout.h:98
codec_is_std
#define codec_is_std(id)
Definition: mythcodecid.h:293
kPrebufferFramesNormal
const int kPrebufferFramesNormal
Definition: mythvideooutnull.cpp:10
MythVideoOutput::m_deinterlacer
MythDeinterlacer m_deinterlacer
Definition: mythvideoout.h:105
MythVideoOutputNull::RenderFrame
void RenderFrame(MythVideoFrame *Frame, FrameScanType Scan) override
Definition: mythvideooutnull.cpp:145
MythVideoOutputNull::GetRenderOptions
static void GetRenderOptions(RenderOptions &Options)
Definition: mythvideooutnull.cpp:15
MythVideoBounds::MoveResize
void MoveResize(void)
performs all the calculations for video framing and any resizing.
Definition: mythvideobounds.cpp:136
MythDeintType
MythDeintType
Definition: mythframe.h:67
MythVideoOutput::m_renderFormats
const VideoFrameTypes * m_renderFormats
Definition: mythvideoout.h:106
LOC
#define LOC
Definition: mythvideooutnull.cpp:13
MythVideoOutput::SetDeinterlacing
virtual void SetDeinterlacing(bool Enable, bool DoubleRate, MythDeintType Force=DEINT_NONE)
Definition: mythvideoout.cpp:140
MythVideoFrame
Definition: mythframe.h:88
kNeedFreeFrames
const int kNeedFreeFrames
Definition: mythvideooutnull.cpp:9
VideoBuffers::Init
void Init(uint NumDecode, uint NeedFree, uint NeedprebufferNormal, uint NeedPrebufferSmall)
Creates buffers and sets various buffer management parameters.
Definition: videobuffers.cpp:175
MythVideoBounds::GetVideoDim
QSize GetVideoDim(void) const
Definition: mythvideobounds.h:70
VideoBuffers::GetNumBuffers
static uint GetNumBuffers(int PixelFormat, int MaxReferenceFrames=16, bool Decoder=false)
Definition: videobuffers.cpp:135
MythVideoOutput::m_deinterlacing2X
bool m_deinterlacing2X
Definition: mythvideoout.h:108
MythVideoOutputNull::SetDeinterlacing
void SetDeinterlacing(bool Enable, bool DoubleRate, MythDeintType Force=DEINT_NONE) override
Definition: mythvideooutnull.cpp:131
MythVideoOutput::m_videoBuffers
VideoBuffers m_videoBuffers
Definition: mythvideoout.h:101
RenderOptions::priorities
QMap< QString, uint > * priorities
Definition: mythvideoprofile.h:50
MythVideoOutput::m_deinterlacing
bool m_deinterlacing
Definition: mythvideoout.h:107