当前位置: 首页>>代码示例>>C++>>正文


C++ Crc32类代码示例

本文整理汇总了C++中Crc32的典型用法代码示例。如果您正苦于以下问题:C++ Crc32类的具体用法?C++ Crc32怎么用?C++ Crc32使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Crc32类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Initialize

bool CSavestateWriter::Initialize(const CGameClient* gameClient, uint64_t frameHistoryCount)
{
  m_savestate.Reset();
  m_fps = 0.0;

  m_fps = gameClient->Timing().GetFrameRate();

  CDateTime now = CDateTime::GetCurrentDateTime();
  std::string label = now.GetAsLocalizedDateTime();

  m_savestate.SetType(SAVETYPE::MANUAL);
  m_savestate.SetLabel(label);
  m_savestate.SetGameClient(gameClient->ID());
  m_savestate.SetGamePath(gameClient->GetGamePath());
  m_savestate.SetTimestamp(now);
  m_savestate.SetPlaytimeFrames(frameHistoryCount);
  m_savestate.SetPlaytimeWallClock(frameHistoryCount / m_fps); //! @todo Accumulate playtime instead of deriving it

  //! @todo Get CRC from game data instead of filename
  Crc32 crc;
  crc.Compute(gameClient->GetGamePath());
  m_savestate.SetGameCRC(StringUtils::Format("%08x", (unsigned __int32)crc));

  m_savestate.SetPath(CSavestateUtils::MakePath(m_savestate));
  if (m_savestate.Path().empty())
    CLog::Log(LOGDEBUG, "Failed to calculate savestate path");

  if (m_fps == 0.0)
    return false; // Sanity check

  return !m_savestate.Path().empty();
}
开发者ID:Elzevir,项目名称:xbmc,代码行数:32,代码来源:SavestateWriter.cpp

示例2: TEST

TEST(TestCrc32, Compute_1)
{
    Crc32 a;
    uint32_t varcrc;
    a.Compute(refdata, sizeof(refdata) - 1);
    varcrc = a;
    EXPECT_EQ(0xa4eb60e3, varcrc);
}
开发者ID:nikkpap,项目名称:SPMC,代码行数:8,代码来源:TestCrc32.cpp

示例3: setHash

void NameKey::setHash()
 {
  Crc32 crc;

  for(auto cur=getCur(); cur.next() ;) crc.add(*cur);

  hash=crc;
 }
开发者ID:SergeyStrukov,项目名称:CCore-2-99,代码行数:8,代码来源:DDLMapTools.cpp

示例4: 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;
}
开发者ID:7orlum,项目名称:xbmc,代码行数:8,代码来源:TextureCache.cpp

示例5: getCacheThumbName

 String getCacheThumbName(const String& path)
 {
   TRACE;
   Crc32 crc;
   crc.ComputeFromLowerCase(path);
   CStdString strPath;
   strPath.Format("%08x.tbn", (unsigned __int32)crc);
   return strPath;
 }
开发者ID:AFFLUENTSOCIETY,项目名称:SPMC,代码行数:9,代码来源:ModuleXbmc.cpp

示例6: 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);
    }
开发者ID:Karlson2k,项目名称:xbmc,代码行数:57,代码来源:GUIDialogVideoBookmarks.cpp

示例7: 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);
      }
    }
  }  
}
开发者ID:Kr0nZ,项目名称:boxee,代码行数:56,代码来源:BackgroundInfoLoader.cpp

示例8: 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);
}
开发者ID:AWilco,项目名称:xbmc,代码行数:10,代码来源:TextureCache.cpp

示例9: 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;
}
开发者ID:tmacreturns,项目名称:XBMC_wireless_setup,代码行数:10,代码来源:TextureCache.cpp

示例10: 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();
}
开发者ID:AWilco,项目名称:xbmc,代码行数:55,代码来源:GUIDialogVideoBookmarks.cpp

示例11: sizeof

void ReadsLayout::save(ostream& out_bin)
{
    unsigned int crcCheck;
    Crc32 CRC;
  
    tabSize = R->getEffectiveNReads() + 1;
    
    CRC.AddData((uint8_t*) & tabSize, sizeof (unsigned int));
    CRC.AddData((uint8_t*) lastIdentical, sizeof (unsigned int) *tabSize);
    CRC.AddData((uint8_t*) next, sizeof (unsigned int) *tabSize);
    CRC.AddData((uint8_t*) previous, sizeof (unsigned int) *tabSize);
    CRC.AddData((uint8_t*) nodeId, sizeof (unsigned int) *tabSize);
    CRC.AddData((uint8_t*) position, sizeof (int) *tabSize);
    CRC.AddData((uint8_t*) flags, sizeof (unsigned char) *tabSize);

    crcCheck=CRC.GetCrc32();
    
    out_bin.write((char*) &crcCheck, sizeof (unsigned int));
      
    out_bin.write((char*) &tabSize, sizeof (unsigned int));
    out_bin.write((char*) lastIdentical, sizeof (unsigned int) *tabSize);
    out_bin.write((char*) next, sizeof (unsigned int) *tabSize);
    out_bin.write((char*) previous, sizeof (unsigned int) *tabSize);
    out_bin.write((char*) nodeId, sizeof (unsigned int) *tabSize);
    out_bin.write((char*) position, sizeof (int) *tabSize);
    out_bin.write((char*) flags, sizeof (unsigned char) *tabSize);
}
开发者ID:b-brankovics,项目名称:grabb,代码行数:27,代码来源:readsLayout.cpp

示例12: path

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);
}
开发者ID:JohnsonAugustine,项目名称:xbmc-rbp,代码行数:12,代码来源:VideoDatabaseDirectory.cpp

示例13: directory

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));
}
开发者ID:Avoidnf8,项目名称:xbmc-fork,代码行数:13,代码来源:MusicDatabaseDirectory.cpp

示例14: lock

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();
}
开发者ID:Kr0nZ,项目名称:boxee,代码行数:50,代码来源:GUIDialogVideoBookmarks.cpp

示例15: lock

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));
}
开发者ID:Openivo,项目名称:xbmc,代码行数:49,代码来源:LastFmManager.cpp


注:本文中的Crc32类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。