MythTV  0.28pre
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  VideoOutput(), 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 = NULL;
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 = NULL;
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 
241  FilterChain *filterList,
242  const PIPMap &pipPlayers,
244 {
245  (void)frame;
246  (void)osd;
247  (void)filterList;
248  (void)pipPlayers;
249  (void)scan;
250 }
GLuint buffer
void ProcessFrame(VideoFrame *frame, OSD *osd, FilterChain *filterList, const PIPMap &pipPlayers, FrameScanType scan)
void SetVideoRenderer(const QString &video_renderer)
def scan(profile, smoonURL, gate)
Definition: scan.py:43
QMap< MythPlayer *, PIPLocation > PIPMap
Definition: videooutbase.h:37
priority_map_t * priorities
void CreatePauseFrame(void)
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.
MythCodecID
Definition: mythcodecid.h:10
safe_list_t * renderers
const int kPrebufferFramesNormal
safe_map_t * deints
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.
QSize GetActualVideoDim(void) const
FrameScanType
Definition: videoouttypes.h:80
virtual void StopEmbedding(void)
Tells video output to stop embedding video in an existing window.
void Zoom(ZoomDirection direction)
Sets up zooming into to different parts of the video, the zoom is actually applied in MoveResize()...
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.
void PrepareFrame(VideoFrame *buffer, FrameScanType, OSD *osd)
VideoDisplayProfile * db_vdisp_profile
Definition: videooutbase.h:315
bool InputChanged(const QSize &video_dim_buf, const QSize &video_dim_disp, float aspect, MythCodecID av_codec_id, void *codec_private, bool &aspect_only)
Tells video output to discard decoded frames and wait for new ones.
virtual void EmbedInWidget(const QRect &rect)
Tells video output to embed video in an existing window.
long long framesPlayed
Definition: videooutbase.h:346
bool CreateBuffers(VideoFrameType type, int width, int height, vector< unsigned char * > bufs, vector< YUVInfo > yuvinfo)
safe_list_t * decoders
void StopEmbedding(void)
Tells video output to stop embedding video in an existing window.
This class serves as the base class for all video output methods.
Definition: videooutbase.h:46
safe_map_t * osds
static void CopyFrame(VideoFrame *to, const VideoFrame *from)
Copies frame data from one VideoFrame to another.
void UpdatePauseFrame(int64_t &disp_timecode)
Updates frame displayed when video is paused.
VideoBuffers vbuffers
VideoBuffers instance used to track video output buffers.
Definition: videooutbase.h:342
QSize GetVideoDim(void) const
static void clear(SettingsMap &cache, SettingsMap &overrides, const QString &myKey)
Definition: mythdb.cpp:816
void Show(FrameScanType)
int height
Definition: mythframe.h:37
const int kNumBuffers
VideoErrorState errorState
Definition: videooutbase.h:345
unsigned char t
Definition: ParseText.cpp:339
const int kNeedFreeFrames
long long frameNumber
Definition: mythframe.h:43
void end_lock()
Definition: videobuffers.h:100
VideoFrame av_pause_frame
Definition: videoout_null.h:47
const int kKeepPrebuffer
static void GetRenderOptions(render_opts &opts, QStringList &cpudeints)
VideoFrame * GetScratchFrame(void)
int64_t disp_timecode
Definition: mythframe.h:45
uint Size(BufferType type) const
void EmbedInWidget(const QRect &rect)
Tells video output to embed video in an existing window.
typedef void(APIENTRY *MYTH_GLTEXIMAGE1DPROC)(GLenum target
static const char * toString(OMX_AUDIO_DDPBITSTREAMID id)
safe_map_t * safe_renderers
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.
void Clear(uint i)
Definition: osd.h:131
const int kPrebufferFramesSmall
VideoOutWindow window
Definition: videooutbase.h:305
static void init(VideoFrame *vf, VideoFrameType _codec, unsigned char *_buf, int _width, int _height, int _size, const int *p=0, const int *o=0, float _aspect=-1.0f, double _rate=-1.0f, int _aligned=64) MUNUSED
Definition: mythframe.h:104
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)
void DrawUnusedRects(bool sync=true)
Draws non-video portions of the screen.
unsigned char * buf
Definition: mythframe.h:34
ZoomDirection
Definition: videoouttypes.h:28
void DeleteBuffers(void)
bool IsEmbedding(void) const
Returns if videooutput is embedding.