MythTV master
mythvideooutnull.cpp
Go to the documentation of this file.
1// MythTV
3#include "mythvideooutnull.h"
4
5// Std
6#include <map>
7#include <iostream>
8
9const int kNeedFreeFrames = 1;
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#if CONFIG_VIDEOTOOLBOX
22 if (Options.decoders->contains("vtb-dec"))
23 (*Options.safe_renderers)["vtb-dec"].append("null");
24#endif
25#if CONFIG_VDPAU
26 if (Options.decoders->contains("vdpau-dec"))
27 (*Options.safe_renderers)["vdpau-dec"].append("null");
28#endif
29#if CONFIG_NVDEC
30 if (Options.decoders->contains("nvdec-dec"))
31 (*Options.safe_renderers)["nvdec-dec"].append("null");
32#endif
33#if CONFIG_VAAPI
34 if (Options.decoders->contains("vaapi-dec"))
35 (*Options.safe_renderers)["vaapi-dec"].append("null");
36#endif
37#if CONFIG_MEDIACODEC
38 if (Options.decoders->contains("mediacodec-dec"))
39 (*Options.safe_renderers)["mediacodec-dec"].append("null");
40#endif
41#if CONFIG_V4L2
42 if (Options.decoders->contains("v4l2-dec"))
43 (*Options.safe_renderers)["v4l2-dec"].append("null");
44#endif
45#if CONFIG_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
52MythVideoOutputNull* 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 VideoAspect,
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>(VideoAspect)));
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 VideoAspect, 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
105bool MythVideoOutputNull::Init(const QSize VideoDim, const QSize VideoDispDim,
106 float VideoAspect, 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, VideoAspect, 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
131void 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}
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