-
Notifications
You must be signed in to change notification settings - Fork 76
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
GifEncoder is final #7
Comments
It's I'm open to a PR that exposes the I don't really understand how you are maintaining the desired order of images alongside parallelism. Without an intermediate object representation of all the local state prior to the calls to write, how do you avoid the racing threads and preemption from causing random order? |
The bulk of scheduling can be possible by making this change to the library, in order to separate processing from write calls: This is the scheduling part, using the newly created method: I had to do too many changes to this project, this gif was taking 17 seconds from master (and 11 seconds after adding multi threads) to be generated in 640x480 (now it renders in 1.5): The MedianCut + Floyd is taking 4s now: The bulk of optimizations:
I might be too far away from a PR at this point, but the entire code can be safely merged (backwards compat) if we change Dither.java to:
That way we don't break people who depend on the copy and also give a new interface for people who don't want to waste memory. BUT, in reality nobody will ever use the deep-copy version unless they call that directly. The SDK should never make the copy in it's internals. |
Submit a pull request? |
@mufumbo Do you have a time to submit pull-request? Your explanation sounds as great performance boost |
Hi there,
not sure what's the point in making GifEncoder final,
In many implementations you would like to leverage multi threads to make the Image.fromRGB calls in parallel, rather than passing int[][] around and making Image.fromRGB from the internal API.
My use case: I download 10 images from the internet (in parallel) and create the int[][] in those threads. I could as well call Image.fromRGB from those threads, but I can't because addImage is a private method.
Furthermore, if I could extend that method, I would move everything to multiple threads, and synchronize only on ImageDataBlock.write.
If you agree, I can send a PR. The new code takes 2 seconds to generate an output that was taking 17s. I just reorganized the same code and haven't change any line.
thanks!
The text was updated successfully, but these errors were encountered: