Kaira-/ttm_unpack_py — pull request #1 by sulix (2012-12-04 13:52:06+00:00)
Title: Improve performance of decryption loop

Hi!

I'm the original author of the C 'ttm_unpack' program. I'm not a Python expert, but I've managed to clean up the main decryption loop a bit. (This is the bit with the nasty pointer arithmetic in the C version!)

Converting decryptState to hex is quite slow, so this does roughly does (though slightly less efficiently) and uses bit-shifts and bitwise and to extract the byte required.

In my tests, it performs roughly twice as fast as the original version (1m17s versus 2m55s), though neither are anywhere near as fast as the C version (which runs in around 2 seconds on my box).

Thanks for doing this port, it's quite amazing. I've put a webpage for the C version up at http://davidgow.net/hacks/ttm_unpack.html if you want a canonical place to check for any updates to it that I might do.

-- David