MythTV  master
videoout_null.cpp
Go to the documentation of this file.
1 #include <map>
2 #include <iostream>
3 using namespace std;
4 
5 #include "mythlogging.h"
6 #include "videoout_null.h"
7 #include "videodisplayprofile.h"
8 
9 const int kNumBuffers = 31;
10 const int kNeedFreeFrames = 1;
11 const int kPrebufferFramesNormal = 12;
12 const int kPrebufferFramesSmall = 4;
13 const int kKeepPrebuffer = 2;
14 
16  QStringList &cpudeints)
17 {
18  opts.renderers->append("null");
19  opts.deints->insert("null", cpudeints);
20  (*opts.osds)["null"].append("softblend");
21  (*opts.safe_renderers)["dummy"].append("null");
22  (*opts.safe_renderers)["nuppel"].append("null");
23  if (opts.decoders->contains("ffmpeg"))
24  (*opts.safe_renderers)["ffmpeg"].append("null");
25  if (opts.decoders->contains("crystalhd"))
26  (*opts.safe_renderers)["crystalhd"].append("null");
27  if (opts.decoders->contains("vda"))
28  (*opts.safe_renderers)["vda"].append("null");
29 #ifdef USING_OPENMAX
30  if (opts.decoders->contains("openmax"))
31  (*opts.safe_renderers)["openmax"].append("null");
32 #endif
33 
34  opts.priorities->insert("null", 10);
35 }
36 
38  global_lock(QMutex::Recursive)
39 {
40  LOG(VB_PLAYBACK, LOG_INFO, "VideoOutputNull()");
41  memset(&av_pause_frame, 0, sizeof(av_pause_frame));
42 }
43 
45 {
46  LOG(VB_PLAYBACK, LOG_INFO, "~VideoOutputNull()");
47  QMutexLocker locker(&global_lock);
48 
49  if (av_pause_frame.buf)
50  {
51  delete [] av_pause_frame.buf;
52  memset(&av_pause_frame, 0, sizeof(av_pause_frame));
53  }
54 
56 }
57 
58 // this is documented in videooutbase.cpp
60 {
61  QMutexLocker locker(&global_lock);
62  VideoOutput::Zoom(direction);
63  MoveResize();
64 }
65 
67 {
68  if (av_pause_frame.buf)
69  {
70  delete [] av_pause_frame.buf;
71  av_pause_frame.buf = nullptr;
72  }
73 
75  new unsigned char[vbuffers.GetScratchFrame()->size + 128],
79 
81 
83 }
84 
85 bool VideoOutputNull::InputChanged(const QSize &video_dim_buf,
86  const QSize &video_dim_disp,
87  float aspect,
88  MythCodecID av_codec_id,
89  void *codec_private,
90  bool &aspect_only)
91 {
92  LOG(VB_PLAYBACK, LOG_INFO,
93  QString("InputChanged(WxH = %1x%2, aspect = %3)")
94  .arg(video_dim_disp.width())
95  .arg(video_dim_disp.height()).arg(aspect));
96 
97  if (!codec_is_std(av_codec_id))
98  {
99  LOG(VB_GENERAL, LOG_ERR, QString("VideoOutputNull::InputChanged(): "
100  "new video codec is not supported."));
102  return false;
103  }
104 
105  QMutexLocker locker(&global_lock);
106 
107  if (video_dim_disp == window.GetActualVideoDim())
108  {
109  vbuffers.Clear();
110  MoveResize();
111  return true;
112  }
113 
114  VideoOutput::InputChanged(video_dim_buf, video_dim_disp,
115  aspect, av_codec_id, codec_private,
116  aspect_only);
118 
119  MoveResize();
120 
121  const QSize video_dim = window.GetVideoDim();
122 
123  bool ok = vbuffers.CreateBuffers(FMT_YV12, video_dim.width(),
124  video_dim.height());
125  if (!ok)
126  {
127  LOG(VB_GENERAL, LOG_ERR, "VideoOutputNull::InputChanged(): "
128  "Failed to recreate buffers");
130  }
131  else
132  {
134  }
135 
136  if (db_vdisp_profile)
138 
139  return ok;
140 }
141 
142 bool VideoOutputNull::Init(const QSize &video_dim_buf,
143  const QSize &video_dim_disp,
144  float aspect, WId winid,
145  const QRect &win_rect, MythCodecID codec_id)
146 {
147  if ((video_dim_disp.width() <= 0) || (video_dim_disp.height() <= 0))
148  return false;
149 
150  if (!codec_is_std(codec_id))
151  {
152  LOG(VB_GENERAL, LOG_ERR,
153  QString("Cannot create VideoOutputNull for codec %1")
154  .arg(toString(codec_id)));
155  return false;
156  }
157 
158  QMutexLocker locker(&global_lock);
159 
160  VideoOutput::Init(video_dim_buf, video_dim_disp,
161  aspect, winid, win_rect, codec_id);
162 
166 
167  // XXX should this be GetActualVideoDim() ?
168  const QSize video_dim = window.GetVideoDim();
169 
170  if (!vbuffers.CreateBuffers(FMT_YV12, video_dim.width(), video_dim.height()))
171  return false;
172 
174 
175  if (db_vdisp_profile)
177 
178  MoveResize();
179 
180  return true;
181 }
182 
183 void VideoOutputNull::EmbedInWidget(const QRect &rect)
184 {
185  QMutexLocker locker(&global_lock);
186  if (!window.IsEmbedding())
188 }
189 
191 {
192  QMutexLocker locker(&global_lock);
193  if (window.IsEmbedding())
195 }
196 
198  OSD *osd)
199 {
200  (void)osd;
201  (void)t;
202 
203  if (!buffer)
204  buffer = vbuffers.GetScratchFrame();
205 
206  framesPlayed = buffer->frameNumber + 1;
207 }
208 
210 {
211 }
212 
214 {
215 }
216 
217 void VideoOutputNull::UpdatePauseFrame(int64_t &disp_timecode)
218 {
219  QMutexLocker locker(&global_lock);
220 
221  // Try used frame first, then fall back to scratch frame.
223  VideoFrame *used_frame = nullptr;
225  used_frame = vbuffers.Head(kVideoBuffer_used);
226 
227  if (used_frame)
228  CopyFrame(&av_pause_frame, used_frame);
229  vbuffers.end_lock();
230 
231  if (!used_frame)
232  {
235  }
236 
237  disp_timecode = av_pause_frame.disp_timecode;
238 }
239 
240 void VideoOutputNull::ProcessFrame(VideoFrame */*frame*/, OSD */*osd*/,
241  FilterChain */*filterList*/,
242  const PIPMap &/*pipPlayers*/,
243  FrameScanType /*scan*/)
244 {
245 }
void SetVideoRenderer(const QString &video_renderer)
QMap< MythPlayer *, PIPLocation > PIPMap
Definition: videooutbase.h:37
void CreatePauseFrame(void)
QString toString(MarkTypes type)
MythCodecID
Definition: mythcodecid.h:10
const int kPrebufferFramesNormal
virtual bool Init(const QSize &video_dim_buf, const QSize &video_dim_disp, float aspect, WId winid, const QRect &win_rect, MythCodecID codec_id)
Performs most of the initialization for VideoOutput.
void Zoom(ZoomDirection direction) override
Sets up zooming into to different parts of the video, the zoom is actually applied in MoveResize().
FrameScanType
Definition: videoouttypes.h:80
virtual void StopEmbedding(void)
Tells video output to stop embedding video in an existing window.
VideoDisplayProfile * db_vdisp_profile
Definition: videooutbase.h:330
uint Size(BufferType type) const
void EmbedInWidget(const QRect &rect) override
Tells video output to embed video in an existing window.
void DrawUnusedRects(bool sync=true) override
Draws non-video portions of the screen.
virtual void EmbedInWidget(const QRect &rect)
Tells video output to embed video in an existing window.
void UpdatePauseFrame(int64_t &disp_timecode) override
Updates frame displayed when video is paused.
long long framesPlayed
Definition: videooutbase.h:361
bool CreateBuffers(VideoFrameType type, int width, int height, vector< unsigned char * > bufs, vector< YUVInfo > yuvinfo)
void StopEmbedding(void) override
Tells video output to stop embedding video in an existing window.
static void CopyFrame(VideoFrame *to, const VideoFrame *from)
Copies frame data from one VideoFrame to another.
VideoBuffers vbuffers
VideoBuffers instance used to track video output buffers.
Definition: videooutbase.h:357
static void clear(SettingsMap &cache, SettingsMap &overrides, const QString &myKey)
Definition: mythdb.cpp:830
bool Init(const QSize &video_dim_buf, const QSize &video_dim_disp, float aspect, WId winid, const QRect &win_rect, MythCodecID codec_id) override
Performs most of the initialization for VideoOutput.
int height
Definition: mythframe.h:42
const int kNumBuffers
VideoErrorState errorState
Definition: videooutbase.h:360
unsigned char t
Definition: ParseText.cpp:329
void ProcessFrame(VideoFrame *frame, OSD *osd, FilterChain *filterList, const PIPMap &pipPlayers, FrameScanType scan) override
const int kNeedFreeFrames
bool IsEmbedding(void) const
Returns if videooutput is embedding.
long long frameNumber
Definition: mythframe.h:48
void end_lock()
Definition: videobuffers.h:100
VideoFrame av_pause_frame
Definition: videoout_null.h:48
const int kKeepPrebuffer
static void GetRenderOptions(render_opts &opts, QStringList &cpudeints)
VideoFrame * GetScratchFrame(void)
virtual bool InputChanged(const QSize &video_dim_buf, const QSize &video_dim_disp, float aspect, MythCodecID myth_codec_id, void *codec_private, bool &aspect_changed)
Tells video output to discard decoded frames and wait for new ones.
QSize GetActualVideoDim(void) const
#define LOG(_MASK_, _LEVEL_, _STRING_)
Definition: mythlogging.h:41
bool InputChanged(const QSize &video_dim_buf, const QSize &video_dim_disp, float aspect, MythCodecID av_codec_id, void *codec_private, bool &aspect_only) override
Tells video output to discard decoded frames and wait for new ones.
int64_t disp_timecode
Definition: mythframe.h:50
VideoFrame * Head(BufferType)
virtual void Zoom(ZoomDirection direction)
Sets up zooming into to different parts of the video, the zoom is actually applied in MoveResize().
virtual void MoveResize(void)
performs all the calculations for video framing and any resizing.
static void init(VideoFrame *vf, VideoFrameType _codec, unsigned char *_buf, int _width, int _height, int _size, const int *p=nullptr, const int *o=nullptr, float _aspect=-1.0F, double _rate=-1.0F, int _aligned=64)
Definition: mythframe.h:115
void Clear(uint i)
Definition: osd.h:132
void Show(FrameScanType) override
const int kPrebufferFramesSmall
QSize GetVideoDim(void) const
VideoOutWindow window
Definition: videooutbase.h:320
void Init(uint numdecode, bool extra_for_pause, uint need_free, uint needprebuffer_normal, uint needprebuffer_small, uint keepprebuffer)
Creates buffers and sets various buffer management parameters.
frame_queue_t::iterator begin_lock(BufferType)
unsigned char * buf
Definition: mythframe.h:39
ZoomDirection
Definition: videoouttypes.h:28
void PrepareFrame(VideoFrame *buffer, FrameScanType, OSD *osd) override
void DeleteBuffers(void)
#define codec_is_std(id)
Definition: mythcodecid.h:127