diff options
author | Lars Knoll <lars.knoll@qt.io> | 2021-06-29 10:38:26 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2021-07-07 16:37:06 +0200 |
commit | 93b80bcd2ed020c64e3608975cb21d1084871f69 (patch) | |
tree | a7273ca2d8964dac6c5754c5cb15e7a66e6755ab | |
parent | d317ea8e7a15f581dc18f7b6848da3130c837799 (diff) |
Fix the MapData structure to include per plane size information
So far the data only contained information about the total size in
bytes. That does break down for planar formats where the different
planes do not have to be connected in memory. So rather provide
the data size per plane.
Also clean up the API and remove the methods that access the mapped
data without a plane argument, as their semantic is not well defined.
Change-Id: I3fb2c74172c31720e66d9856472e8786e9004afa
Reviewed-by: André de la Rocha <andre.rocha@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
16 files changed, 76 insertions, 107 deletions
diff --git a/examples/multimediawidgets/player/histogramwidget.cpp b/examples/multimediawidgets/player/histogramwidget.cpp index 5cd3bc3b3..26595dd8a 100644 --- a/examples/multimediawidgets/player/histogramwidget.cpp +++ b/examples/multimediawidgets/player/histogramwidget.cpp @@ -214,18 +214,18 @@ void FrameProcessor::processFrame(QVideoFrame frame, int levels) if (frame.pixelFormat() == QVideoFrameFormat::Format_YUV420P || frame.pixelFormat() == QVideoFrameFormat::Format_NV12) { // Process YUV data - uchar *b = frame.bits(); + uchar *b = frame.bits(0); for (int y = 0; y < frame.height(); ++y) { uchar *lastPixel = b + frame.width(); for (uchar *curPixel = b; curPixel < lastPixel; curPixel++) histogram[(*curPixel * levels) >> 8] += 1.0; - b += frame.bytesPerLine(); + b += frame.bytesPerLine(0); } } else { QImage::Format imageFormat = QVideoFrameFormat::imageFormatFromPixelFormat(frame.pixelFormat()); if (imageFormat != QImage::Format_Invalid) { // Process RGB data - QImage image(frame.bits(), frame.width(), frame.height(), imageFormat); + QImage image(frame.bits(0), frame.width(), frame.height(), imageFormat); image = image.convertToFormat(QImage::Format_RGB32); const QRgb* b = (const QRgb*)image.bits(); diff --git a/src/multimedia/platform/android/common/qandroidvideooutput.cpp b/src/multimedia/platform/android/common/qandroidvideooutput.cpp index 823fe862c..f6c5d3f8e 100644 --- a/src/multimedia/platform/android/common/qandroidvideooutput.cpp +++ b/src/multimedia/platform/android/common/qandroidvideooutput.cpp @@ -115,9 +115,9 @@ public: m_mapMode = mode; m_image = m_output->m_fbo->toImage(); - mapData.nBytes = static_cast<int>(m_image.sizeInBytes()); mapData.nPlanes = 1; mapData.bytesPerLine[0] = m_image.bytesPerLine(); + mapData.size[0] = static_cast<int>(m_image.sizeInBytes()); mapData.data[0] = m_image.bits(); } diff --git a/src/multimedia/platform/darwin/avfvideobuffer.mm b/src/multimedia/platform/darwin/avfvideobuffer.mm index 24036c410..5a3ea4d5d 100644 --- a/src/multimedia/platform/darwin/avfvideobuffer.mm +++ b/src/multimedia/platform/darwin/avfvideobuffer.mm @@ -94,13 +94,13 @@ AVFVideoBuffer::MapData AVFVideoBuffer::map(QVideoFrame::MapMode mode) } mapData.nPlanes = CVPixelBufferGetPlaneCount(m_buffer); - mapData.nBytes = CVPixelBufferGetDataSize(m_buffer); Q_ASSERT(mapData.nPlanes <= 3); if (!mapData.nPlanes) { // single plane mapData.bytesPerLine[0] = CVPixelBufferGetBytesPerRow(m_buffer); mapData.data[0] = static_cast<uchar*>(CVPixelBufferGetBaseAddress(m_buffer)); + mapData.size[0] = CVPixelBufferGetDataSize(m_buffer); mapData.nPlanes = mapData.data[0] ? 1 : 0; return mapData; } @@ -108,6 +108,7 @@ AVFVideoBuffer::MapData AVFVideoBuffer::map(QVideoFrame::MapMode mode) // For a bi-planar or tri-planar format we have to set the parameters correctly: for (int i = 0; i < mapData.nPlanes; ++i) { mapData.bytesPerLine[i] = CVPixelBufferGetBytesPerRowOfPlane(m_buffer, i); + mapData.size[i] = mapData.bytesPerLine[i]*CVPixelBufferGetHeightOfPlane(m_buffer, i); mapData.data[i] = static_cast<uchar*>(CVPixelBufferGetBaseAddressOfPlane(m_buffer, i)); } diff --git a/src/multimedia/platform/gstreamer/common/qgstvideobuffer.cpp b/src/multimedia/platform/gstreamer/common/qgstvideobuffer.cpp index a345fc8c2..f25192c41 100644 --- a/src/multimedia/platform/gstreamer/common/qgstvideobuffer.cpp +++ b/src/multimedia/platform/gstreamer/common/qgstvideobuffer.cpp @@ -88,20 +88,20 @@ QAbstractVideoBuffer::MapData QGstVideoBuffer::map(QVideoFrame::MapMode mode) if (m_videoInfo.finfo->n_planes == 0) { // Encoded if (gst_buffer_map(m_buffer, &m_frame.map[0], flags)) { - mapData.nBytes = m_frame.map[0].size; mapData.nPlanes = 1; mapData.bytesPerLine[0] = -1; + mapData.size[0] = m_frame.map[0].size; mapData.data[0] = static_cast<uchar *>(m_frame.map[0].data); m_mode = mode; } } else if (gst_video_frame_map(&m_frame, &m_videoInfo, m_buffer, flags)) { - mapData.nBytes = m_frame.info.size; mapData.nPlanes = m_frame.info.finfo->n_planes; for (guint i = 0; i < m_frame.info.finfo->n_planes; ++i) { - mapData.bytesPerLine[i] = m_frame.info.stride[i]; - mapData.data[i] = static_cast<uchar *>(m_frame.data[i]); + mapData.bytesPerLine[i] = GST_VIDEO_FRAME_PLANE_STRIDE(&m_frame, i); + mapData.data[i] = static_cast<uchar *>(GST_VIDEO_FRAME_PLANE_DATA(&m_frame, i)); + mapData.size[i] = mapData.bytesPerLine[i]*GST_VIDEO_FRAME_COMP_HEIGHT(&m_frame, i); } m_mode = mode; diff --git a/src/multimedia/platform/windows/evr/evrd3dpresentengine.cpp b/src/multimedia/platform/windows/evr/evrd3dpresentengine.cpp index ff0185b2e..b1e477675 100644 --- a/src/multimedia/platform/windows/evr/evrd3dpresentengine.cpp +++ b/src/multimedia/platform/windows/evr/evrd3dpresentengine.cpp @@ -114,10 +114,10 @@ IMFSampleVideoBuffer::MapData IMFSampleVideoBuffer::map(QVideoFrame::MapMode mod m_mapMode = mode; MapData mapData; - mapData.nBytes = (int)(rect.Pitch * desc.Height); mapData.nPlanes = 1; mapData.bytesPerLine[0] = (int)rect.Pitch; mapData.data[0] = reinterpret_cast<uchar *>(rect.pBits); + mapData.size[0] = (int)(rect.Pitch * desc.Height); return mapData; } diff --git a/src/multimedia/platform/windows/player/mfvideorenderercontrol.cpp b/src/multimedia/platform/windows/player/mfvideorenderercontrol.cpp index 5dae44c28..fb64d5ae2 100644 --- a/src/multimedia/platform/windows/player/mfvideorenderercontrol.cpp +++ b/src/multimedia/platform/windows/player/mfvideorenderercontrol.cpp @@ -83,10 +83,10 @@ namespace DWORD length; HRESULT hr = m_buffer->Lock(&bytes, NULL, &length); if (SUCCEEDED(hr)) { - mapData.nBytes = qsizetype(length); mapData.nPlanes = 1; mapData.bytesPerLine[0] = m_bytesPerLine; mapData.data[0] = reinterpret_cast<uchar *>(bytes); + mapData.size[0] = qsizetype(length); m_mapMode = mode; } else { qWarning("Faild to lock mf buffer!"); diff --git a/src/multimedia/video/qabstractvideobuffer_p.h b/src/multimedia/video/qabstractvideobuffer_p.h index a82f13723..7ec2726ed 100644 --- a/src/multimedia/video/qabstractvideobuffer_p.h +++ b/src/multimedia/video/qabstractvideobuffer_p.h @@ -72,10 +72,10 @@ public: struct MapData { - qsizetype nBytes = 0; int nPlanes = 0; int bytesPerLine[4] = {}; uchar *data[4] = {}; + int size[4] = {}; }; virtual QVideoFrame::MapMode mapMode() const = 0; diff --git a/src/multimedia/video/qmemoryvideobuffer.cpp b/src/multimedia/video/qmemoryvideobuffer.cpp index bd505ecf2..8bb3eae17 100644 --- a/src/multimedia/video/qmemoryvideobuffer.cpp +++ b/src/multimedia/video/qmemoryvideobuffer.cpp @@ -82,10 +82,10 @@ QAbstractVideoBuffer::MapData QMemoryVideoBuffer::map(QVideoFrame::MapMode mode) if (m_mapMode == QVideoFrame::NotMapped && data.size() && mode != QVideoFrame::NotMapped) { m_mapMode = mode; - mapData.nBytes = data.size(); mapData.nPlanes = 1; mapData.bytesPerLine[0] = bytesPerLine; mapData.data[0] = reinterpret_cast<uchar *>(data.data()); + mapData.size[0] = data.size(); } return mapData; diff --git a/src/multimedia/video/qvideoframe.cpp b/src/multimedia/video/qvideoframe.cpp index 91fb76ce1..1c9c3f224 100644 --- a/src/multimedia/video/qvideoframe.cpp +++ b/src/multimedia/video/qvideoframe.cpp @@ -133,12 +133,16 @@ QT_DEFINE_QESDP_SPECIALIZATION_DTOR(QVideoFramePrivate); frames can vary greatly, and some pixel formats offer greater compression opportunities at the expense of ease of use. - The pixel contents of a video frame can be mapped to memory using the map() function. While - mapped, the video data can accessed using the bits() function, which returns a pointer to a - buffer. The total size of this buffer is given by the mappedBytes() function, and the size of - each line is given by bytesPerLine(). The return value of the handle() function may also be - used to access frame data using the internal buffer's native APIs (for example - an OpenGL - texture handle). + The pixel contents of a video frame can be mapped to memory using the map() function. After + a successful call to map(), the video data can be accessed through various functions. Some of + the YUV pixel formats provide the data in several planes. The planeCount() method will return + the amount of planes that being used. + + While mapped, the video data of each plane can accessed using the bits() function, which + returns a pointer to a buffer. The size of this buffer is given by the mappedBytes() function, + and the size of each line is given by bytesPerLine(). The return value of the handle() + function may also be used to access frame data using the internal buffer's native APIs + (for example - an OpenGL texture handle). A video frame can also have timestamp information associated with it. These timestamps can be used to determine when to start and stop displaying the frame. @@ -419,7 +423,7 @@ bool QVideoFrame::map(QVideoFrame::MapMode mode) Q_ASSERT(d->mapData.data[0] == nullptr); Q_ASSERT(d->mapData.bytesPerLine[0] == 0); Q_ASSERT(d->mapData.nPlanes == 0); - Q_ASSERT(d->mapData.nBytes == 0); + Q_ASSERT(d->mapData.size[0] == 0); d->mapData = d->buffer->map(mode); if (d->mapData.nPlanes == 0) @@ -457,13 +461,16 @@ bool QVideoFrame::map(QVideoFrame::MapMode mode) const int height = this->height(); const int yStride = d->mapData.bytesPerLine[0]; const int uvHeight = pixelFmt == QVideoFrameFormat::Format_YUV422P ? height : height / 2; - const int uvStride = (d->mapData.nBytes - (yStride * height)) / uvHeight / 2; + const int uvStride = (d->mapData.size[0] - (yStride * height)) / uvHeight / 2; // Three planes, the second and third vertically (and horizontally for other than Format_YUV422P formats) subsampled. d->mapData.nPlanes = 3; d->mapData.bytesPerLine[2] = d->mapData.bytesPerLine[1] = uvStride; - d->mapData.data[1] = d->mapData.data[0] + (yStride * height); - d->mapData.data[2] = d->mapData.data[1] + (uvStride * uvHeight); + d->mapData.size[0] = yStride * height; + d->mapData.size[1] = uvStride * uvHeight; + d->mapData.size[2] = uvStride * uvHeight; + d->mapData.data[1] = d->mapData.data[0] + d->mapData.size[0]; + d->mapData.data[2] = d->mapData.data[1] + d->mapData.size[1]; break; } case QVideoFrameFormat::Format_NV12: @@ -475,7 +482,10 @@ bool QVideoFrame::map(QVideoFrame::MapMode mode) // Semi planar, Full resolution Y plane with interleaved subsampled U and V planes. d->mapData.nPlanes = 2; d->mapData.bytesPerLine[1] = d->mapData.bytesPerLine[0]; - d->mapData.data[1] = d->mapData.data[0] + (d->mapData.bytesPerLine[0] * height()); + int size = d->mapData.size[0]; + d->mapData.size[0] = (d->mapData.bytesPerLine[0] * height()); + d->mapData.size[1] = size - d->mapData.size[0]; + d->mapData.data[1] = d->mapData.data[0] + d->mapData.size[0]; break; } case QVideoFrameFormat::Format_IMC1: @@ -484,8 +494,11 @@ bool QVideoFrame::map(QVideoFrame::MapMode mode) // but with lines padded to the width of the first plane. d->mapData.nPlanes = 3; d->mapData.bytesPerLine[2] = d->mapData.bytesPerLine[1] = d->mapData.bytesPerLine[0]; - d->mapData.data[1] = d->mapData.data[0] + (d->mapData.bytesPerLine[0] * height()); - d->mapData.data[2] = d->mapData.data[1] + (d->mapData.bytesPerLine[1] * height() / 2); + d->mapData.size[0] = (d->mapData.bytesPerLine[0] * height()); + d->mapData.size[1] = (d->mapData.bytesPerLine[0] * height() / 2); + d->mapData.size[2] = (d->mapData.bytesPerLine[0] * height() / 2); + d->mapData.data[1] = d->mapData.data[0] + d->mapData.size[0]; + d->mapData.data[2] = d->mapData.data[1] + d->mapData.size[1]; break; } } @@ -526,21 +539,6 @@ void QVideoFrame::unmap() } /*! - Returns the number of bytes in a scan line. - - \note For planar formats this is the bytes per line of the first plane only. The bytes per line of subsequent - planes should be calculated as per the frame \l{QVideoFrameFormat::PixelFormat}{pixel format}. - - This value is only valid while the frame data is \l {map()}{mapped}. - - \sa bits(), map(), mappedBytes() -*/ -int QVideoFrame::bytesPerLine() const -{ - return d->mapData.bytesPerLine[0]; -} - -/*! Returns the number of bytes in a scan line of a \a plane. This value is only valid while the frame data is \l {map()}{mapped}. @@ -555,22 +553,6 @@ int QVideoFrame::bytesPerLine(int plane) const } /*! - Returns a pointer to the start of the frame data buffer. - - This value is only valid while the frame data is \l {map()}{mapped}. - - Changes made to data accessed via this pointer (when mapped with write access) - are only guaranteed to have been persisted when unmap() is called and when the - buffer has been mapped for writing. - - \sa map(), mappedBytes(), bytesPerLine() -*/ -uchar *QVideoFrame::bits() -{ - return d->mapData.data[0]; -} - -/*! Returns a pointer to the start of the frame data buffer for a \a plane. This value is only valid while the frame data is \l {map()}{mapped}. @@ -588,21 +570,6 @@ uchar *QVideoFrame::bits(int plane) } /*! - Returns a pointer to the start of the frame data buffer. - - This value is only valid while the frame data is \l {map()}{mapped}. - - If the buffer was not mapped with read access, the contents of this - buffer will initially be uninitialized. - - \sa map(), mappedBytes(), bytesPerLine() -*/ -const uchar *QVideoFrame::bits() const -{ - return d->mapData.data[0]; -} - -/*! Returns a pointer to the start of the frame data buffer for a \a plane. This value is only valid while the frame data is \l {map()}{mapped}. @@ -619,15 +586,15 @@ const uchar *QVideoFrame::bits(int plane) const } /*! - Returns the number of bytes occupied by the mapped frame data. + Returns the number of bytes occupied by plane \a plane of the mapped frame data. This value is only valid while the frame data is \l {map()}{mapped}. \sa map() */ -int QVideoFrame::mappedBytes() const +int QVideoFrame::mappedBytes(int plane) const { - return d->mapData.nBytes; + return plane >= 0 && plane < d->mapData.nPlanes ? d->mapData.size[plane] : 0; } /*! @@ -713,12 +680,12 @@ QImage QVideoFrame::toImage() const // Formats supported by QImage don't need conversion QImage::Format imageFormat = QVideoFrameFormat::imageFormatFromPixelFormat(frame.pixelFormat()); if (imageFormat != QImage::Format_Invalid) { - result = QImage(frame.bits(), frame.width(), frame.height(), frame.bytesPerLine(), imageFormat).copy(); + result = QImage(frame.bits(0), frame.width(), frame.height(), frame.bytesPerLine(0), imageFormat).copy(); } // Load from JPG else if (frame.pixelFormat() == QVideoFrameFormat::Format_Jpeg) { - result.loadFromData(frame.bits(), frame.mappedBytes(), "JPG"); + result.loadFromData(frame.bits(0), frame.mappedBytes(0), "JPG"); } // Need conversion diff --git a/src/multimedia/video/qvideoframe.h b/src/multimedia/video/qvideoframe.h index e5c53b5ec..feb4e2b6d 100644 --- a/src/multimedia/video/qvideoframe.h +++ b/src/multimedia/video/qvideoframe.h @@ -111,14 +111,11 @@ public: bool map(QVideoFrame::MapMode mode); void unmap(); - int bytesPerLine() const; int bytesPerLine(int plane) const; - uchar *bits(); uchar *bits(int plane); - const uchar *bits() const; const uchar *bits(int plane) const; - int mappedBytes() const; + int mappedBytes(int plane) const; int planeCount() const; quint64 textureHandle(int plane) const; diff --git a/src/multimedia/video/qvideoframeconversionhelper_p.h b/src/multimedia/video/qvideoframeconversionhelper_p.h index beb41500f..855c29205 100644 --- a/src/multimedia/video/qvideoframeconversionhelper_p.h +++ b/src/multimedia/video/qvideoframeconversionhelper_p.h @@ -83,8 +83,8 @@ inline quint32 qConvertBGR24ToARGB32(const uchar *bgr) } #define FETCH_INFO_PACKED(frame) \ - const uchar *src = frame.bits(); \ - int stride = frame.bytesPerLine(); \ + const uchar *src = frame.bits(0); \ + int stride = frame.bytesPerLine(0); \ int width = frame.width(); \ int height = frame.height(); diff --git a/src/multimedia/video/qvideotexturehelper.cpp b/src/multimedia/video/qvideotexturehelper.cpp index f9d982456..e0ab9470d 100644 --- a/src/multimedia/video/qvideotexturehelper.cpp +++ b/src/multimedia/video/qvideotexturehelper.cpp @@ -441,9 +441,8 @@ int updateRhiTextures(QVideoFrame frame, QRhi *rhi, QRhiResourceUpdateBatch *res } } - QRhiTextureSubresourceUploadDescription subresDesc(frame.bits(plane), frame.bytesPerLine(plane)*planeSizes[plane].height()); - subresDesc.setSourceSize(planeSizes[plane]); - subresDesc.setDestinationTopLeft(QPoint(0, 0)); + QRhiTextureSubresourceUploadDescription subresDesc(frame.bits(plane), frame.mappedBytes(plane)); + subresDesc.setDataStride(frame.bytesPerLine(plane)); QRhiTextureUploadEntry entry(0, 0, subresDesc); QRhiTextureUploadDescription desc({ entry }); resourceUpdates->uploadTexture(textures[plane], desc); diff --git a/tests/auto/integration/qquickvideooutput/tst_qquickvideooutput.cpp b/tests/auto/integration/qquickvideooutput/tst_qquickvideooutput.cpp index 83b0d4c81..9ec6bcee4 100644 --- a/tests/auto/integration/qquickvideooutput/tst_qquickvideooutput.cpp +++ b/tests/auto/integration/qquickvideooutput/tst_qquickvideooutput.cpp @@ -311,8 +311,8 @@ void tst_QQuickVideoOutput::paintSurface() QVideoFrame frame(QVideoFrameFormat(QSize(4, 4), QVideoFrameFormat::Format_ARGB32)); frame.map(QVideoFrame::ReadWrite); - QCOMPARE(frame.mappedBytes(), 64); - memcpy(frame.bits(), rgb32ImageData, 64); + QCOMPARE(frame.mappedBytes(0), 64); + memcpy(frame.bits(0), rgb32ImageData, 64); frame.unmap(); surface->newVideoFrame(frame); } diff --git a/tests/auto/unit/multimedia/qvideoframe/tst_qvideoframe.cpp b/tests/auto/unit/multimedia/qvideoframe/tst_qvideoframe.cpp index fe933bdbb..5ff6d0e11 100644 --- a/tests/auto/unit/multimedia/qvideoframe/tst_qvideoframe.cpp +++ b/tests/auto/unit/multimedia/qvideoframe/tst_qvideoframe.cpp @@ -119,11 +119,16 @@ public: { m_mapMode = mode; MapData mapData; - mapData.nBytes = m_numBytes; + int nBytes = m_numBytes; mapData.nPlanes = m_planeCount; for (int i = 0; i < m_planeCount; ++i) { mapData.data[i] = m_data[i]; mapData.bytesPerLine[i] = m_bytesPerLine[i]; + if (i) { + mapData.size[i-1] = m_data[i] - m_data[i-1]; + nBytes -= mapData.size[i-1]; + } + mapData.size[i] = nBytes; } return mapData; } @@ -558,25 +563,25 @@ void tst_QVideoFrame::map() QVideoFrame frame(QVideoFrameFormat(size, pixelFormat)); - QVERIFY(!frame.bits()); - QCOMPARE(frame.mappedBytes(), 0); - QCOMPARE(frame.bytesPerLine(), 0); + QVERIFY(!frame.bits(0)); + QCOMPARE(frame.mappedBytes(0), 0); + QCOMPARE(frame.bytesPerLine(0), 0); QCOMPARE(frame.mapMode(), QVideoFrame::NotMapped); QVERIFY(frame.map(mode)); // Mapping multiple times is allowed in ReadOnly mode if (mode == QVideoFrame::ReadOnly) { - const uchar *bits = frame.bits(); + const uchar *bits = frame.bits(0); QVERIFY(frame.map(QVideoFrame::ReadOnly)); QVERIFY(frame.isMapped()); - QCOMPARE(frame.bits(), bits); + QCOMPARE(frame.bits(0), bits); frame.unmap(); //frame should still be mapped after the first nested unmap QVERIFY(frame.isMapped()); - QCOMPARE(frame.bits(), bits); + QCOMPARE(frame.bits(0), bits); //re-mapping in Write or ReadWrite modes should fail QVERIFY(!frame.map(QVideoFrame::WriteOnly)); @@ -587,14 +592,14 @@ void tst_QVideoFrame::map() QVERIFY(!frame.map(QVideoFrame::ReadOnly)); } - QVERIFY(frame.bits()); + QVERIFY(frame.bits(0)); QCOMPARE(frame.mapMode(), mode); frame.unmap(); - QVERIFY(!frame.bits()); - QCOMPARE(frame.mappedBytes(), 0); - QCOMPARE(frame.bytesPerLine(), 0); + QVERIFY(!frame.bits(0)); + QCOMPARE(frame.mappedBytes(0), 0); + QCOMPARE(frame.bytesPerLine(0), 0); QCOMPARE(frame.mapMode(), QVideoFrame::NotMapped); } @@ -796,19 +801,19 @@ void tst_QVideoFrame::formatConversion() #define TEST_MAPPED(frame, mode) \ do { \ - QVERIFY(frame.bits()); \ + QVERIFY(frame.bits(0)); \ QVERIFY(frame.isMapped()); \ - QCOMPARE(frame.mappedBytes(), 16384); \ - QCOMPARE(frame.bytesPerLine(), 256); \ + QCOMPARE(frame.mappedBytes(0), 16384); \ + QCOMPARE(frame.bytesPerLine(0), 256); \ QCOMPARE(frame.mapMode(), mode); \ } while (0) #define TEST_UNMAPPED(frame) \ do { \ - QVERIFY(!frame.bits()); \ + QVERIFY(!frame.bits(0)); \ QVERIFY(!frame.isMapped()); \ - QCOMPARE(frame.mappedBytes(), 0); \ - QCOMPARE(frame.bytesPerLine(), 0); \ + QCOMPARE(frame.mappedBytes(0), 0); \ + QCOMPARE(frame.bytesPerLine(0), 0); \ QCOMPARE(frame.mapMode(), QVideoFrame::NotMapped); \ } while (0) diff --git a/tests/auto/unit/multimediawidgets/qgraphicsvideoitem/tst_qgraphicsvideoitem.cpp b/tests/auto/unit/multimediawidgets/qgraphicsvideoitem/tst_qgraphicsvideoitem.cpp index b04583c87..9b42ee891 100644 --- a/tests/auto/unit/multimediawidgets/qgraphicsvideoitem/tst_qgraphicsvideoitem.cpp +++ b/tests/auto/unit/multimediawidgets/qgraphicsvideoitem/tst_qgraphicsvideoitem.cpp @@ -403,7 +403,7 @@ void tst_QGraphicsVideoItem::paint() QVideoFrameFormat format(QSize(2, 2), QVideoFrameFormat::Format_RGB32); QVideoFrame frame(format); frame.map(QVideoFrame::WriteOnly); - memcpy(frame.bits(), rgb32ImageData, frame.mappedBytes()); + memcpy(frame.bits(0), rgb32ImageData, frame.mappedBytes(0)); frame.unmap(); sink->newVideoFrame(frame); diff --git a/tests/auto/unit/multimediawidgets/qvideowidget/tst_qvideowidget.cpp b/tests/auto/unit/multimediawidgets/qvideowidget/tst_qvideowidget.cpp index be76575fd..90f7d3164 100644 --- a/tests/auto/unit/multimediawidgets/qvideowidget/tst_qvideowidget.cpp +++ b/tests/auto/unit/multimediawidgets/qvideowidget/tst_qvideowidget.cpp @@ -519,7 +519,7 @@ void tst_QVideoWidget::paint() QVideoFrameFormat format(QSize(2, 2), QVideoFrameFormat::Format_RGB32); QVideoFrame frame(format); QVERIFY(frame.map(QVideoFrame::ReadWrite)); - uchar *data = frame.bits(); + uchar *data = frame.bits(0); memcpy(data, rgb32ImageData, sizeof(rgb32ImageData)); frame.unmap(); |