aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsarbes <sarbes@kodi.tv>2024-07-02 15:01:45 +0200
committersarbes <sarbes@kodi.tv>2024-07-02 15:01:45 +0200
commit0a730dd0b30aab5d7990e55e0b08d5ab4c407b4b (patch)
tree295cb55322176bbcc274b9a1fc5ab8164d1a3ac9
parentfb90b04e8d65c929499157cc99ec23351db7c6ff (diff)
Upload XBT textures with right dimensions
-rw-r--r--xbmc/guilib/Texture.cpp16
-rw-r--r--xbmc/guilib/TextureBase.cpp14
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());