Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[texturecache] cache images by default at a max of 720p, except for 1…

…080p fanart images which default to 1080p - can be changed by <fanartres> and <imageres> advancedsettings - these replace the previous <fanartheight> and <imagesize> tags.
  • Loading branch information...
commit 34f045a46b97099914ecd17f6fdd2e791c290b00 1 parent 392bf9c
Jonathan Marshall authored
View
13 xbmc/TextureCacheJob.cpp
@@ -97,12 +97,7 @@ bool CTextureCacheJob::CacheTexture(CBaseTexture **out_texture)
else
m_details.file = m_cachePath + ".jpg";
- if (width > 0 && height > 0)
- CLog::Log(LOGDEBUG, "%s image '%s' at %dx%d with orientation %d as '%s'", m_oldHash.IsEmpty() ? "Caching" : "Recaching", image.c_str(),
- width, height, texture->GetOrientation(), m_details.file.c_str());
- else
- CLog::Log(LOGDEBUG, "%s image '%s' fullsize with orientation %d as '%s'", m_oldHash.IsEmpty() ? "Caching" : "Recaching", image.c_str(),
- texture->GetOrientation(), m_details.file.c_str());
+ CLog::Log(LOGDEBUG, "%s image '%s' to '%s':", m_oldHash.IsEmpty() ? "Caching" : "Recaching", image.c_str(), m_details.file.c_str());
if (CPicture::CacheTexture(texture, width, height, CTextureCache::GetCachedPath(m_details.file)))
{
@@ -124,8 +119,8 @@ CStdString CTextureCacheJob::DecodeImageURL(const CStdString &url, unsigned int
// unwrap the URL as required
CStdString image(url);
additional_info.clear();
- width = g_advancedSettings.m_fanartHeight * 16/9;
- height = g_advancedSettings.m_fanartHeight;
+ width = g_advancedSettings.m_fanartRes * 16/9;
+ height = g_advancedSettings.m_fanartRes;
if (url.compare(0, 8, "image://") == 0)
{
// format is image://[type@]<url_encoded_path>?options
@@ -163,7 +158,7 @@ CStdString CTextureCacheJob::DecodeImageURL(const CStdString &url, unsigned int
}
if (option == "size" && value == "thumb")
{
- width = height = g_advancedSettings.m_thumbSize;
+ width = height = g_advancedSettings.GetThumbSize();
}
else if (option == "flipped")
{
View
4 xbmc/cores/dvdplayer/DVDFileInfo.cpp
@@ -219,11 +219,11 @@ bool CDVDFileInfo::ExtractThumb(const CStdString &strPath, CTextureDetails &deta
if (iDecoderState & VC_PICTURE && !(picture.iFlags & DVP_FLAG_DROPPED))
{
{
- unsigned int nWidth = g_advancedSettings.m_thumbSize;
+ unsigned int nWidth = g_advancedSettings.GetThumbSize();
double aspect = (double)picture.iDisplayWidth / (double)picture.iDisplayHeight;
if(hint.forced_aspect && hint.aspect != 0)
aspect = hint.aspect;
- unsigned int nHeight = (unsigned int)((double)g_advancedSettings.m_thumbSize / aspect);
+ unsigned int nHeight = (unsigned int)((double)g_advancedSettings.GetThumbSize() / aspect);
DllSwScale dllSwScale;
dllSwScale.Load();
View
30 xbmc/pictures/Picture.cpp
@@ -36,6 +36,7 @@ using namespace XFILE;
bool CPicture::CreateThumbnailFromSurface(const unsigned char *buffer, int width, int height, int stride, const CStdString &thumbFile)
{
+ CLog::Log(LOGDEBUG, "cached image '%s' size %dx%d", thumbFile.c_str(), width, height);
if (URIUtils::GetExtension(thumbFile).Equals(".jpg"))
{
CJpegIO jpegImage;
@@ -85,6 +86,19 @@ bool CPicture::CacheTexture(uint8_t *pixels, uint32_t width, uint32_t height, ui
if (dest_height == 0)
dest_height = height;
+ uint32_t max_height = g_advancedSettings.m_imageRes;
+ if (g_advancedSettings.m_fanartRes > g_advancedSettings.m_imageRes)
+ { // a separate fanart resolution is specified - check if the image is exactly equal to this res
+ if (width == g_advancedSettings.m_fanartRes * 16/9 && height == g_advancedSettings.m_fanartRes)
+ { // special case for fanart res
+ max_height = g_advancedSettings.m_fanartRes;
+ }
+ }
+ uint32_t max_width = max_height * 16/9;
+
+ dest_height = std::min(dest_height, max_height);
+ dest_width = std::min(dest_width, max_width);
+
if (width > dest_width || height > dest_height || orientation)
{
bool success = false;
@@ -125,12 +139,12 @@ bool CPicture::CreateTiledThumb(const std::vector<std::string> &files, const std
unsigned int num_across = (unsigned int)ceil(sqrt((float)files.size()));
unsigned int num_down = (files.size() + num_across - 1) / num_across;
- unsigned int tile_width = g_advancedSettings.m_thumbSize / num_across;
- unsigned int tile_height = g_advancedSettings.m_thumbSize / num_down;
- unsigned int tile_gap = std::max(1,g_advancedSettings.m_thumbSize / 512);
+ unsigned int tile_width = g_advancedSettings.GetThumbSize() / num_across;
+ unsigned int tile_height = g_advancedSettings.GetThumbSize() / num_down;
+ unsigned int tile_gap = 1;
// create a buffer for the resulting thumb
- uint32_t *buffer = (uint32_t *)calloc(g_advancedSettings.m_thumbSize * g_advancedSettings.m_thumbSize, 4);
+ uint32_t *buffer = (uint32_t *)calloc(g_advancedSettings.GetThumbSize() * g_advancedSettings.GetThumbSize(), 4);
for (unsigned int i = 0; i < files.size(); ++i)
{
int x = i % num_across;
@@ -152,12 +166,12 @@ bool CPicture::CreateTiledThumb(const std::vector<std::string> &files, const std
// drop into the texture
unsigned int posX = x*tile_width + (tile_width - width)/2;
unsigned int posY = y*tile_height + (tile_height - height)/2;
- uint32_t *dest = buffer + posX + posY*g_advancedSettings.m_thumbSize;
+ uint32_t *dest = buffer + posX + posY*g_advancedSettings.GetThumbSize();
uint32_t *src = scaled;
for (unsigned int y = 0; y < height; ++y)
{
memcpy(dest, src, width*4);
- dest += g_advancedSettings.m_thumbSize;
+ dest += g_advancedSettings.GetThumbSize();
src += width;
}
}
@@ -166,8 +180,8 @@ bool CPicture::CreateTiledThumb(const std::vector<std::string> &files, const std
}
}
// now save to a file
- bool ret = CreateThumbnailFromSurface((uint8_t *)buffer, g_advancedSettings.m_thumbSize, g_advancedSettings.m_thumbSize,
- g_advancedSettings.m_thumbSize * 4, thumb);
+ bool ret = CreateThumbnailFromSurface((uint8_t *)buffer, g_advancedSettings.GetThumbSize(), g_advancedSettings.GetThumbSize(),
+ g_advancedSettings.GetThumbSize() * 4, thumb);
free(buffer);
return ret;
}
View
4 xbmc/pictures/PictureThumbLoader.cpp
@@ -225,8 +225,8 @@ void CPictureThumbLoader::ProcessFoldersAndArchives(CFileItem *pItem)
{
CTextureDetails details;
details.file = relativeCacheFile;
- details.width = g_advancedSettings.m_thumbSize;
- details.height = g_advancedSettings.m_thumbSize;
+ details.width = g_advancedSettings.GetThumbSize();
+ details.height = g_advancedSettings.GetThumbSize();
CTextureCache::Get().AddCachedTexture(thumb, details);
db.SetTextureForPath(pItem->GetPath(), "thumb", thumb);
pItem->SetThumbnailImage(CTextureCache::GetCachedPath(relativeCacheFile));
View
8 xbmc/settings/AdvancedSettings.cpp
@@ -182,8 +182,8 @@ void CAdvancedSettings::Initialize()
m_playlistAsFolders = true;
m_detectAsUdf = false;
- m_thumbSize = DEFAULT_THUMB_SIZE;
- m_fanartHeight = DEFAULT_FANART_HEIGHT;
+ m_fanartRes = 1080;
+ m_imageRes = 720;
m_useDDSFanart = false;
m_sambaclienttimeout = 10;
@@ -879,8 +879,8 @@ void CAdvancedSettings::ParseSettingsFile(const CStdString &file)
XMLUtils::GetInt(pRootElement, "remotedelay", m_remoteDelay, 1, 20);
XMLUtils::GetFloat(pRootElement, "controllerdeadzone", m_controllerDeadzone, 0.0f, 1.0f);
- XMLUtils::GetInt(pRootElement, "thumbsize", m_thumbSize, 0, 1024);
- XMLUtils::GetInt(pRootElement, "fanartheight", m_fanartHeight, 0, 1080);
+ XMLUtils::GetInt(pRootElement, "fanartres", m_fanartRes, 0, 1080);
+ XMLUtils::GetInt(pRootElement, "imageres", m_imageRes, 0, 1080);
XMLUtils::GetBoolean(pRootElement, "useddsfanart", m_useDDSFanart);
XMLUtils::GetBoolean(pRootElement, "playlistasfolders", m_playlistAsFolders);
View
8 xbmc/settings/AdvancedSettings.h
@@ -204,8 +204,12 @@ class CAdvancedSettings
bool m_playlistAsFolders;
bool m_detectAsUdf;
- int m_thumbSize;
- int m_fanartHeight;
+ int m_fanartRes; ///< \brief the maximal resolution to cache fanart at (assumes 16x9)
+ int m_imageRes; ///< \brief the maximal resolution to cache images at (assumes 16x9)
+ /*! \brief the maximal size to cache thumbs at, assuming square
+ Used for actual thumbs (eg bookmark thumbs, picture thumbs) rather than cover art which uses m_imageRes instead
+ */
+ unsigned int GetThumbSize() const { return m_imageRes / 2; };
bool m_useDDSFanart;
int m_sambaclienttimeout;
View
3  xbmc/settings/Settings.h
@@ -33,18 +33,15 @@
#else
#define DEFAULT_SKIN "skin.confluence"
#endif
-#define DEFAULT_FANART_HEIGHT 0
#define DEFAULT_WEB_INTERFACE "webinterface.default"
#ifdef MID
#define DEFAULT_VSYNC VSYNC_DISABLED
-#define DEFAULT_THUMB_SIZE 256
#else // MID
#if defined(TARGET_DARWIN) || defined(_WIN32)
#define DEFAULT_VSYNC VSYNC_ALWAYS
#else
#define DEFAULT_VSYNC VSYNC_DRIVER
#endif
-#define DEFAULT_THUMB_SIZE 512
#endif // MID
#include "settings/VideoSettings.h"
View
2  xbmc/video/dialogs/GUIDialogVideoBookmarks.cpp
@@ -44,7 +44,7 @@
using namespace std;
-#define BOOKMARK_THUMB_WIDTH g_advancedSettings.m_thumbSize
+#define BOOKMARK_THUMB_WIDTH g_advancedSettings.GetThumbSize()
#define CONTROL_ADD_BOOKMARK 2
#define CONTROL_CLEAR_BOOKMARKS 3

0 comments on commit 34f045a

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