xboxscene.org forums

Author Topic: Xbe Style Thumbnails (.tbn) For Shortcut (.cut) Files  (Read 130 times)

Ez0n3

  • Archived User
  • Jr. Member
  • *
  • Posts: 64
Xbe Style Thumbnails (.tbn) For Shortcut (.cut) Files
« on: March 14, 2009, 01:30:00 AM »

Sup,

If you have allot of cut files with thumbnails and can't stand how painfully slow it is browsing through them and have the ability to compile your own XBMC build, you might want to give this a try.

Using this source (any should work): XBMC_for_Xbox-8.10.src.tar.gz

And these instructions: HOW-TO compile XBMC for Xbox from source code

You can comment out a few lines of code and compile yourself a build that will allow .tbn style thumbnails for .cut files instead of using "<" thumb ">" embedded in the cut.

For this cut named "Some Program.cut":
CODE

    E:\Apps\Some Program\default.xbe
    
    E:\Apps\Some Program\Some Program.jpg
    
        E:\Apps\Some Program\CMDSomething.ext
    



I would remove the thumb tag and its parameter completely. Then copy "Some Program.jpg" to the same directory as the cut file and rename it to "Some Program.tbn". Because a thumb isn't defined in the cut and a thumb file with the same name using the tbn extension exists, it will use the tbn file as the thumb and cache it. biggrin.gif

EG:
E:\Programs\Some Program.tbn
E:\Programs\Some Program.cut
CODE

    E:\Apps\Some Program\default.xbe
    
    
        E:\Apps\Some Program\CMDSomething.ext
    



As an example, I put 1,000 cuts in a folder using the embedded thumb tag:
:: Takes about 10-20sec before it displays anything in the folder (every time).
:: Scrolling through them is a nightmare. Chug, chug, chug (every time).
:: Takes like 15min to scroll through them all.

Using the tbn method:
:: Takes 5-10sec before it displays anything in the folder
:: It caches all the thumbs in about 30sec the first time through only, after that they just pop right in.
:: Once cached, scrolling through is silky smooth from then on.
:: Takes like 15sec to scroll through them all.

Instead of chug, chug, chug - it's normal, faster, even faster - woot! ohmy.gif

To do it, you need to modify two files in the source:
..\XBMC_Source_Path\xbmc\FileItem.cpp
..\XBMC_Source_Path\xbmc\GUIWindowPrograms.cpp

In FileItem.cpp (CFileItem::SetUserProgramThumb) around line 2540 change these lines and comment out the lower return:
CODE
  if (IsShortCut())
  {
    CShortcut shortcut;
    if ( shortcut.Create( m_strPath ) )
    {
      // use the shortcut's thumb
      if (!shortcut.m_strThumb.IsEmpty())
      { //Ez0n3 <-- add a open curly here

        m_strThumbnailImage = shortcut.m_strThumb;

        //Ez0n3 - return here if cut has an embedded , quit and use it
        return;

      } //Ez0n3 <-- add a close curly here
      else
      {
        CFileItem item(shortcut.m_strPath,false);
        item.SetUserProgramThumb();
        m_strThumbnailImage = item.m_strThumbnailImage;
      }
      
      //Ez0n3 - don't return here so that it will find and cache the tbn file
      //return;
    }
  }


In GUIWindowPrograms.cpp (CGUIWindowPrograms::GetDirectory) around line 730 comment out the 3 lines:
CODE
    else if (item->IsShortCut())
    { // resolve the shortcut to set it's description etc.
      // and save the old shortcut path (so we can reassign it later)
      CShortcut cut;
      if (cut.Create(item->m_strPath))
      {
        shortcutPath = item->m_strPath;
        item->m_strPath = cut.m_strPath;
        
        //Ez0n3 - xbox specific (missing from win32 source) - prevents tbn file usage for cuts
        //if (cut.m_strThumb.IsEmpty()) // try to cache thumb for path
        //  item->SetUserProgramThumb();
        //else
        
          item->SetThumbnailImage(cut.m_strThumb);

        LABEL_MASKS labelMasks;
        m_guiState->GetSortMethodLabelMasks(labelMasks);
        CLabelFormatter formatter("", labelMasks.m_strLabel2File);
        if (!cut.m_strLabel.IsEmpty())
        {
          item->SetLabel(cut.m_strLabel);
          __stat64 stat;
          if (CFile::Stat(item->m_strPath,&stat) == 0)
            item->m_dwSize = stat.st_size;

          formatter.FormatLabel2(item.get());
          item->SetLabelPreformated(true);
        }
      }
    }


