MCPcopy Create free account
hub / github.com/ARM-software/ComputeLibrary / stbi__load_gif_main

Function stbi__load_gif_main

include/stb/stb_image.h:6963–7046  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

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