[fix] ffmpeg uses a 16-byte stride when scaling images, which can overrun the texture...
authornight199uk <night199uk@xbmc.org>
Mon, 22 Jul 2013 09:52:22 +0000 (17:52 +0800)
committernight199uk <night199uk@xbmc.org>
Mon, 22 Jul 2013 09:52:22 +0000 (17:52 +0800)
xbmc/guilib/Texture.cpp

index 3b46d0f..0f5edee 100644 (file)
@@ -87,7 +87,11 @@ void CBaseTexture::Allocate(unsigned int width, unsigned int height, unsigned in
     // we crash in CPicture::ScaleImage in ffmpegs swscale
     // because it tries to access beyond the source memory
     // (happens on osx and ios)
-    m_textureWidth = ((m_textureWidth + 1) / 2) * 2;
+    // UPDATE: don't just update to be on an even width;
+    // ffmpegs swscale relies on a 16-byte stride on some systems
+    // so the textureWidth needs to be a multiple of 16. see ffmpeg
+    // swscale headers for more info.
+    m_textureWidth = ((m_textureWidth + 15) / 16) * 16;
   }
 
   // check for max texture size