Build and enjoy the massive cut file performance increase! biggrin.gif

PS: I would test the build out before replacing the dash, just to be sure. Just run it like you would run any other program.

Let me know if you have any issues, still testing - but loving every second.
Logged

Ez0n3

  • Archived User
  • Jr. Member
  • *
  • Posts: 64
Xbe Style Thumbnails (.tbn) For Shortcut (.cut) Files
« Reply #1 on: March 16, 2009, 01:55:00 AM »

The above code is fine if you have less than 4,096 Program thumbs to cache. But if you have more, you'll have to make the Program thumbs function like that of Music, Pictures, Videos - using sub folders based on the path+file crc (0-9 and a-f sub folders) to overcome the fatx limit.

In FileItem.cpp (same file from fist post) (CFileItem::GetCachedProgramThumb) around line 2456 change these lines:
CODE
CStdString CFileItem::GetCachedProgramThumb() const
{
  // get the locally cached thumb
  Crc32 crc;
  if (IsOnDVD())
  {
    CStdString strDesc;
    CUtil::GetXBEDescription(m_strPath,strDesc);
    CStdString strCRC;
    strCRC.Format("%s%u",strDesc.c_str(),CUtil::GetXbeID(m_strPath));
    crc.ComputeFromLowerCase(strCRC);
  }
  else
    crc.ComputeFromLowerCase(m_strPath);
    
  //Ez0n3 - get path+file crc to string for first character
  CStdString hex;
  hex.Format("%08x", (__int32)crc);
    
  CStdString thumb;

  //Ez0n3 - use first character as the sub folder
  //thumb.Format("%s\\%08x.tbn", g_settings.GetProgramsThumbFolder().c_str(), (unsigned __int32)crc);
  thumb.Format("%s\\%c\\%08x.tbn", g_settings.GetProgramsThumbFolder().c_str(), hex[0], (unsigned __int32)crc);
  
  return thumb;
}


In Settings.cpp (CSettings::CreateProfileFolders) around line 2872 add these lines:
CODE
void CSettings::CreateProfileFolders()
{
  CreateDirectory(GetDatabaseFolder(), NULL);
  CreateDirectory(GetCDDBFolder().c_str(), NULL);

  // Thumbnails/
  CreateDirectory(GetThumbnailsFolder().c_str(), NULL);
  CreateDirectory(GetMusicThumbFolder().c_str(), NULL);
  CreateDirectory(GetMusicArtistThumbFolder().c_str(), NULL);
  CreateDirectory(GetLastFMThumbFolder().c_str(), NULL);
  CreateDirectory(GetVideoThumbFolder().c_str(), NULL);
  CreateDirectory(GetVideoFanartFolder().c_str(), NULL);
  CreateDirectory(GetBookmarksThumbFolder().c_str(), NULL);
  CreateDirectory(GetProgramsThumbFolder().c_str(), NULL);
  CreateDirectory(GetPicturesThumbFolder().c_str(), NULL);
  CLog::Log(LOGINFO, "  thumbnails folder:%s", GetThumbnailsFolder().c_str());
  for (unsigned int hex=0; hex < 16; hex++)
  {
    CStdString strHex;
    strHex.Format("%x",hex);
    CStdString strThumbLoc;
    CUtil::AddFileToFolder(GetPicturesThumbFolder(), strHex, strThumbLoc);
    CreateDirectory(strThumbLoc.c_str(),NULL);
    CUtil::AddFileToFolder(GetMusicThumbFolder(), strHex, strThumbLoc);
    CreateDirectory(strThumbLoc.c_str(),NULL);
    CUtil::AddFileToFolder(GetVideoThumbFolder(), strHex, strThumbLoc);
    CreateDirectory(strThumbLoc.c_str(),NULL);
    
    //Ez0n3 - create the program thumbs sub folders
    CUtil::AddFileToFolder(GetProgramsThumbFolder(), strHex, strThumbLoc);
    CreateDirectory(strThumbLoc.c_str(),NULL);
  }
}


