Skip to content
This repository
Browse code

[fix] ffmpeg uses a 16-byte stride when scaling images, which can ove…

…rrun the texture buffer which is only 2-byte aligned, causing a segfault on OSX/iOS
  • Loading branch information...
commit 2a3ad143576fe3cdfb869126258e5f041f6794a1 1 parent 37f3554
night199uk authored July 22, 2013

Showing 1 changed file with 5 additions and 1 deletion. Show diff stats Hide diff stats

  1. 6  xbmc/guilib/Texture.cpp
6  xbmc/guilib/Texture.cpp
@@ -87,7 +87,11 @@ void CBaseTexture::Allocate(unsigned int width, unsigned int height, unsigned in
87 87
     // we crash in CPicture::ScaleImage in ffmpegs swscale
88 88
     // because it tries to access beyond the source memory
89 89
     // (happens on osx and ios)
90  
-    m_textureWidth = ((m_textureWidth + 1) / 2) * 2;
  90
+    // UPDATE: don't just update to be on an even width;
  91
+    // ffmpegs swscale relies on a 16-byte stride on some systems
  92
+    // so the textureWidth needs to be a multiple of 16. see ffmpeg
  93
+    // swscale headers for more info.
  94
+    m_textureWidth = ((m_textureWidth + 15) / 16) * 16;
91 95
   }
92 96
 
93 97
   // check for max texture size

1 note on commit 2a3ad14

Memphiz
Owner

awesome catch - thx - this should fix software rendering on those systems :)

Please sign in to comment.
Something went wrong with that request. Please try again.