Skip to content

Commit

Permalink
fix calling WebPDemux() with dynamically loaded libwebp
Browse files Browse the repository at this point in the history
autotools and cmake configurators still need fixing
  • Loading branch information
sezero committed Nov 1, 2022
1 parent bc52f89 commit 1af8a53
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions IMG_webp.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ static struct {
uint8_t* (*WebPDecodeRGBInto) (const uint8_t* data, size_t data_size, uint8_t* output_buffer, size_t output_buffer_size, int output_stride);
uint8_t* (*WebPDecodeRGBAInto) (const uint8_t* data, size_t data_size, uint8_t* output_buffer, size_t output_buffer_size, int output_stride);
#endif
WebPDemuxer* (*WebPDemux)(const WebPData* data);
/* WebPDemux() is an inline in webp/demux.h calling WebPDemuxInternal(). */
WebPDemuxer* (*WebPDemuxInternal)(const WebPData*, int, WebPDemuxState*, int);
int (*WebPDemuxGetFrame)(const WebPDemuxer* dmux, int frame_number, WebPIterator* iter);
uint32_t (*WebPDemuxGetI)(const WebPDemuxer* dmux, WebPFormatFeature feature);
void (*WebPDemuxDelete)(WebPDemuxer* dmux);
Expand Down Expand Up @@ -88,7 +89,7 @@ int IMG_InitWEBP()
FUNCTION_LOADER(WebPDecodeRGBInto, uint8_t * (*) (const uint8_t* data, size_t data_size, uint8_t* output_buffer, size_t output_buffer_size, int output_stride))
FUNCTION_LOADER(WebPDecodeRGBAInto, uint8_t * (*) (const uint8_t* data, size_t data_size, uint8_t* output_buffer, size_t output_buffer_size, int output_stride))
#endif
FUNCTION_LOADER(WebPDemux, WebPDemuxer* (*)(const WebPData* data))
FUNCTION_LOADER(WebPDemuxInternal, WebPDemuxer* (*)(const WebPData*, int, WebPDemuxState*, int))
FUNCTION_LOADER(WebPDemuxGetFrame, int (*)(const WebPDemuxer* dmux, int frame_number, WebPIterator* iter))
FUNCTION_LOADER(WebPDemuxGetI, uint32_t (*)(const WebPDemuxer* dmux, WebPFormatFeature feature));
FUNCTION_LOADER(WebPDemuxDelete, void (*)(WebPDemuxer* dmux))
Expand All @@ -110,6 +111,10 @@ void IMG_QuitWEBP()
--lib.loaded;
}

static SDL_INLINE WebPDemuxer* SDL_WebPDemux(const WebPData* data) {
return lib.WebPDemuxInternal(data, 0, NULL, WEBP_DEMUX_ABI_VERSION);
}

static int webp_getinfo (SDL_RWops *src, int *datasize) {
Sint64 start;
int is_WEBP;
Expand Down Expand Up @@ -342,7 +347,7 @@ IMG_Animation *IMG_LoadWEBPAnimation_RW(SDL_RWops *src)

wd.size = raw_data_size;
wd.bytes = raw_data;
dmuxer = lib.WebPDemux(&wd);
dmuxer = SDL_WebPDemux(&wd);
anim = (IMG_Animation *)SDL_malloc(sizeof(IMG_Animation));
anim->w = features.width;
anim->h = features.height;
Expand Down

0 comments on commit 1af8a53

Please sign in to comment.