-
-
Notifications
You must be signed in to change notification settings - Fork 383
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GIF export speedup #696
GIF export speedup #696
Conversation
Do not merge yet. I found a bug with big images which require quantization. They are exported as solid color gifs and I need to investigate. |
I rewrote the add_image_data_block() function to have less looping. It shaves off only around 100ms from the export I test on but it hugely helps in a profiler where it was causing big spikes. |
I am done with this PR for now. The next step would be to somehow speed up LSBLZWBitPacker.write_bits() function which gets called a lot but it already uses a lot of bithacks so there is not much room to work with. |
addons/gdgifexporter/gif-lzw/lzw.gd
Outdated
current_code_size = new_code_size_candidate | ||
|
||
return index_stream | ||
#func decompress_lzw( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be best if we removed this method entirely instead of commenting it out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to leave it as a reminder that it should be reimplemented with a proper gif import support but it's also possible to remove it.
The last commit helped to shave off a few hundred milliseconds. Now the export takes around 11.5 seconds. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
This PR was originally made by @novhack for Pixelorama (Orama-Interactive/Pixelorama#696), but the changes weren't brought in this repo. Note that I had to not keep the changes made in the `add_image_data_block()` method in exported.gd that the original PR had, because the resulting gif file seemed invalid. I'm not sure what the problem is, but even without this change the speedup is still there. Using the default images of the project: Gif exporting time before this PR: 1.70701233333333 Gif exporting time after this PR: 1.01357166666667
I looked into LZW compression code in the gifexporter addon and simplified it a little bit.
The result is as speedup of around 3.6 times.
Using Roroto's awesome splashscreen it went from 43,26 seconds to 11,96 seconds in the editor. Compiled version of Pixelorama goes from 34.5 to 9.3 seconds.
I did some tests with multiple animation files and gifs exported from 0.10 and exported from this changed version are identical according to "cmp -l"
I will eventually commit this also to the jegor's repository but it seems to be outdated at this moment.
I also commented the decompress function because it now needs a rewrite and is currently unused.
There are for sure more ways the speed the whole thing up but small steps...