Skip to content
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

"gd_get_frame" function takes too long to execute #12

Open
leHeix opened this issue Mar 7, 2021 · 3 comments
Open

"gd_get_frame" function takes too long to execute #12

leHeix opened this issue Mar 7, 2021 · 3 comments

Comments

@leHeix
Copy link

leHeix commented Mar 7, 2021

The gd_get_frame function takes more than one second to finish execution, which is considerably slow compared to other GIF decoders and nearly unusable in a runtime where performance is a key point.

gifdec/gifdec.c

Lines 464 to 482 in 54ab6c8

int
gd_get_frame(gd_GIF *gif)
{
char sep;
dispose(gif);
read(gif->fd, &sep, 1);
while (sep != ',') {
if (sep == ';')
return 0;
if (sep == '!')
read_ext(gif);
else return -1;
read(gif->fd, &sep, 1);
}
if (read_image(gif) == -1)
return -1;
return 1;
}

GIF used:
ez

@sam20908
Copy link

The gd_get_frame function takes more than one second to finish execution, which is considerably slow compared to other GIF decoders and nearly unusable in a runtime where performance is a key point.

You know any other GIF libraries that are performant?

@Baker7
Copy link

Baker7 commented Mar 24, 2024

I noticed this too.

This is because the decoder accesses all data by reading it from disk via "read" instead of pulling it into memory.

There are file access calls everywhere.

Functionally, this doesn't matter and I find this project excellent -- however the access speed for getting to the data beyond the first couple of frames is slow due to all the disk access.

Thank you for writing this! The code is great, simple and very portable and minimal.

I am using this in https://www.moddb.com/mods/zircon-engine

I myself am probably going to need to convert all file access reads to memory reads to get the speed upgraded.

@erhoof
Copy link

erhoof commented May 27, 2024

@leHeix I have a small solution for that
@Baker7
Works way faster (like x3)

#28

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants