本文整理汇总了C++中Crc32::ComputeFromLowerCase方法的典型用法代码示例。如果您正苦于以下问题:C++ Crc32::ComputeFromLowerCase方法的具体用法?C++ Crc32::ComputeFromLowerCase怎么用?C++ Crc32::ComputeFromLowerCase使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Crc32
的用法示例。
在下文中一共展示了Crc32::ComputeFromLowerCase方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetCacheFile
CStdString CTextureCache::GetCacheFile(const CStdString &url)
{
Crc32 crc;
crc.ComputeFromLowerCase(url);
CStdString hex = StringUtils::Format("%08x", (unsigned int)crc);
CStdString hash = StringUtils::Format("%c/%s", hex[0], hex.c_str());
return hash;
}
示例2: AddBookmark
bool CGUIDialogVideoBookmarks::AddBookmark(CVideoInfoTag* tag)
{
CVideoDatabase videoDatabase;
CBookmark bookmark;
bookmark.timeInSeconds = (int)g_application.GetTime();
bookmark.totalTimeInSeconds = (int)g_application.GetTotalTime();
if( g_application.m_pPlayer->HasPlayer() )
bookmark.playerState = g_application.m_pPlayer->GetPlayerState();
else
bookmark.playerState.clear();
bookmark.player = CPlayerCoreFactory::GetInstance().GetPlayerName(g_application.GetCurrentPlayer());
// create the thumbnail image
#ifdef HAS_VIDEO_PLAYBACK
float aspectRatio = g_renderManager.GetAspectRatio();
#else
float aspectRatio = 1.0f;
#endif
int width = BOOKMARK_THUMB_WIDTH;
int height = (int)(BOOKMARK_THUMB_WIDTH / aspectRatio);
if (height > (int)BOOKMARK_THUMB_WIDTH)
{
height = BOOKMARK_THUMB_WIDTH;
width = (int)(BOOKMARK_THUMB_WIDTH * aspectRatio);
}
{
#ifdef HAS_VIDEO_PLAYBACK
CRenderCapture* thumbnail = g_renderManager.AllocRenderCapture();
if (thumbnail)
{
g_renderManager.Capture(thumbnail, width, height, CAPTUREFLAG_IMMEDIATELY);
#if !defined(HAS_LIBAMCODEC)
if (thumbnail->GetUserState() == CAPTURESTATE_DONE)
{
#else//HAS_LIBAMCODEC
{
CScreenshotAML::CaptureVideoFrame(thumbnail->GetPixels(), width, height, false);
#endif
Crc32 crc;
crc.ComputeFromLowerCase(g_application.CurrentFile());
bookmark.thumbNailImage = StringUtils::Format("%08x_%i.jpg", (unsigned __int32) crc, (int)bookmark.timeInSeconds);
bookmark.thumbNailImage = URIUtils::AddFileToFolder(CProfilesManager::GetInstance().GetBookmarksThumbFolder(), bookmark.thumbNailImage);
if (!CPicture::CreateThumbnailFromSurface(thumbnail->GetPixels(), width, height, thumbnail->GetWidth() * 4,
bookmark.thumbNailImage))
bookmark.thumbNailImage.clear();
}
#if !defined(HAS_LIBAMCODEC)
else
CLog::Log(LOGERROR,"CGUIDialogVideoBookmarks: failed to create thumbnail");
#endif
g_renderManager.ReleaseRenderCapture(thumbnail);
}
示例3:
TEST(TestCrc32, ComputeFromLowerCase)
{
Crc32 a;
uint32_t varcrc;
CStdString s = refdata;
a.ComputeFromLowerCase(s);
varcrc = a;
EXPECT_EQ((uint32_t)0x7f045b3e, varcrc);
}
示例4: getCacheThumbName
String getCacheThumbName(const String& path)
{
TRACE;
Crc32 crc;
crc.ComputeFromLowerCase(path);
CStdString strPath;
strPath.Format("%08x.tbn", (unsigned __int32)crc);
return strPath;
}
示例5: LoadCustomImages
void CBackgroundInfoLoader::LoadCustomImages(CFileItem* pItem, bool bCanBlock)
{
//CLog::Log(LOGDEBUG,"CBackgroundInfoLoader::LoadCustomImages - Enter function with item [path=%s][label=%s]. [bCanBlock=%d] (custi)",(pItem->m_strPath).c_str(),(pItem->GetLabel()).c_str(),bCanBlock);
for (int nImage=0; nImage < 10; nImage++)
{
CStdString strPropName;
strPropName.Format("Image%d", nImage);
if (!pItem->HasProperty(strPropName))
{
break;
}
CStdString strImagePath = pItem->GetProperty(strPropName);
//CLog::Log(LOGDEBUG,"CBackgroundInfoLoader::LoadCustomImages - [%d] Going to try and download property [%s] value [ImagePath=%s] for item [path=%s][label=%s]. [bCanBlock=%d] (custi)",nImage,strPropName.c_str(),strImagePath.c_str(),(pItem->m_strPath).c_str(),(pItem->GetLabel()).c_str(),bCanBlock);
// Get path for cache picture
Crc32 crc;
crc.ComputeFromLowerCase(strImagePath);
CStdString hex;
hex.Format("%08x", (unsigned __int32) crc);
CStdString cacheImagePath;
cacheImagePath.Format("%s\\%c\\%s_image.tbn", g_settings.GetPicturesThumbFolder().c_str(), hex[0], hex.c_str());
cacheImagePath = _P(cacheImagePath);
//CLog::Log(LOGDEBUG,"CBackgroundInfoLoader::LoadCustomImages - [%d] For image [ImagePath=%s] the cacheImagePath is [%s]. Item [path=%s][label=%s]. [bCanBlock=%d] (custi)",nImage,strImagePath.c_str(),cacheImagePath.c_str(),(pItem->m_strPath).c_str(),(pItem->GetLabel()).c_str(),bCanBlock);
if(CFile::Exists(cacheImagePath))
{
// Picture exist in cache
pItem->SetProperty(strPropName, cacheImagePath);
//CLog::Log(LOGDEBUG,"CBackgroundInfoLoader::LoadCustomImages - [%d] cacheImagePath [%s] already exist and was set to property [%s=%s]. item [path=%s][label=%s]. [bCanBlock=%d] (custi)",nImage,cacheImagePath.c_str(),strPropName.c_str(),(pItem->GetProperty(strPropName)).c_str(),(pItem->m_strPath).c_str(),(pItem->GetLabel()).c_str(),bCanBlock);
}
else
{
// Picture doesn't exist in cache -> Need to download it
BOXEE::BXCurl http;
bool success = http.HttpDownloadFile(strImagePath,cacheImagePath,"");
if(success)
{
pItem->SetProperty(strPropName, cacheImagePath);
//CLog::Log(LOGDEBUG,"CBackgroundInfoLoader::LoadCustomImages - [%d] successed downloading image. cacheImagePath [%s] was set to property [%s=%s]. item [path=%s][label=%s]. [bCanBlock=%d] (custi)",nImage,cacheImagePath.c_str(),strPropName.c_str(),(pItem->GetProperty(strPropName)).c_str(),(pItem->m_strPath).c_str(),(pItem->GetLabel()).c_str(),bCanBlock);
}
else
{
CLog::Log(LOGERROR,"CBackgroundInfoLoader::LoadCustomImages - [%d] Failed to download [ImagePath=%s] for item [path=%s][label=%s]. [bCanBlock=%d] (pthumb)(custi)",nImage,strImagePath.c_str(),(pItem->m_strPath).c_str(),(pItem->GetLabel()).c_str(),bCanBlock);
}
}
}
}
示例6: GetUniqueImage
CStdString CTextureCache::GetUniqueImage(const CStdString &url, const CStdString &extension)
{
Crc32 crc;
crc.ComputeFromLowerCase(url);
CStdString hex;
hex.Format("%08x", (unsigned int)crc);
CStdString hash;
hash.Format("generated/%c/%s%s", hex[0], hex.c_str(), extension.c_str());
return GetCachedPath(hash);
}
示例7: GetCacheFile
CStdString CTextureCache::GetCacheFile(const CStdString &url)
{
Crc32 crc;
crc.ComputeFromLowerCase(url);
CStdString hex;
hex.Format("%08x", (unsigned int)crc);
CStdString hash;
hash.Format("%c/%s%s", hex[0], hex.c_str(), CUtil::GetExtension(url).c_str());
return hash;
}
示例8: AddBookmark
void CGUIDialogVideoBookmarks::AddBookmark(CVideoInfoTag* tag)
{
CVideoDatabase videoDatabase;
CBookmark bookmark;
bookmark.timeInSeconds = (int)g_application.GetTime();
bookmark.totalTimeInSeconds = (int)g_application.GetTotalTime();
if( g_application.m_pPlayer )
bookmark.playerState = g_application.m_pPlayer->GetPlayerState();
else
bookmark.playerState.Empty();
bookmark.player = CPlayerCoreFactory::GetPlayerName(g_application.GetCurrentPlayer());
// create the thumbnail image
#ifdef HAS_VIDEO_PLAYBACK
float aspectRatio = g_renderManager.GetAspectRatio();
#else
float aspectRatio = 1.0f;
#endif
int width = BOOKMARK_THUMB_WIDTH;
int height = (int)(BOOKMARK_THUMB_WIDTH / aspectRatio);
if (height > BOOKMARK_THUMB_WIDTH)
{
height = BOOKMARK_THUMB_WIDTH;
width = (int)(BOOKMARK_THUMB_WIDTH * aspectRatio);
}
{
#ifdef HAS_VIDEO_PLAYBACK
CRenderCapture* thumbnail = g_renderManager.AllocRenderCapture();
g_renderManager.Capture(thumbnail, width, height, CAPTUREFLAG_IMMEDIATELY);
if (thumbnail->GetUserState() == CAPTURESTATE_DONE)
{
Crc32 crc;
crc.ComputeFromLowerCase(g_application.CurrentFile());
bookmark.thumbNailImage.Format("%08x_%i.jpg", (unsigned __int32) crc, m_vecItems->Size() + 1);
bookmark.thumbNailImage = URIUtils::AddFileToFolder(g_settings.GetBookmarksThumbFolder(), bookmark.thumbNailImage);
if (!CPicture::CreateThumbnailFromSurface(thumbnail->GetPixels(), width, height, thumbnail->GetWidth() * 4,
bookmark.thumbNailImage))
bookmark.thumbNailImage.Empty();
}
else
CLog::Log(LOGERROR,"CGUIDialogVideoBookmarks: failed to create thumbnail");
g_renderManager.ReleaseRenderCapture(thumbnail);
#endif
}
videoDatabase.Open();
if (tag)
videoDatabase.AddBookMarkForEpisode(*tag, bookmark);
else
videoDatabase.AddBookMarkToFile(g_application.CurrentFile(), bookmark, CBookmark::STANDARD);
videoDatabase.Close();
Update();
}
示例9: ClearDirectoryCache
void CVideoDatabaseDirectory::ClearDirectoryCache(const CStdString& strDirectory)
{
CStdString path(strDirectory);
URIUtils::RemoveSlashAtEnd(path);
Crc32 crc;
crc.ComputeFromLowerCase(path);
CStdString strFileName;
strFileName.Format("special://temp/%08x.fi", (unsigned __int32) crc);
CFile::Delete(strFileName);
}
示例10: ClearDirectoryCache
void CMusicDatabaseDirectory::ClearDirectoryCache(const CStdString& strDirectory)
{
CFileItem directory(strDirectory, true);
if (CUtil::HasSlashAtEnd(directory.m_strPath))
directory.m_strPath.Delete(directory.m_strPath.size() - 1);
Crc32 crc;
crc.ComputeFromLowerCase(directory.m_strPath);
CStdString strFileName;
strFileName.Format("Z:\\%08x.fi", (unsigned __int32) crc);
CFile::Delete(_P(strFileName));
}
示例11: AddBookmark
void CGUIDialogVideoBookmarks::AddBookmark(CVideoInfoTag* tag)
{
CVideoDatabase videoDatabase;
CBookmark bookmark;
bookmark.timeInSeconds = (int)g_application.GetTime();
bookmark.totalTimeInSeconds = (int)g_application.GetTotalTime();
if( g_application.m_pPlayer )
bookmark.playerState = g_application.m_pPlayer->GetPlayerState();
else
bookmark.playerState.Empty();
bookmark.player = CPlayerCoreFactory::GetPlayerName(g_application.GetCurrentPlayer());
// create the thumbnail image
#ifdef HAS_VIDEO_PLAYBACK
float aspectRatio = g_renderManager.GetAspectRatio();
#else
float aspectRatio = 1.0f;
#endif
int width = BOOKMARK_THUMB_WIDTH;
int height = (int)(BOOKMARK_THUMB_WIDTH / aspectRatio);
if (height > BOOKMARK_THUMB_WIDTH)
{
height = BOOKMARK_THUMB_WIDTH;
width = (int)(BOOKMARK_THUMB_WIDTH * aspectRatio);
}
{
CSingleLock lock(g_graphicsContext);
// we're really just using the CTexture here as a pixel buffer
CTexture texture(width, height, XB_FMT_B8G8R8A8);
#ifdef HAS_VIDEO_PLAYBACK
//g_renderManager.CreateThumbnail(&texture, width, height);
#endif
Crc32 crc;
crc.ComputeFromLowerCase(g_application.CurrentFile());
bookmark.thumbNailImage.Format("%08x_%i.jpg", (unsigned __int32) crc, m_vecItems->Size() + 1);
bookmark.thumbNailImage = CUtil::AddFileToFolder(g_settings.GetBookmarksThumbFolder(), bookmark.thumbNailImage);
if (!CPicture::CreateThumbnailFromSurface(texture.GetPixels(), width, height, texture.GetPitch(),
bookmark.thumbNailImage))
bookmark.thumbNailImage.Empty();
}
videoDatabase.Open();
if (tag)
videoDatabase.AddBookMarkForEpisode(*tag, bookmark);
else
videoDatabase.AddBookMarkToFile(g_application.CurrentFile(), bookmark, CBookmark::STANDARD);
videoDatabase.Close();
Update();
}
示例12: CacheTrackThumb
void CLastFmManager::CacheTrackThumb(const int nrInitialTracksToAdd)
{
unsigned int start = CTimeUtils::GetTimeMS();
CSingleLock lock(m_lockCache);
int iNrCachedTracks = m_RadioTrackQueue->size();
CFileCurl http;
for (int i = 0; i < nrInitialTracksToAdd && i < iNrCachedTracks; i++)
{
CFileItemPtr item = (*m_RadioTrackQueue)[i];
if (!item->GetMusicInfoTag()->Loaded())
{
//cache albumthumb, GetThumbnailImage contains the url to cache
if (item->HasThumbnail())
{
CStdString coverUrl = item->GetThumbnailImage();
CStdString crcFile;
CStdString cachedFile;
CStdString thumbFile;
Crc32 crc;
crc.ComputeFromLowerCase(coverUrl);
crcFile.Format("%08x.tbn", (__int32)crc);
URIUtils::AddFileToFolder(g_advancedSettings.m_cachePath, crcFile, cachedFile);
URIUtils::AddFileToFolder(g_settings.GetLastFMThumbFolder(), crcFile, thumbFile);
item->SetThumbnailImage("");
try
{
//download to temp, then make a thumb
if (CFile::Exists(thumbFile) || (http.Download(coverUrl, cachedFile) && CPicture::CreateThumbnail(cachedFile, thumbFile)))
{
if (CFile::Exists(cachedFile))
CFile::Delete(cachedFile);
item->SetThumbnailImage(thumbFile);
}
}
catch(...)
{
CLog::Log(LOGERROR, "LastFmManager: exception while caching %s to %s.", coverUrl.c_str(), thumbFile.c_str());
}
}
if (!item->HasThumbnail())
{
item->SetThumbnailImage("DefaultAlbumCover.png");
}
item->GetMusicInfoTag()->SetLoaded();
}
}
CLog::Log(LOGDEBUG, "%s: Done (time: %i ms)", __FUNCTION__, (int)(CTimeUtils::GetTimeMS() - start));
}
示例13: get_cache_thumb_name
char* Interface_Filesystem::get_cache_thumb_name(void* kodiBase, const char* filename)
{
CAddonDll* addon = static_cast<CAddonDll*>(kodiBase);
if (addon == nullptr || filename == nullptr)
{
CLog::Log(LOGERROR, "Interface_Filesystem::%s - invalid data (addon='%p', filename='%p)", __FUNCTION__, kodiBase, filename);
return nullptr;
}
Crc32 crc;
crc.ComputeFromLowerCase(filename);
std::string string = StringUtils::Format("%08x.tbn", static_cast<unsigned int>(crc));
char* buffer = strdup(string.c_str());
return buffer;
}
示例14: GetThumb
CStdString CEdenVideoArtUpdater::GetThumb(const CStdString &path, const CStdString &path2, bool split)
{
// get the locally cached thumb
Crc32 crc;
crc.ComputeFromLowerCase(path);
CStdString thumb;
if (split)
{
CStdString hex = StringUtils::Format("%08x", (__int32)crc);
thumb = StringUtils::Format("%c\\%08x.tbn", hex[0], (unsigned __int32)crc);
}
else
thumb = StringUtils::Format("%08x.tbn", (unsigned __int32)crc);
return URIUtils::AddFileToFolder(path2, thumb);
}
示例15: GetDirectory
bool CRSSDirectory::GetDirectory(const CStdString& strPath, CFileItemList &items)
{
CLog::Log(LOGDEBUG,"CRSSDirectory::GetDirectory - path [%s]", strPath.c_str());
m_cacheDirectory = DIR_CACHE_ALWAYS;
CStdString strURL = strPath;
CStdString newURL;
CStdString strRoot = strPath;
if (CUtil::HasSlashAtEnd(strRoot))
strRoot.Delete(strRoot.size() - 1);
// If we have the items in the cache, return them
if (g_directoryCache.GetDirectory(strRoot, items))
{
return true;
}
// Remove the rss:// prefix and replace it with http://
if (strURL.Left(7) == "http://")
{
newURL = strURL;
}
else
{
strURL.Delete(0,6);
// if first symbol is '/', we have local file
if (strURL.Left(1) == "/")
{
newURL = "file://";
}
else
{
newURL = "http://";
}
newURL = newURL + strURL;
}
// Remove the last slash
if (CUtil::HasSlashAtEnd(newURL))
{
CUtil::RemoveSlashAtEnd(newURL);
}
// Create new thread and run the feed retreival from it
// In order to allow progress dialog and cancel operation
m_strUrl = newURL;
Crc32 crc;
crc.ComputeFromLowerCase(newURL);
CStdString strLocalFile;
strLocalFile.Format("special://temp/rss-%08x-%lu.xml", (unsigned __int32)crc, CTimeUtils::GetTimeMS());
CLog::Log(LOGDEBUG,"CRSSDirectory::GetDirectory - going to load url [%s] to file [%s]", newURL.c_str(), strLocalFile.c_str());
if (!BOXEE::Boxee::GetInstance().AsyncLoadUrl(newURL, _P(strLocalFile), "rss-load", NULL))
{
CGUIDialogOK::ShowAndGetInput(51014,0,0,0);
return false;
}
SDL_LockMutex(m_pOpFinishedMutex);
int result = SDL_CondWaitTimeout(m_pOpFinishedCond,m_pOpFinishedMutex,REQUEST_WAIT_PERIOD);
SDL_UnlockMutex(m_pOpFinishedMutex);
m_feed.GetItemList(items);
if (result != 0)
{
m_cacheDirectory = DIR_CACHE_NEVER;
// set this property so that the UI will handle the timeout
CLog::Log(LOGDEBUG,"CRSSDirectory::GetDirectory, loading timed out, path [%s] loaded:%d out of %d", strPath.c_str(), items.Size(),items.GetPageContext().m_itemsPerPage);
items.SetProperty("isRequestTimedOut",true);
}
CLog::Log(LOGDEBUG,"CRSSDirectory::GetDirectory - done loading url, got [%d] items (result=[%d])",items.Size(),result);
if (items.Size() == 0)
{
m_cacheDirectory = DIR_CACHE_NEVER;
return true;
}
else
{
CLog::Log(LOGDEBUG,"CRSSDirectory::GetDirectory - Going to add [DefaultSortLabel] property to each item. [path=%s][NumOfItems=%d] (vns)",strPath.c_str(),items.Size());
for(int i=0; i<items.Size(); i++)
{
CFileItemPtr item = items[i];
char pos[5];
sprintf(pos,"%d",i+1);
item->SetProperty("DefaultSortLabel",pos);
//CLog::Log(LOGDEBUG,"CRSSDirectory::GetDirectory - For item [path=%s] set property [DefaultSortLabel=%s] (vns)", (item->m_strPath).c_str(),(item->GetProperty("DefaultSortLabel")).c_str());
//.........这里部分代码省略.........