diff options
author | sarbes <sarbes@kodi.tv> | 2024-07-12 20:53:14 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-12 20:53:14 +0200 |
commit | 21f0ace914b9ef22a86922161e95ede511d6fc06 (patch) | |
tree | 6a8ae776531ce6b52507137be81cc84fb1caf143 | |
parent | 1bf14a063e9a70f0bcef2ef80825937991786d5f (diff) | |
parent | 0a730dd0b30aab5d7990e55e0b08d5ab4c407b4b (diff) |
Upload XBT textures with right dimensions
-rw-r--r-- | xbmc/guilib/Texture.cpp | 16 | ||||
-rw-r--r-- | xbmc/guilib/TextureBase.cpp | 14 |
2 files changed, 15 insertions, 15 deletions
diff --git a/xbmc/guilib/Texture.cpp b/xbmc/guilib/Texture.cpp index 91b9db90d3..31a6029636 100644 --- a/xbmc/guilib/Texture.cpp +++ b/xbmc/guilib/Texture.cpp @@ -246,7 +246,21 @@ bool CTexture::LoadIImage(IImage* pImage, if (pImage->Width() == 0 || pImage->Height() == 0) return false; - Allocate(pImage->Width(), pImage->Height(), XB_FMT_A8R8G8B8); + // align all textures so that they have an even width + // in some circumstances when we downsize a thumbnail + // which has an uneven number of pixels in width + // we crash in CPicture::ScaleImage in ffmpegs swscale + // because it tries to access beyond the source memory + // (happens on osx and ios) + // 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. + unsigned int textureWidth = ((pImage->Width() + 15) / 16) * 16; + + Allocate(textureWidth, pImage->Height(), XB_FMT_A8R8G8B8); + + m_imageWidth = std::min(m_imageWidth, textureWidth); if (m_pixels == nullptr) return false; diff --git a/xbmc/guilib/TextureBase.cpp b/xbmc/guilib/TextureBase.cpp index 63c510ff94..3d2ea6e760 100644 --- a/xbmc/guilib/TextureBase.cpp +++ b/xbmc/guilib/TextureBase.cpp @@ -45,20 +45,6 @@ void CTextureBase::Allocate(uint32_t width, uint32_t height, XB_FMT format) m_textureWidth = ((m_textureWidth + 3) / 4) * 4; m_textureHeight = ((m_textureHeight + 3) / 4) * 4; } - else - { - // align all textures so that they have an even width - // in some circumstances when we downsize a thumbnail - // which has an uneven number of pixels in width - // we crash in CPicture::ScaleImage in ffmpegs swscale - // because it tries to access beyond the source memory - // (happens on osx and ios) - // 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 m_textureWidth = std::min(m_textureWidth, CServiceBroker::GetRenderSystem()->GetMaxTextureSize()); |