From 0a730dd0b30aab5d7990e55e0b08d5ab4c407b4b Mon Sep 17 00:00:00 2001 From: sarbes Date: Tue, 2 Jul 2024 15:01:45 +0200 Subject: Upload XBT textures with right dimensions --- xbmc/guilib/Texture.cpp | 16 +++++++++++++++- 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 5c2c01e22b..b0c3ce11b0 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()); -- cgit v1.2.3