• Login
  • Register
  • Dolphin Forums
  • Home
  • FAQ
  • Download
  • Wiki
  • Code


Dolphin, the GameCube and Wii emulator - Forums › Dolphin Emulator Discussion and Support › Development Discussion v
« Previous 1 ... 33 34 35 36 37 ... 111 Next »

An ignorable improvement for reading Wii ISO file
View New Posts | View Today's Posts

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Thread Modes
An ignorable improvement for reading Wii ISO file
10-21-2014, 04:17 PM
#1
SamSun
Unregistered
 
Tongue 
Hi,

I have found following code for reading Wii iso file may be optimized, although the improvement is ignorable under modern OS (ex: Windows)

When emulator read data from Wii iso file via VolumeWiiCrypted.cpp CVolumeWiiCrypted::Read (), it always reads 32Kbyte data, even only 1 byte is requested. This is strange.

// read current block
if (!m_pReader->Read(m_VolumeOffset + m_dataOffset + Block * 0x8000, 0x8000, m_pBuffer))
{
return(false);
}

if (m_LastDecryptedBlockOffset != Block)
{
memcpy(IV, m_pBuffer + 0x3d0, 16);
aes_crypt_cbc(m_AES_ctx.get(), AES_DECRYPT, 0x7C00, IV, m_pBuffer + 0x400, m_LastDecryptedBlock);

m_LastDecryptedBlockOffset = Block;
}


I think it can be optimized by following code:

if (m_LastDecryptedBlockOffset != Block)
{

if (!m_pReader->Read(m_VolumeOffset + dataOffset + Block * 0x8000, 0x8000, m_pBuffer))
return(false);

memcpy(IV, m_pBuffer + 0x3d0, 16);
aes_crypt_cbc(m_AES_ctx, AES_DECRYPT, 0x7C00, IV, m_pBuffer + 0x400, m_LastDecryptedBlock);


m_LastDecryptedBlockOffset = Block;
}
Reply
10-22-2014, 06:23 AM
#2
JMC47 Offline
Content Producer
*******
Content Creators (Moderators)
Posts: 6,471
Threads: 28
Joined: Feb 2013
If someone made a PR it would get reviewed regardless.
Find
Reply
10-23-2014, 07:12 AM
#3
Buddybenj Offline
Junior Member
**
Posts: 35
Threads: 2
Joined: Feb 2014
If it doesn't cause any regressions, LGTM. You should submit a PR on GitHub.
Find
Reply
10-24-2014, 02:25 AM
#4
Jack Frost Offline
aka. BhaaL
**********
Developers (Some Administrators and Super Moderators)
Posts: 499
Threads: 3
Joined: Oct 2009
I don't really understand your change (without context); you moved the reading into the if? How is that supposed to change things if you need to decrypt the whole block anyways to read the data (even if its just one byte)?
Find
Reply
10-24-2014, 12:29 PM
#5
tueidj Offline
Senior Member
****
Posts: 555
Threads: 0
Joined: Apr 2013
The change is intended to avoid unnecessarily reading the encrypted block from the disc/iso file if the same block is already sitting decrypted in m_LastDecryptedBlock. I doubt it would have noticeable effect due to OS-level disk caching, you'd be better off implementing a cache for decrypted blocks if you wanted to speed things up.
Find
Reply
« Next Oldest | Next Newest »


  • View a Printable Version
  • Subscribe to this thread
Forum Jump:


Users browsing this thread: 1 Guest(s)



Powered By MyBB | Theme by Fragma

Linear Mode
Threaded Mode