author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Thu, 02 Sep 2010 21:20:32 +0300 | |
changeset 34 | a33bf25e6f72 |
parent 33 | 3e2da88830cd |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 4 |
** All rights reserved. |
5 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 |
** |
|
7 |
** This file is part of the test suite of the Qt Toolkit. |
|
8 |
** |
|
9 |
** $QT_BEGIN_LICENSE:LGPL$ |
|
10 |
** No Commercial Usage |
|
11 |
** This file contains pre-release code and may not be distributed. |
|
12 |
** You may use this file in accordance with the terms and conditions |
|
13 |
** contained in the Technology Preview License Agreement accompanying |
|
14 |
** this package. |
|
15 |
** |
|
16 |
** GNU Lesser General Public License Usage |
|
17 |
** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 |
** General Public License version 2.1 as published by the Free Software |
|
19 |
** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 |
** packaging of this file. Please review the following information to |
|
21 |
** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 |
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 |
** |
|
24 |
** In addition, as a special exception, Nokia gives you certain additional |
|
25 |
** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 |
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 |
** |
|
28 |
** If you have questions regarding the use of this file, please contact |
|
29 |
** Nokia at qt-info@nokia.com. |
|
30 |
** |
|
31 |
** |
|
32 |
** |
|
33 |
** |
|
34 |
** |
|
35 |
** |
|
36 |
** |
|
37 |
** |
|
38 |
** $QT_END_LICENSE$ |
|
39 |
** |
|
40 |
****************************************************************************/ |
|
41 |
||
42 |
#include <QtTest/QtTest> |
|
43 |
||
44 |
#include <QtMultimedia/QVideoFrame> |
|
45 |
#include <QtGui/QImage> |
|
46 |
#include <QtCore/QPointer> |
|
47 |
||
48 |
class tst_QVideoFrame : public QObject |
|
49 |
{ |
|
50 |
Q_OBJECT |
|
51 |
public: |
|
52 |
tst_QVideoFrame(); |
|
53 |
~tst_QVideoFrame(); |
|
54 |
||
55 |
public slots: |
|
56 |
void initTestCase(); |
|
57 |
void cleanupTestCase(); |
|
58 |
void init(); |
|
59 |
void cleanup(); |
|
60 |
||
61 |
private slots: |
|
62 |
void create_data(); |
|
63 |
void create(); |
|
64 |
void createInvalid_data(); |
|
65 |
void createInvalid(); |
|
66 |
void createFromBuffer_data(); |
|
67 |
void createFromBuffer(); |
|
68 |
void createFromImage_data(); |
|
69 |
void createFromImage(); |
|
70 |
void createFromIncompatibleImage(); |
|
71 |
void createNull(); |
|
72 |
void destructor(); |
|
73 |
void copy_data(); |
|
74 |
void copy(); |
|
75 |
void assign_data(); |
|
76 |
void assign(); |
|
77 |
void map_data(); |
|
78 |
void map(); |
|
79 |
void mapImage_data(); |
|
80 |
void mapImage(); |
|
81 |
void imageDetach(); |
|
33
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
82 |
void formatConversion_data(); |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
83 |
void formatConversion(); |
0 | 84 |
}; |
85 |
||
86 |
Q_DECLARE_METATYPE(QImage::Format) |
|
87 |
Q_DECLARE_METATYPE(QVideoFrame) |
|
88 |
||
89 |
class QtTestVideoBuffer : public QObject, public QAbstractVideoBuffer |
|
90 |
{ |
|
91 |
Q_OBJECT |
|
92 |
public: |
|
93 |
QtTestVideoBuffer() |
|
94 |
: QAbstractVideoBuffer(NoHandle) {} |
|
95 |
explicit QtTestVideoBuffer(QAbstractVideoBuffer::HandleType type) |
|
96 |
: QAbstractVideoBuffer(type) {} |
|
97 |
||
98 |
MapMode mapMode() const { return NotMapped; } |
|
99 |
||
100 |
uchar *map(MapMode, int *, int *) { return 0; } |
|
101 |
void unmap() {} |
|
102 |
}; |
|
103 |
||
104 |
tst_QVideoFrame::tst_QVideoFrame() |
|
105 |
{ |
|
106 |
} |
|
107 |
||
108 |
tst_QVideoFrame::~tst_QVideoFrame() |
|
109 |
{ |
|
110 |
} |
|
111 |
||
112 |
void tst_QVideoFrame::initTestCase() |
|
113 |
{ |
|
114 |
} |
|
115 |
||
116 |
void tst_QVideoFrame::cleanupTestCase() |
|
117 |
{ |
|
118 |
} |
|
119 |
||
120 |
void tst_QVideoFrame::init() |
|
121 |
{ |
|
122 |
} |
|
123 |
||
124 |
void tst_QVideoFrame::cleanup() |
|
125 |
{ |
|
126 |
} |
|
127 |
||
128 |
void tst_QVideoFrame::create_data() |
|
129 |
{ |
|
130 |
QTest::addColumn<QSize>("size"); |
|
131 |
QTest::addColumn<QVideoFrame::PixelFormat>("pixelFormat"); |
|
132 |
QTest::addColumn<int>("bytes"); |
|
133 |
QTest::addColumn<int>("bytesPerLine"); |
|
134 |
||
135 |
QTest::newRow("64x64 ARGB32") |
|
136 |
<< QSize(64, 64) |
|
137 |
<< QVideoFrame::Format_ARGB32 |
|
138 |
<< 16384 |
|
139 |
<< 256; |
|
140 |
QTest::newRow("32x256 YUV420P") |
|
141 |
<< QSize(32, 256) |
|
142 |
<< QVideoFrame::Format_YUV420P |
|
143 |
<< 13288 |
|
144 |
<< 32; |
|
145 |
} |
|
146 |
||
147 |
void tst_QVideoFrame::create() |
|
148 |
{ |
|
149 |
QFETCH(QSize, size); |
|
150 |
QFETCH(QVideoFrame::PixelFormat, pixelFormat); |
|
151 |
QFETCH(int, bytes); |
|
152 |
QFETCH(int, bytesPerLine); |
|
153 |
||
154 |
QVideoFrame frame(bytes, size, bytesPerLine, pixelFormat); |
|
155 |
||
156 |
QVERIFY(frame.isValid()); |
|
157 |
QCOMPARE(frame.handleType(), QAbstractVideoBuffer::NoHandle); |
|
158 |
QCOMPARE(frame.pixelFormat(), pixelFormat); |
|
159 |
QCOMPARE(frame.size(), size); |
|
160 |
QCOMPARE(frame.width(), size.width()); |
|
161 |
QCOMPARE(frame.height(), size.height()); |
|
162 |
QCOMPARE(frame.fieldType(), QVideoFrame::ProgressiveFrame); |
|
163 |
QCOMPARE(frame.startTime(), qint64(-1)); |
|
164 |
QCOMPARE(frame.endTime(), qint64(-1)); |
|
165 |
} |
|
166 |
||
167 |
void tst_QVideoFrame::createInvalid_data() |
|
168 |
{ |
|
169 |
QTest::addColumn<QSize>("size"); |
|
170 |
QTest::addColumn<QVideoFrame::PixelFormat>("pixelFormat"); |
|
171 |
QTest::addColumn<int>("bytes"); |
|
172 |
QTest::addColumn<int>("bytesPerLine"); |
|
173 |
||
174 |
QTest::newRow("64x64 ARGB32 0 size") |
|
175 |
<< QSize(64, 64) |
|
176 |
<< QVideoFrame::Format_ARGB32 |
|
177 |
<< 0 |
|
178 |
<< 45; |
|
179 |
QTest::newRow("32x256 YUV420P negative size") |
|
180 |
<< QSize(32, 256) |
|
181 |
<< QVideoFrame::Format_YUV420P |
|
182 |
<< -13288 |
|
183 |
<< 32; |
|
184 |
} |
|
185 |
||
186 |
void tst_QVideoFrame::createInvalid() |
|
187 |
{ |
|
188 |
QFETCH(QSize, size); |
|
189 |
QFETCH(QVideoFrame::PixelFormat, pixelFormat); |
|
190 |
QFETCH(int, bytes); |
|
191 |
QFETCH(int, bytesPerLine); |
|
192 |
||
193 |
QVideoFrame frame(bytes, size, bytesPerLine, pixelFormat); |
|
194 |
||
195 |
QVERIFY(!frame.isValid()); |
|
196 |
QCOMPARE(frame.handleType(), QAbstractVideoBuffer::NoHandle); |
|
197 |
QCOMPARE(frame.pixelFormat(), pixelFormat); |
|
198 |
QCOMPARE(frame.size(), size); |
|
199 |
QCOMPARE(frame.width(), size.width()); |
|
200 |
QCOMPARE(frame.height(), size.height()); |
|
201 |
QCOMPARE(frame.fieldType(), QVideoFrame::ProgressiveFrame); |
|
202 |
QCOMPARE(frame.startTime(), qint64(-1)); |
|
203 |
QCOMPARE(frame.endTime(), qint64(-1)); |
|
204 |
} |
|
205 |
||
206 |
void tst_QVideoFrame::createFromBuffer_data() |
|
207 |
{ |
|
208 |
QTest::addColumn<QAbstractVideoBuffer::HandleType>("handleType"); |
|
209 |
QTest::addColumn<QSize>("size"); |
|
210 |
QTest::addColumn<QVideoFrame::PixelFormat>("pixelFormat"); |
|
211 |
||
212 |
QTest::newRow("64x64 ARGB32 no handle") |
|
213 |
<< QAbstractVideoBuffer::NoHandle |
|
214 |
<< QSize(64, 64) |
|
215 |
<< QVideoFrame::Format_ARGB32; |
|
216 |
QTest::newRow("64x64 ARGB32 gl handle") |
|
217 |
<< QAbstractVideoBuffer::GLTextureHandle |
|
218 |
<< QSize(64, 64) |
|
219 |
<< QVideoFrame::Format_ARGB32; |
|
220 |
QTest::newRow("64x64 ARGB32 user handle") |
|
221 |
<< QAbstractVideoBuffer::UserHandle |
|
222 |
<< QSize(64, 64) |
|
223 |
<< QVideoFrame::Format_ARGB32; |
|
224 |
} |
|
225 |
||
226 |
void tst_QVideoFrame::createFromBuffer() |
|
227 |
{ |
|
228 |
QFETCH(QAbstractVideoBuffer::HandleType, handleType); |
|
229 |
QFETCH(QSize, size); |
|
230 |
QFETCH(QVideoFrame::PixelFormat, pixelFormat); |
|
231 |
||
232 |
QVideoFrame frame(new QtTestVideoBuffer(handleType), size, pixelFormat); |
|
233 |
||
234 |
QVERIFY(frame.isValid()); |
|
235 |
QCOMPARE(frame.handleType(), handleType); |
|
236 |
QCOMPARE(frame.pixelFormat(), pixelFormat); |
|
237 |
QCOMPARE(frame.size(), size); |
|
238 |
QCOMPARE(frame.width(), size.width()); |
|
239 |
QCOMPARE(frame.height(), size.height()); |
|
240 |
QCOMPARE(frame.fieldType(), QVideoFrame::ProgressiveFrame); |
|
241 |
QCOMPARE(frame.startTime(), qint64(-1)); |
|
242 |
QCOMPARE(frame.endTime(), qint64(-1)); |
|
243 |
} |
|
244 |
||
245 |
void tst_QVideoFrame::createFromImage_data() |
|
246 |
{ |
|
247 |
QTest::addColumn<QSize>("size"); |
|
248 |
QTest::addColumn<QImage::Format>("imageFormat"); |
|
249 |
QTest::addColumn<QVideoFrame::PixelFormat>("pixelFormat"); |
|
250 |
||
251 |
QTest::newRow("64x64 RGB32") |
|
252 |
<< QSize(64, 64) |
|
253 |
<< QImage::Format_RGB32 |
|
254 |
<< QVideoFrame::Format_RGB32; |
|
255 |
QTest::newRow("12x45 RGB16") |
|
256 |
<< QSize(12, 45) |
|
257 |
<< QImage::Format_RGB16 |
|
258 |
<< QVideoFrame::Format_RGB565; |
|
259 |
QTest::newRow("19x46 ARGB32_Premultiplied") |
|
260 |
<< QSize(19, 46) |
|
261 |
<< QImage::Format_ARGB32_Premultiplied |
|
262 |
<< QVideoFrame::Format_ARGB32_Premultiplied; |
|
263 |
} |
|
264 |
||
265 |
void tst_QVideoFrame::createFromImage() |
|
266 |
{ |
|
267 |
QFETCH(QSize, size); |
|
268 |
QFETCH(QImage::Format, imageFormat); |
|
269 |
QFETCH(QVideoFrame::PixelFormat, pixelFormat); |
|
270 |
||
271 |
const QImage image(size.width(), size.height(), imageFormat); |
|
272 |
||
273 |
QVideoFrame frame(image); |
|
274 |
||
275 |
QVERIFY(frame.isValid()); |
|
276 |
QCOMPARE(frame.handleType(), QAbstractVideoBuffer::NoHandle); |
|
277 |
QCOMPARE(frame.pixelFormat(), pixelFormat); |
|
278 |
QCOMPARE(frame.size(), size); |
|
279 |
QCOMPARE(frame.width(), size.width()); |
|
280 |
QCOMPARE(frame.height(), size.height()); |
|
281 |
QCOMPARE(frame.fieldType(), QVideoFrame::ProgressiveFrame); |
|
282 |
QCOMPARE(frame.startTime(), qint64(-1)); |
|
283 |
QCOMPARE(frame.endTime(), qint64(-1)); |
|
284 |
} |
|
285 |
||
286 |
void tst_QVideoFrame::createFromIncompatibleImage() |
|
287 |
{ |
|
288 |
const QImage image(64, 64, QImage::Format_Mono); |
|
289 |
||
290 |
QVideoFrame frame(image); |
|
291 |
||
292 |
QVERIFY(!frame.isValid()); |
|
293 |
QCOMPARE(frame.handleType(), QAbstractVideoBuffer::NoHandle); |
|
294 |
QCOMPARE(frame.pixelFormat(), QVideoFrame::Format_Invalid); |
|
295 |
QCOMPARE(frame.size(), QSize(64, 64)); |
|
296 |
QCOMPARE(frame.width(), 64); |
|
297 |
QCOMPARE(frame.height(), 64); |
|
298 |
QCOMPARE(frame.fieldType(), QVideoFrame::ProgressiveFrame); |
|
299 |
QCOMPARE(frame.startTime(), qint64(-1)); |
|
300 |
QCOMPARE(frame.endTime(), qint64(-1)); |
|
301 |
} |
|
302 |
||
303 |
void tst_QVideoFrame::createNull() |
|
304 |
{ |
|
305 |
QVideoFrame frame; |
|
306 |
||
307 |
QVERIFY(!frame.isValid()); |
|
308 |
QCOMPARE(frame.handleType(), QAbstractVideoBuffer::NoHandle); |
|
309 |
QCOMPARE(frame.pixelFormat(), QVideoFrame::Format_Invalid); |
|
310 |
QCOMPARE(frame.size(), QSize()); |
|
311 |
QCOMPARE(frame.width(), -1); |
|
312 |
QCOMPARE(frame.height(), -1); |
|
313 |
QCOMPARE(frame.fieldType(), QVideoFrame::ProgressiveFrame); |
|
314 |
QCOMPARE(frame.startTime(), qint64(-1)); |
|
315 |
QCOMPARE(frame.endTime(), qint64(-1)); |
|
316 |
} |
|
317 |
||
318 |
void tst_QVideoFrame::destructor() |
|
319 |
{ |
|
320 |
QPointer<QtTestVideoBuffer> buffer = new QtTestVideoBuffer; |
|
321 |
||
322 |
{ |
|
323 |
QVideoFrame frame(buffer, QSize(4, 1), QVideoFrame::Format_ARGB32); |
|
324 |
} |
|
325 |
||
326 |
QVERIFY(buffer.isNull()); |
|
327 |
} |
|
328 |
||
329 |
void tst_QVideoFrame::copy_data() |
|
330 |
{ |
|
331 |
QTest::addColumn<QAbstractVideoBuffer::HandleType>("handleType"); |
|
332 |
QTest::addColumn<QSize>("size"); |
|
333 |
QTest::addColumn<QVideoFrame::PixelFormat>("pixelFormat"); |
|
334 |
QTest::addColumn<QVideoFrame::FieldType>("fieldType"); |
|
335 |
QTest::addColumn<qint64>("startTime"); |
|
336 |
QTest::addColumn<qint64>("endTime"); |
|
337 |
||
338 |
QTest::newRow("64x64 ARGB32") |
|
339 |
<< QAbstractVideoBuffer::GLTextureHandle |
|
340 |
<< QSize(64, 64) |
|
341 |
<< QVideoFrame::Format_ARGB32 |
|
342 |
<< QVideoFrame::TopField |
|
343 |
<< qint64(63641740) |
|
344 |
<< qint64(63641954); |
|
345 |
QTest::newRow("32x256 YUV420P") |
|
346 |
<< QAbstractVideoBuffer::UserHandle |
|
347 |
<< QSize(32, 256) |
|
348 |
<< QVideoFrame::Format_YUV420P |
|
349 |
<< QVideoFrame::InterlacedFrame |
|
350 |
<< qint64(12345) |
|
351 |
<< qint64(12389); |
|
352 |
} |
|
353 |
||
354 |
void tst_QVideoFrame::copy() |
|
355 |
{ |
|
356 |
QFETCH(QAbstractVideoBuffer::HandleType, handleType); |
|
357 |
QFETCH(QSize, size); |
|
358 |
QFETCH(QVideoFrame::PixelFormat, pixelFormat); |
|
359 |
QFETCH(QVideoFrame::FieldType, fieldType); |
|
360 |
QFETCH(qint64, startTime); |
|
361 |
QFETCH(qint64, endTime); |
|
362 |
||
363 |
QPointer<QtTestVideoBuffer> buffer = new QtTestVideoBuffer(handleType); |
|
364 |
||
365 |
{ |
|
366 |
QVideoFrame frame(buffer, size, pixelFormat); |
|
367 |
frame.setFieldType(QVideoFrame::FieldType(fieldType)); |
|
368 |
frame.setStartTime(startTime); |
|
369 |
frame.setEndTime(endTime); |
|
370 |
||
371 |
QVERIFY(frame.isValid()); |
|
372 |
QCOMPARE(frame.handleType(), handleType); |
|
373 |
QCOMPARE(frame.pixelFormat(), pixelFormat); |
|
374 |
QCOMPARE(frame.size(), size); |
|
375 |
QCOMPARE(frame.width(), size.width()); |
|
376 |
QCOMPARE(frame.height(), size.height()); |
|
377 |
QCOMPARE(frame.fieldType(), fieldType); |
|
378 |
QCOMPARE(frame.startTime(), startTime); |
|
379 |
QCOMPARE(frame.endTime(), endTime); |
|
380 |
||
381 |
{ |
|
382 |
QVideoFrame otherFrame(frame); |
|
383 |
||
384 |
QVERIFY(!buffer.isNull()); |
|
385 |
||
386 |
QVERIFY(otherFrame.isValid()); |
|
387 |
QCOMPARE(otherFrame.handleType(), handleType); |
|
388 |
QCOMPARE(otherFrame.pixelFormat(), pixelFormat); |
|
389 |
QCOMPARE(otherFrame.size(), size); |
|
390 |
QCOMPARE(otherFrame.width(), size.width()); |
|
391 |
QCOMPARE(otherFrame.height(), size.height()); |
|
392 |
QCOMPARE(otherFrame.fieldType(), fieldType); |
|
393 |
QCOMPARE(otherFrame.startTime(), startTime); |
|
394 |
QCOMPARE(otherFrame.endTime(), endTime); |
|
395 |
||
396 |
otherFrame.setEndTime(-1); |
|
397 |
||
398 |
QVERIFY(!buffer.isNull()); |
|
399 |
||
400 |
QVERIFY(otherFrame.isValid()); |
|
401 |
QCOMPARE(otherFrame.handleType(), handleType); |
|
402 |
QCOMPARE(otherFrame.pixelFormat(), pixelFormat); |
|
403 |
QCOMPARE(otherFrame.size(), size); |
|
404 |
QCOMPARE(otherFrame.width(), size.width()); |
|
405 |
QCOMPARE(otherFrame.height(), size.height()); |
|
406 |
QCOMPARE(otherFrame.fieldType(), fieldType); |
|
407 |
QCOMPARE(otherFrame.startTime(), startTime); |
|
408 |
QCOMPARE(otherFrame.endTime(), qint64(-1)); |
|
409 |
} |
|
410 |
||
411 |
QVERIFY(!buffer.isNull()); |
|
412 |
||
413 |
QVERIFY(frame.isValid()); |
|
414 |
QCOMPARE(frame.handleType(), handleType); |
|
415 |
QCOMPARE(frame.pixelFormat(), pixelFormat); |
|
416 |
QCOMPARE(frame.size(), size); |
|
417 |
QCOMPARE(frame.width(), size.width()); |
|
418 |
QCOMPARE(frame.height(), size.height()); |
|
419 |
QCOMPARE(frame.fieldType(), fieldType); |
|
420 |
QCOMPARE(frame.startTime(), startTime); |
|
421 |
QCOMPARE(frame.endTime(), qint64(-1)); // Explicitly shared. |
|
422 |
} |
|
423 |
||
424 |
QVERIFY(buffer.isNull()); |
|
425 |
} |
|
426 |
||
427 |
void tst_QVideoFrame::assign_data() |
|
428 |
{ |
|
429 |
QTest::addColumn<QAbstractVideoBuffer::HandleType>("handleType"); |
|
430 |
QTest::addColumn<QSize>("size"); |
|
431 |
QTest::addColumn<QVideoFrame::PixelFormat>("pixelFormat"); |
|
432 |
QTest::addColumn<QVideoFrame::FieldType>("fieldType"); |
|
433 |
QTest::addColumn<qint64>("startTime"); |
|
434 |
QTest::addColumn<qint64>("endTime"); |
|
435 |
||
436 |
QTest::newRow("64x64 ARGB32") |
|
437 |
<< QAbstractVideoBuffer::GLTextureHandle |
|
438 |
<< QSize(64, 64) |
|
439 |
<< QVideoFrame::Format_ARGB32 |
|
440 |
<< QVideoFrame::TopField |
|
441 |
<< qint64(63641740) |
|
442 |
<< qint64(63641954); |
|
443 |
QTest::newRow("32x256 YUV420P") |
|
444 |
<< QAbstractVideoBuffer::UserHandle |
|
445 |
<< QSize(32, 256) |
|
446 |
<< QVideoFrame::Format_YUV420P |
|
447 |
<< QVideoFrame::InterlacedFrame |
|
448 |
<< qint64(12345) |
|
449 |
<< qint64(12389); |
|
450 |
} |
|
451 |
||
452 |
void tst_QVideoFrame::assign() |
|
453 |
{ |
|
454 |
QFETCH(QAbstractVideoBuffer::HandleType, handleType); |
|
455 |
QFETCH(QSize, size); |
|
456 |
QFETCH(QVideoFrame::PixelFormat, pixelFormat); |
|
457 |
QFETCH(QVideoFrame::FieldType, fieldType); |
|
458 |
QFETCH(qint64, startTime); |
|
459 |
QFETCH(qint64, endTime); |
|
460 |
||
461 |
QPointer<QtTestVideoBuffer> buffer = new QtTestVideoBuffer(handleType); |
|
462 |
||
463 |
QVideoFrame frame; |
|
464 |
{ |
|
465 |
QVideoFrame otherFrame(buffer, size, pixelFormat); |
|
466 |
otherFrame.setFieldType(fieldType); |
|
467 |
otherFrame.setStartTime(startTime); |
|
468 |
otherFrame.setEndTime(endTime); |
|
469 |
||
470 |
frame = otherFrame; |
|
471 |
||
472 |
QVERIFY(!buffer.isNull()); |
|
473 |
||
474 |
QVERIFY(otherFrame.isValid()); |
|
475 |
QCOMPARE(otherFrame.handleType(), handleType); |
|
476 |
QCOMPARE(otherFrame.pixelFormat(), pixelFormat); |
|
477 |
QCOMPARE(otherFrame.size(), size); |
|
478 |
QCOMPARE(otherFrame.width(), size.width()); |
|
479 |
QCOMPARE(otherFrame.height(), size.height()); |
|
480 |
QCOMPARE(otherFrame.fieldType(), fieldType); |
|
481 |
QCOMPARE(otherFrame.startTime(), startTime); |
|
482 |
QCOMPARE(otherFrame.endTime(), endTime); |
|
483 |
||
484 |
otherFrame.setStartTime(-1); |
|
485 |
||
486 |
QVERIFY(!buffer.isNull()); |
|
487 |
||
488 |
QVERIFY(otherFrame.isValid()); |
|
489 |
QCOMPARE(otherFrame.handleType(), handleType); |
|
490 |
QCOMPARE(otherFrame.pixelFormat(), pixelFormat); |
|
491 |
QCOMPARE(otherFrame.size(), size); |
|
492 |
QCOMPARE(otherFrame.width(), size.width()); |
|
493 |
QCOMPARE(otherFrame.height(), size.height()); |
|
494 |
QCOMPARE(otherFrame.fieldType(), fieldType); |
|
495 |
QCOMPARE(otherFrame.startTime(), qint64(-1)); |
|
496 |
QCOMPARE(otherFrame.endTime(), endTime); |
|
497 |
} |
|
498 |
||
499 |
QVERIFY(!buffer.isNull()); |
|
500 |
||
501 |
QVERIFY(frame.isValid()); |
|
502 |
QCOMPARE(frame.handleType(), handleType); |
|
503 |
QCOMPARE(frame.pixelFormat(), pixelFormat); |
|
504 |
QCOMPARE(frame.size(), size); |
|
505 |
QCOMPARE(frame.width(), size.width()); |
|
506 |
QCOMPARE(frame.height(), size.height()); |
|
507 |
QCOMPARE(frame.fieldType(), fieldType); |
|
508 |
QCOMPARE(frame.startTime(), qint64(-1)); |
|
509 |
QCOMPARE(frame.endTime(), endTime); |
|
510 |
||
511 |
frame = QVideoFrame(); |
|
512 |
||
513 |
QVERIFY(buffer.isNull()); |
|
514 |
||
515 |
QVERIFY(!frame.isValid()); |
|
516 |
QCOMPARE(frame.handleType(), QAbstractVideoBuffer::NoHandle); |
|
517 |
QCOMPARE(frame.pixelFormat(), QVideoFrame::Format_Invalid); |
|
518 |
QCOMPARE(frame.size(), QSize()); |
|
519 |
QCOMPARE(frame.width(), -1); |
|
520 |
QCOMPARE(frame.height(), -1); |
|
521 |
QCOMPARE(frame.fieldType(), QVideoFrame::ProgressiveFrame); |
|
522 |
QCOMPARE(frame.startTime(), qint64(-1)); |
|
523 |
QCOMPARE(frame.endTime(), qint64(-1)); |
|
524 |
} |
|
525 |
||
526 |
void tst_QVideoFrame::map_data() |
|
527 |
{ |
|
528 |
QTest::addColumn<QSize>("size"); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
529 |
QTest::addColumn<int>("mappedBytes"); |
0 | 530 |
QTest::addColumn<int>("bytesPerLine"); |
531 |
QTest::addColumn<QVideoFrame::PixelFormat>("pixelFormat"); |
|
532 |
QTest::addColumn<QAbstractVideoBuffer::MapMode>("mode"); |
|
533 |
||
534 |
QTest::newRow("read-only") |
|
535 |
<< QSize(64, 64) |
|
536 |
<< 16384 |
|
537 |
<< 256 |
|
538 |
<< QVideoFrame::Format_ARGB32 |
|
539 |
<< QAbstractVideoBuffer::ReadOnly; |
|
540 |
||
541 |
QTest::newRow("write-only") |
|
542 |
<< QSize(64, 64) |
|
543 |
<< 16384 |
|
544 |
<< 256 |
|
545 |
<< QVideoFrame::Format_ARGB32 |
|
546 |
<< QAbstractVideoBuffer::WriteOnly; |
|
547 |
||
548 |
QTest::newRow("read-write") |
|
549 |
<< QSize(64, 64) |
|
550 |
<< 16384 |
|
551 |
<< 256 |
|
552 |
<< QVideoFrame::Format_ARGB32 |
|
553 |
<< QAbstractVideoBuffer::ReadWrite; |
|
554 |
} |
|
555 |
||
556 |
void tst_QVideoFrame::map() |
|
557 |
{ |
|
558 |
QFETCH(QSize, size); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
559 |
QFETCH(int, mappedBytes); |
0 | 560 |
QFETCH(int, bytesPerLine); |
561 |
QFETCH(QVideoFrame::PixelFormat, pixelFormat); |
|
562 |
QFETCH(QAbstractVideoBuffer::MapMode, mode); |
|
563 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
564 |
QVideoFrame frame(mappedBytes, size, bytesPerLine, pixelFormat); |
0 | 565 |
|
566 |
QVERIFY(!frame.bits()); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
567 |
QCOMPARE(frame.mappedBytes(), 0); |
0 | 568 |
QCOMPARE(frame.bytesPerLine(), 0); |
569 |
QCOMPARE(frame.mapMode(), QAbstractVideoBuffer::NotMapped); |
|
570 |
||
571 |
QVERIFY(frame.map(mode)); |
|
572 |
||
573 |
QVERIFY(frame.bits()); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
574 |
QCOMPARE(frame.mappedBytes(), mappedBytes); |
0 | 575 |
QCOMPARE(frame.bytesPerLine(), bytesPerLine); |
576 |
QCOMPARE(frame.mapMode(), mode); |
|
577 |
||
578 |
frame.unmap(); |
|
579 |
||
580 |
QVERIFY(!frame.bits()); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
581 |
QCOMPARE(frame.mappedBytes(), 0); |
0 | 582 |
QCOMPARE(frame.bytesPerLine(), 0); |
583 |
QCOMPARE(frame.mapMode(), QAbstractVideoBuffer::NotMapped); |
|
584 |
} |
|
585 |
||
586 |
void tst_QVideoFrame::mapImage_data() |
|
587 |
{ |
|
588 |
QTest::addColumn<QSize>("size"); |
|
589 |
QTest::addColumn<QImage::Format>("format"); |
|
590 |
QTest::addColumn<QAbstractVideoBuffer::MapMode>("mode"); |
|
591 |
||
592 |
QTest::newRow("read-only") |
|
593 |
<< QSize(64, 64) |
|
594 |
<< QImage::Format_ARGB32 |
|
595 |
<< QAbstractVideoBuffer::ReadOnly; |
|
596 |
||
597 |
QTest::newRow("write-only") |
|
598 |
<< QSize(15, 106) |
|
599 |
<< QImage::Format_RGB32 |
|
600 |
<< QAbstractVideoBuffer::WriteOnly; |
|
601 |
||
602 |
QTest::newRow("read-write") |
|
603 |
<< QSize(23, 111) |
|
604 |
<< QImage::Format_RGB16 |
|
605 |
<< QAbstractVideoBuffer::ReadWrite; |
|
606 |
} |
|
607 |
||
608 |
void tst_QVideoFrame::mapImage() |
|
609 |
{ |
|
610 |
QFETCH(QSize, size); |
|
611 |
QFETCH(QImage::Format, format); |
|
612 |
QFETCH(QAbstractVideoBuffer::MapMode, mode); |
|
613 |
||
614 |
QImage image(size.width(), size.height(), format); |
|
615 |
||
616 |
QVideoFrame frame(image); |
|
617 |
||
618 |
QVERIFY(!frame.bits()); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
619 |
QCOMPARE(frame.mappedBytes(), 0); |
0 | 620 |
QCOMPARE(frame.bytesPerLine(), 0); |
621 |
QCOMPARE(frame.mapMode(), QAbstractVideoBuffer::NotMapped); |
|
622 |
||
623 |
QVERIFY(frame.map(mode)); |
|
624 |
||
625 |
QVERIFY(frame.bits()); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
626 |
QCOMPARE(frame.mappedBytes(), image.numBytes()); |
0 | 627 |
QCOMPARE(frame.bytesPerLine(), image.bytesPerLine()); |
628 |
QCOMPARE(frame.mapMode(), mode); |
|
629 |
||
630 |
frame.unmap(); |
|
631 |
||
632 |
QVERIFY(!frame.bits()); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
633 |
QCOMPARE(frame.mappedBytes(), 0); |
0 | 634 |
QCOMPARE(frame.bytesPerLine(), 0); |
635 |
QCOMPARE(frame.mapMode(), QAbstractVideoBuffer::NotMapped); |
|
636 |
} |
|
637 |
||
638 |
void tst_QVideoFrame::imageDetach() |
|
639 |
{ |
|
640 |
const uint red = qRgb(255, 0, 0); |
|
641 |
const uint blue = qRgb(0, 0, 255); |
|
642 |
||
643 |
QImage image(8, 8, QImage::Format_RGB32); |
|
644 |
||
645 |
image.fill(red); |
|
646 |
QCOMPARE(image.pixel(4, 4), red); |
|
647 |
||
648 |
QVideoFrame frame(image); |
|
649 |
||
650 |
QVERIFY(frame.map(QAbstractVideoBuffer::ReadWrite)); |
|
651 |
||
652 |
QImage frameImage(frame.bits(), 8, 8, frame.bytesPerLine(), QImage::Format_RGB32); |
|
653 |
||
654 |
QCOMPARE(frameImage.pixel(4, 4), red); |
|
655 |
||
656 |
frameImage.fill(blue); |
|
657 |
QCOMPARE(frameImage.pixel(4, 4), blue); |
|
658 |
||
659 |
// Original image has detached and is therefore unchanged. |
|
660 |
QCOMPARE(image.pixel(4, 4), red); |
|
661 |
} |
|
662 |
||
33
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
663 |
void tst_QVideoFrame::formatConversion_data() |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
664 |
{ |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
665 |
QTest::addColumn<QImage::Format>("imageFormat"); |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
666 |
QTest::addColumn<QVideoFrame::PixelFormat>("pixelFormat"); |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
667 |
|
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
668 |
QTest::newRow("QImage::Format_RGB32 | QVideoFrame::Format_RGB32") |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
669 |
<< QImage::Format_RGB32 |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
670 |
<< QVideoFrame::Format_RGB32; |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
671 |
QTest::newRow("QImage::Format_ARGB32 | QVideoFrame::Format_ARGB32") |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
672 |
<< QImage::Format_ARGB32 |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
673 |
<< QVideoFrame::Format_ARGB32; |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
674 |
QTest::newRow("QImage::Format_ARGB32_Premultiplied | QVideoFrame::Format_ARGB32_Premultiplied") |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
675 |
<< QImage::Format_ARGB32_Premultiplied |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
676 |
<< QVideoFrame::Format_ARGB32_Premultiplied; |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
677 |
QTest::newRow("QImage::Format_RGB16 | QVideoFrame::Format_RGB565") |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
678 |
<< QImage::Format_RGB16 |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
679 |
<< QVideoFrame::Format_RGB565; |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
680 |
QTest::newRow("QImage::Format_ARGB8565_Premultiplied | QVideoFrame::Format_ARGB8565_Premultiplied") |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
681 |
<< QImage::Format_ARGB8565_Premultiplied |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
682 |
<< QVideoFrame::Format_ARGB8565_Premultiplied; |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
683 |
QTest::newRow("QImage::Format_RGB555 | QVideoFrame::Format_RGB555") |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
684 |
<< QImage::Format_RGB555 |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
685 |
<< QVideoFrame::Format_RGB555; |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
686 |
QTest::newRow("QImage::Format_RGB888 | QVideoFrame::Format_RGB24") |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
687 |
<< QImage::Format_RGB888 |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
688 |
<< QVideoFrame::Format_RGB24; |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
689 |
|
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
690 |
QTest::newRow("QImage::Format_MonoLSB") |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
691 |
<< QImage::Format_MonoLSB |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
692 |
<< QVideoFrame::Format_Invalid; |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
693 |
QTest::newRow("QImage::Format_Indexed8") |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
694 |
<< QImage::Format_Indexed8 |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
695 |
<< QVideoFrame::Format_Invalid; |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
696 |
QTest::newRow("QImage::Format_ARGB6666_Premultiplied") |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
697 |
<< QImage::Format_ARGB6666_Premultiplied |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
698 |
<< QVideoFrame::Format_Invalid; |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
699 |
QTest::newRow("QImage::Format_ARGB8555_Premultiplied") |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
700 |
<< QImage::Format_ARGB8555_Premultiplied |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
701 |
<< QVideoFrame::Format_Invalid; |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
702 |
QTest::newRow("QImage::Format_RGB666") |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
703 |
<< QImage::Format_RGB666 |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
704 |
<< QVideoFrame::Format_Invalid; |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
705 |
QTest::newRow("QImage::Format_RGB444") |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
706 |
<< QImage::Format_RGB444 |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
707 |
<< QVideoFrame::Format_Invalid; |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
708 |
QTest::newRow("QImage::Format_ARGB4444_Premultiplied") |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
709 |
<< QImage::Format_ARGB4444_Premultiplied |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
710 |
<< QVideoFrame::Format_Invalid; |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
711 |
|
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
712 |
QTest::newRow("QVideoFrame::Format_BGRA32") |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
713 |
<< QImage::Format_Invalid |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
714 |
<< QVideoFrame::Format_BGRA32; |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
715 |
QTest::newRow("QVideoFrame::Format_BGRA32_Premultiplied") |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
716 |
<< QImage::Format_Invalid |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
717 |
<< QVideoFrame::Format_BGRA32_Premultiplied; |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
718 |
QTest::newRow("QVideoFrame::Format_BGR32") |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
719 |
<< QImage::Format_Invalid |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
720 |
<< QVideoFrame::Format_BGR32; |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
721 |
QTest::newRow("QVideoFrame::Format_BGR24") |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
722 |
<< QImage::Format_Invalid |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
723 |
<< QVideoFrame::Format_BGR24; |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
724 |
QTest::newRow("QVideoFrame::Format_BGR565") |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
725 |
<< QImage::Format_Invalid |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
726 |
<< QVideoFrame::Format_BGR565; |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
727 |
QTest::newRow("QVideoFrame::Format_BGR555") |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
728 |
<< QImage::Format_Invalid |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
729 |
<< QVideoFrame::Format_BGR555; |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
730 |
QTest::newRow("QVideoFrame::Format_BGRA5658_Premultiplied") |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
731 |
<< QImage::Format_Invalid |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
732 |
<< QVideoFrame::Format_BGRA5658_Premultiplied; |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
733 |
QTest::newRow("QVideoFrame::Format_AYUV444") |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
734 |
<< QImage::Format_Invalid |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
735 |
<< QVideoFrame::Format_AYUV444; |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
736 |
QTest::newRow("QVideoFrame::Format_AYUV444_Premultiplied") |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
737 |
<< QImage::Format_Invalid |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
738 |
<< QVideoFrame::Format_AYUV444_Premultiplied; |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
739 |
QTest::newRow("QVideoFrame::Format_YUV444") |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
740 |
<< QImage::Format_Invalid |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
741 |
<< QVideoFrame::Format_YUV420P; |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
742 |
QTest::newRow("QVideoFrame::Format_YV12") |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
743 |
<< QImage::Format_Invalid |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
744 |
<< QVideoFrame::Format_YV12; |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
745 |
QTest::newRow("QVideoFrame::Format_UYVY") |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
746 |
<< QImage::Format_Invalid |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
747 |
<< QVideoFrame::Format_UYVY; |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
748 |
QTest::newRow("QVideoFrame::Format_YUYV") |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
749 |
<< QImage::Format_Invalid |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
750 |
<< QVideoFrame::Format_YUYV; |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
751 |
QTest::newRow("QVideoFrame::Format_NV12") |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
752 |
<< QImage::Format_Invalid |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
753 |
<< QVideoFrame::Format_NV12; |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
754 |
QTest::newRow("QVideoFrame::Format_NV21") |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
755 |
<< QImage::Format_Invalid |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
756 |
<< QVideoFrame::Format_NV21; |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
757 |
QTest::newRow("QVideoFrame::Format_IMC1") |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
758 |
<< QImage::Format_Invalid |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
759 |
<< QVideoFrame::Format_IMC1; |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
760 |
QTest::newRow("QVideoFrame::Format_IMC2") |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
761 |
<< QImage::Format_Invalid |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
762 |
<< QVideoFrame::Format_IMC2; |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
763 |
QTest::newRow("QVideoFrame::Format_IMC3") |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
764 |
<< QImage::Format_Invalid |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
765 |
<< QVideoFrame::Format_IMC3; |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
766 |
QTest::newRow("QVideoFrame::Format_IMC4") |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
767 |
<< QImage::Format_Invalid |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
768 |
<< QVideoFrame::Format_IMC4; |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
769 |
QTest::newRow("QVideoFrame::Format_Y8") |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
770 |
<< QImage::Format_Invalid |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
771 |
<< QVideoFrame::Format_Y8; |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
772 |
QTest::newRow("QVideoFrame::Format_Y16") |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
773 |
<< QImage::Format_Invalid |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
774 |
<< QVideoFrame::Format_Y16; |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
775 |
} |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
776 |
|
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
777 |
void tst_QVideoFrame::formatConversion() |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
778 |
{ |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
779 |
QFETCH(QImage::Format, imageFormat); |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
780 |
QFETCH(QVideoFrame::PixelFormat, pixelFormat); |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
781 |
|
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
782 |
QCOMPARE(QVideoFrame::pixelFormatFromImageFormat(imageFormat) == pixelFormat, |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
783 |
imageFormat != QImage::Format_Invalid); |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
784 |
|
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
785 |
QCOMPARE(QVideoFrame::imageFormatFromPixelFormat(pixelFormat) == imageFormat, |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
786 |
pixelFormat != QVideoFrame::Format_Invalid); |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
787 |
} |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
788 |
|
0 | 789 |
QTEST_MAIN(tst_QVideoFrame) |
790 |
||
791 |
#include "tst_qvideoframe.moc" |