/
videoout_null.cpp
251 lines (204 loc) · 6.95 KB
/
videoout_null.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
#include <map>
#include <iostream>
using namespace std;
#include "mythverbose.h"
#include "videoout_null.h"
#include "videodisplayprofile.h"
const int kNumBuffers = 31;
const int kNeedFreeFrames = 1;
const int kPrebufferFramesNormal = 12;
const int kPrebufferFramesSmall = 4;
const int kKeepPrebuffer = 2;
void VideoOutputNull::GetRenderOptions(render_opts &opts,
QStringList &cpudeints)
{
opts.renderers->append("null");
opts.deints->insert("null", cpudeints);
(*opts.osds)["null"].append("softblend");
(*opts.safe_renderers)["dummy"].append("null");
(*opts.safe_renderers)["nuppel"].append("null");
if (opts.decoders->contains("ffmpeg"))
(*opts.safe_renderers)["ffmpeg"].append("null");
if (opts.decoders->contains("crystalhd"))
(*opts.safe_renderers)["crystalhd"].append("null");
opts.priorities->insert("null", 10);
}
VideoOutputNull::VideoOutputNull() :
VideoOutput(), global_lock(QMutex::Recursive)
{
VERBOSE(VB_PLAYBACK, "VideoOutputNull()");
memset(&av_pause_frame, 0, sizeof(av_pause_frame));
}
VideoOutputNull::~VideoOutputNull()
{
VERBOSE(VB_PLAYBACK, "~VideoOutputNull()");
QMutexLocker locker(&global_lock);
vbuffers.LockFrame(&av_pause_frame, "DeletePauseFrame");
if (av_pause_frame.buf)
{
delete [] av_pause_frame.buf;
memset(&av_pause_frame, 0, sizeof(av_pause_frame));
}
vbuffers.UnlockFrame(&av_pause_frame, "DeletePauseFrame");
vbuffers.DeleteBuffers();
}
// this is documented in videooutbase.cpp
void VideoOutputNull::Zoom(ZoomDirection direction)
{
QMutexLocker locker(&global_lock);
VideoOutput::Zoom(direction);
MoveResize();
}
void VideoOutputNull::CreatePauseFrame(void)
{
vbuffers.LockFrame(&av_pause_frame, "CreatePauseFrame");
if (av_pause_frame.buf)
{
delete [] av_pause_frame.buf;
av_pause_frame.buf = NULL;
}
init(&av_pause_frame, FMT_YV12,
new unsigned char[vbuffers.GetScratchFrame()->size + 128],
vbuffers.GetScratchFrame()->width,
vbuffers.GetScratchFrame()->height,
vbuffers.GetScratchFrame()->size);
av_pause_frame.frameNumber = vbuffers.GetScratchFrame()->frameNumber;
clear(&av_pause_frame);
vbuffers.UnlockFrame(&av_pause_frame, "CreatePauseFrame");
}
bool VideoOutputNull::InputChanged(const QSize &input_size,
float aspect,
MythCodecID av_codec_id,
void *codec_private,
bool &aspect_only)
{
VERBOSE(VB_PLAYBACK,
QString("InputChanged(WxH = %1x%2, aspect = %3)")
.arg(input_size.width())
.arg(input_size.height()).arg(aspect));
if (!codec_is_std(av_codec_id))
{
VERBOSE(VB_IMPORTANT, QString("VideoOutputNull::InputChanged(): "
"new video codec is not supported."));
errorState = kError_Unknown;
return false;
}
QMutexLocker locker(&global_lock);
if (input_size == window.GetActualVideoDim())
{
vbuffers.Clear();
MoveResize();
return true;
}
VideoOutput::InputChanged(input_size, aspect, av_codec_id, codec_private,
aspect_only);
vbuffers.DeleteBuffers();
MoveResize();
const QSize video_dim = window.GetVideoDim();
bool ok = vbuffers.CreateBuffers(FMT_YV12, video_dim.width(),
video_dim.height());
if (!ok)
{
VERBOSE(VB_IMPORTANT, "VideoOutputNull::InputChanged(): "
"Failed to recreate buffers");
errorState = kError_Unknown;
}
else
{
CreatePauseFrame();
}
if (db_vdisp_profile)
db_vdisp_profile->SetVideoRenderer("null");
return ok;
}
bool VideoOutputNull::Init(int width, int height, float aspect,
WId winid, int winx, int winy, int winw,
int winh, MythCodecID codec_id, WId embedid)
{
if ((width <= 0) || (height <= 0))
return false;
QMutexLocker locker(&global_lock);
VideoOutput::Init(width, height, aspect, winid,
winx, winy, winw, winh, codec_id, embedid);
vbuffers.Init(kNumBuffers, true, kNeedFreeFrames,
kPrebufferFramesNormal, kPrebufferFramesSmall,
kKeepPrebuffer);
const QSize video_dim = window.GetVideoDim();
if (!vbuffers.CreateBuffers(FMT_YV12, video_dim.width(), video_dim.height()))
return false;
CreatePauseFrame();
if (db_vdisp_profile)
db_vdisp_profile->SetVideoRenderer("null");
MoveResize();
return true;
}
void VideoOutputNull::EmbedInWidget(int x, int y, int w, int h)
{
QMutexLocker locker(&global_lock);
if (!window.IsEmbedding())
VideoOutput::EmbedInWidget(x, y, w, h);
}
void VideoOutputNull::StopEmbedding(void)
{
QMutexLocker locker(&global_lock);
if (window.IsEmbedding())
VideoOutput::StopEmbedding();
}
void VideoOutputNull::PrepareFrame(VideoFrame *buffer, FrameScanType t,
OSD *osd)
{
(void)osd;
(void)t;
if (!buffer)
buffer = vbuffers.GetScratchFrame();
vbuffers.LockFrame(buffer, "PrepareFrame");
framesPlayed = buffer->frameNumber + 1;
vbuffers.UnlockFrame(buffer, "PrepareFrame");
}
void VideoOutputNull::Show(FrameScanType )
{
}
void VideoOutputNull::DrawUnusedRects(bool)
{
}
void VideoOutputNull::UpdatePauseFrame(void)
{
QMutexLocker locker(&global_lock);
// Try used frame first, then fall back to scratch frame.
vbuffers.LockFrame(&av_pause_frame, "UpdatePauseFrame -- pause");
vbuffers.begin_lock(kVideoBuffer_used);
VideoFrame *used_frame = NULL;
if (vbuffers.size(kVideoBuffer_used) > 0)
{
used_frame = vbuffers.head(kVideoBuffer_used);
if (!vbuffers.TryLockFrame(used_frame, "UpdatePauseFrame -- used"))
used_frame = NULL;
}
if (used_frame)
{
CopyFrame(&av_pause_frame, used_frame);
vbuffers.UnlockFrame(used_frame, "UpdatePauseFrame -- used");
}
vbuffers.end_lock();
if (!used_frame &&
vbuffers.TryLockFrame(vbuffers.GetScratchFrame(),
"UpdatePauseFrame -- scratch"))
{
vbuffers.GetScratchFrame()->frameNumber = framesPlayed - 1;
CopyFrame(&av_pause_frame, vbuffers.GetScratchFrame());
vbuffers.UnlockFrame(vbuffers.GetScratchFrame(),
"UpdatePauseFrame -- scratch");
}
vbuffers.UnlockFrame(&av_pause_frame, "UpdatePauseFrame - used");
}
void VideoOutputNull::ProcessFrame(VideoFrame *frame, OSD *osd,
FilterChain *filterList,
const PIPMap &pipPlayers,
FrameScanType scan)
{
(void)frame;
(void)osd;
(void)filterList;
(void)pipPlayers;
(void)scan;
}