Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qvideoframetestutils.cpp
Go to the documentation of this file.
1// Copyright (C) 2026 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
5
6#include <cstring>
7
8QT_BEGIN_NAMESPACE
9
10namespace QtMultimediaTest {
11
12QByteArray makeBytes(std::initializer_list<uchar> bytes)
13{
14 return QByteArray(reinterpret_cast<const char *>(bytes.begin()), qsizetype(bytes.size()));
15}
16
17void fillPlaneRows(uchar *data, qsizetype stride, int width, int height, QByteArrayView texel)
18{
19 for (int row = 0; row < height; ++row) {
20 uchar *rowData = data + row * stride;
21 for (int col = 0; col < width; ++col)
22 std::memcpy(rowData + col * texel.size(), texel.constData(), texel.size());
23 }
24}
25
26q23::expected<void, QString> comparePlaneRows(const uchar *data, qsizetype stride, int width,
27 int height, QByteArrayView texel)
28{
29 for (int row = 0; row < height; ++row) {
30 const uchar *rowData = data + row * stride;
31 for (int col = 0; col < width; ++col) {
32 if (std::memcmp(rowData + col * texel.size(), texel.constData(), texel.size()) != 0)
33 return q23::unexpected(
34 QStringLiteral("mismatch at row %1, column %2").arg(row).arg(col));
35 }
36 }
37 return {};
38}
39
40} // namespace QtMultimediaTest
41
42QT_END_NAMESPACE
q23::expected< void, QString > comparePlaneRows(const uchar *data, qsizetype stride, int width, int height, QByteArrayView texel)
QByteArray makeBytes(std::initializer_list< uchar > bytes)
void fillPlaneRows(uchar *data, qsizetype stride, int width, int height, QByteArrayView texel)