summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorLing Hu <ling.hu@nokia.com>2011-07-19 10:50:41 +1000
committerQt by Nokia <qt-info@nokia.com>2011-07-25 07:09:35 +0200
commitf0bc3aa8dfcaa334f15d547f1e77e1b94cb49cea (patch)
tree69ba2853fa71a31748f3338c4c9fb5edf1f556aa /src/plugins
parent1b1012f2990084ffc367ddb4aaf5910835bc4641 (diff)
Fix for QTMOBILITY-1772 VideoWidget example crash on windows
The surface format stride calculation in directshow backend is wrong which results in memory access violation. Change-Id: I80da5affc9a727513bad9c8d74a9f49d0c1a6c0d Task-number:QTMOBILITY-1772 Reviewed-by:Michael Goddard (cherry picked from commit 0b010e781634d3b33750fcead445fc7bd3a6f828) Reviewed-on: http://codereview.qt.nokia.com/2070 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Michael Goddard <michael.goddard@nokia.com>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/directshow/player/directshowmediatype.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/plugins/directshow/player/directshowmediatype.cpp b/src/plugins/directshow/player/directshowmediatype.cpp
index 9e65dc44e..ab901c547 100644
--- a/src/plugins/directshow/player/directshowmediatype.cpp
+++ b/src/plugins/directshow/player/directshowmediatype.cpp
@@ -153,6 +153,7 @@ QVideoSurfaceFormat DirectShowMediaType::formatFromType(const AM_MEDIA_TYPE &typ
return QVideoSurfaceFormat();
}
+#define PAD_TO_DWORD(x) (((x) + 3) & ~3)
int DirectShowMediaType::bytesPerLine(const QVideoSurfaceFormat &format)
{
switch (format.pixelFormat()) {
@@ -162,13 +163,13 @@ int DirectShowMediaType::bytesPerLine(const QVideoSurfaceFormat &format)
return format.frameWidth() * 4;
// 24 bpp packed formats.
case QVideoFrame::Format_RGB24:
- return format.frameWidth() * 3 + 3 - format.frameWidth() % 4;
+ return PAD_TO_DWORD(format.frameWidth() * 3);
// 16 bpp packed formats.
case QVideoFrame::Format_RGB565:
case QVideoFrame::Format_RGB555:
case QVideoFrame::Format_YUYV:
case QVideoFrame::Format_UYVY:
- return format.frameWidth() * 2 + 3 - format.frameWidth() % 4;
+ return PAD_TO_DWORD(format.frameWidth() * 2);
// Planar formats.
case QVideoFrame::Format_IMC1:
case QVideoFrame::Format_IMC2:
@@ -177,7 +178,7 @@ int DirectShowMediaType::bytesPerLine(const QVideoSurfaceFormat &format)
case QVideoFrame::Format_YV12:
case QVideoFrame::Format_NV12:
case QVideoFrame::Format_YUV420P:
- return format.frameWidth() + 3 - format.frameWidth() % 4;
+ return PAD_TO_DWORD(format.frameWidth());
default:
return 0;
}