MCPcopy Create free account
hub / github.com/OpenFodder/openfodder / stbi__load_gif_main

Function stbi__load_gif_main

Source/Utils/stb_image.h:6960–7043  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6958}
6959
6960static void *stbi__load_gif_main(stbi__context *s, int **delays, int *x, int *y, int *z, int *comp, int req_comp)
6961{
6962 if (stbi__gif_test(s)) {
6963 int layers = 0;
6964 stbi_uc *u = 0;
6965 stbi_uc *out = 0;
6966 stbi_uc *two_back = 0;
6967 stbi__gif g;
6968 int stride;
6969 int out_size = 0;
6970 int delays_size = 0;
6971
6972 STBI_NOTUSED(out_size);
6973 STBI_NOTUSED(delays_size);
6974
6975 memset(&g, 0, sizeof(g));
6976 if (delays) {
6977 *delays = 0;
6978 }
6979
6980 do {
6981 u = stbi__gif_load_next(s, &g, comp, req_comp, two_back);
6982 if (u == (stbi_uc *) s) u = 0; // end of animated gif marker
6983
6984 if (u) {
6985 *x = g.w;
6986 *y = g.h;
6987 ++layers;
6988 stride = g.w * g.h * 4;
6989
6990 if (out) {
6991 void *tmp = (stbi_uc*) STBI_REALLOC_SIZED( out, out_size, layers * stride );
6992 if (!tmp)
6993 return stbi__load_gif_main_outofmem(&g, out, delays);
6994 else {
6995 out = (stbi_uc*) tmp;
6996 out_size = layers * stride;
6997 }
6998
6999 if (delays) {
7000 int *new_delays = (int*) STBI_REALLOC_SIZED( *delays, delays_size, sizeof(int) * layers );
7001 if (!new_delays)
7002 return stbi__load_gif_main_outofmem(&g, out, delays);
7003 *delays = new_delays;
7004 delays_size = layers * sizeof(int);
7005 }
7006 } else {
7007 out = (stbi_uc*)stbi__malloc( layers * stride );
7008 if (!out)
7009 return stbi__load_gif_main_outofmem(&g, out, delays);
7010 out_size = layers * stride;
7011 if (delays) {
7012 *delays = (int*) stbi__malloc( layers * sizeof(int) );
7013 if (!*delays)
7014 return stbi__load_gif_main_outofmem(&g, out, delays);
7015 delays_size = layers * sizeof(int);
7016 }
7017 }

Callers 1

Calls 5

stbi__gif_testFunction · 0.85
stbi__gif_load_nextFunction · 0.85
stbi__mallocFunction · 0.85
stbi__convert_formatFunction · 0.85

Tested by

no test coverage detected