From a3e2e9efd4ed4baed3b5ca71cf518b3d3fda4716 Mon Sep 17 00:00:00 2001 From: Dmytro Poplavskiy Date: Fri, 12 Mar 2010 15:03:58 +1000 Subject: QPainterVideoSurface: assume yuv 420p and YV12 lines are 4 byte aligned. Reviewed-by: Andrew den Exter --- src/multimedia/base/qpaintervideosurface.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/multimedia/base/qpaintervideosurface.cpp b/src/multimedia/base/qpaintervideosurface.cpp index fc3d493..ed93fad 100644 --- a/src/multimedia/base/qpaintervideosurface.cpp +++ b/src/multimedia/base/qpaintervideosurface.cpp @@ -434,6 +434,9 @@ void QVideoSurfaceGLPainter::initRgbTextureInfo( void QVideoSurfaceGLPainter::initYuv420PTextureInfo(const QSize &size) { + int w = (size.width() + 3) & ~3; + int w2 = (size.width()/2 + 3) & ~3; + m_yuv = true; m_textureInternalFormat = GL_LUMINANCE; m_textureFormat = GL_LUMINANCE; @@ -444,14 +447,17 @@ void QVideoSurfaceGLPainter::initYuv420PTextureInfo(const QSize &size) m_textureOffsets[0] = 0; m_textureWidths[1] = size.width() / 2; m_textureHeights[1] = size.height() / 2; - m_textureOffsets[1] = size.width() * size.height(); + m_textureOffsets[1] = w * size.height(); m_textureWidths[2] = size.width() / 2; m_textureHeights[2] = size.height() / 2; - m_textureOffsets[2] = size.width() * size.height() * 5 / 4; + m_textureOffsets[2] = w * size.height() + w2 * (size.height() / 2); } void QVideoSurfaceGLPainter::initYv12TextureInfo(const QSize &size) { + int w = (size.width() + 3) & ~3; + int w2 = (size.width()/2 + 3) & ~3; + m_yuv = true; m_textureInternalFormat = GL_LUMINANCE; m_textureFormat = GL_LUMINANCE; @@ -462,10 +468,10 @@ void QVideoSurfaceGLPainter::initYv12TextureInfo(const QSize &size) m_textureOffsets[0] = 0; m_textureWidths[1] = size.width() / 2; m_textureHeights[1] = size.height() / 2; - m_textureOffsets[1] = size.width() * size.height() * 5 / 4; + m_textureOffsets[1] = w * size.height() + w2 * (size.height() / 2); m_textureWidths[2] = size.width() / 2; m_textureHeights[2] = size.height() / 2; - m_textureOffsets[2] = size.width() * size.height(); + m_textureOffsets[2] = w * size.height(); } #ifndef QT_OPENGL_ES -- cgit v0.12