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