I just tested it on 7,900 cuts and it worked like a charm.  (IMG:style_emoticons/default/love.gif)

Edit:
Forgot to say 7,900 thumbs roughly 500x500 (around 800MB) cached out at 192x192 was only around 128MB. I upped it to 256x256 using "../UserData/AdvancedSettings.xml" and it was still very smooth, could probably go even more without too much impact:
CODE

256


This post has been edited by Ez0n3: Mar 16 2009, 09:04 AM
Logged

Bomb Bloke

  • Archived User
  • Hero Member
  • *
  • Posts: 2398
Xbe Style Thumbnails (.tbn) For Shortcut (.cut) Files
« Reply #2 on: March 16, 2009, 02:25:00 AM »

With standard thumbnail setups, once the things are cached you can wipe the originals and save the drive space. I assume the same thing stands here?
Logged

Ez0n3

  • Archived User
  • Jr. Member
  • *
  • Posts: 64
Xbe Style Thumbnails (.tbn) For Shortcut (.cut) Files
« Reply #3 on: March 16, 2009, 02:40:00 AM »

QUOTE
With standard thumbnail setups, once the things are cached you can wipe the originals and save the drive space. I assume the same thing stands here?

Do you mean delete everything in "../UserData/Thumbnails/Programs/" and start over? If so, yes.

After comparing the source, the only thing I saw different was that Music, Videos, and Pictures all use the first character of the path+file crc (which is where I shamelessly copied and pasted the code from  smile.gif ).

The sub folders have to be created upon startup or it won't work. Which is why I had to modify "Settings.cpp" so that Programs created its sub folders like the rest do.

As far as I can tell, Program thumbs now functions exactly the same as the others.

Edit: My bad, didn't understand the question. I see what you mean, I'll try it.

Edit 2:
Nope, doesn't work sad.gif. If you delete the original nothing shows up. Probably an issue with it being a .cut file. I'll look into it.
Logged

Ez0n3

  • Archived User
  • Jr. Member
  • *
  • Posts: 64
Xbe Style Thumbnails (.tbn) For Shortcut (.cut) Files
« Reply #4 on: March 16, 2009, 03:07:00 AM »

QUOTE(Ez0n3 @ Mar 16 2009, 05:16 AM) View Post

Edit 2:
Nope, doesn't work sad.gif. If you delete the original nothing shows up. Probably an issue with it being a .cut file. I'll look into it.


Scratch that. You gotta understand, it's 4am and I'm really tired. Can't understand a fairly simple question and then I go and delete all the cut's instead of the thumbs (tbn's) which explain exactly why "nothing" showed up.  laugh.gif

Yes it works. You can delete the original after it has been cached and it will still show up.

I'm going to sleep before do any more stupid things.  wink.gif
Logged

pkbunghole

  • Archived User
  • Jr. Member
  • *
  • Posts: 65
Xbe Style Thumbnails (.tbn) For Shortcut (.cut) Files
« Reply #5 on: June 09, 2009, 04:54:00 PM »

I wanted to do this, but i dont understand it fully.

I would have to redo this each time I updated XBMC is what put me off.

Is there a way you could get this feature added to all future versions of XBMC? or is there a good reason that they don't have it in the first place?
Logged

pkbunghole

  • Archived User
  • Jr. Member
  • *
  • Posts: 65
Xbe Style Thumbnails (.tbn) For Shortcut (.cut) Files
« Reply #6 on: June 10, 2009, 06:03:00 AM »

Could / Have you submitted it to the XBMC trac thing?
Logged

Ez0n3

  • Archived User
  • Jr. Member
  • *
  • Posts: 64
Xbe Style Thumbnails (.tbn) For Shortcut (.cut) Files
« Reply #7 on: June 11, 2009, 01:45:00 PM »

I agree that integrating this would be ideal. But from what I can tell, there is little interest overall making it difficult to get the XBMC dev's to accept it.

This is what I was told:
QUOTE
as this is xbox only code don't hold your breath waiting for us to do anything about it.

-spiff

I never submitted anything to the XBMC branch and don't have the time at the moment (nor do I know where to start), but I believe Bomb Bloke is going to submit it which would be great.

This post has been edited by Ez0n3: Jun 11 2009, 08:46 PM
Logged