diff options
author | Vincent Sanders <vince@kyllikki.org> | 2023-11-26 16:12:26 +0000 |
---|---|---|
committer | Vincent Sanders <vince@kyllikki.org> | 2023-11-26 16:12:26 +0000 |
commit | 794d9b00260ea23a1ed935fbf6ad0a994b6a1d1f (patch) | |
tree | ceed608f1bd4b8e8c672d59d26c9096a9d0ed3c7 | |
parent | 9d5ebb857caa8561972f0c2395e2176ce2b03146 (diff) | |
download | netsurf-vince/libjxl.tar.gz netsurf-vince/libjxl.tar.bz2 |
avoid the unecessary callback APIvince/libjxl
-rw-r--r-- | content/handlers/image/jpegxl.c | 21 |
1 files changed, 4 insertions, 17 deletions
diff --git a/content/handlers/image/jpegxl.c b/content/handlers/image/jpegxl.c index 4bba02d1b..ba385f3ab 100644 --- a/content/handlers/image/jpegxl.c +++ b/content/handlers/image/jpegxl.c @@ -79,20 +79,6 @@ nsjpegxl_create(const content_handler *handler, return NSERROR_OK; } -static void image_out_callback(void *opaque, size_t x, size_t y, size_t num_pixels, const void *pixels) -{ - struct bitmap * bitmap = opaque; - uint8_t * output; - - output = guit->bitmap->get_buffer(bitmap); - if (output != NULL) { - /* bitmap buffer available */ - memcpy(output + (x*jxl_output_format.num_channels) + (y * guit->bitmap->get_rowstride(bitmap)), - pixels, - num_pixels*jxl_output_format.num_channels); - } -} - /** * create a bitmap from jpeg xl content. */ @@ -105,6 +91,7 @@ jpegxl_cache_convert(struct content *c) JxlBasicInfo binfo; const uint8_t *src_data; size_t src_size; + uint8_t * output; jxldec = JxlDecoderCreate(NULL); if (jxldec == NULL) { @@ -154,14 +141,14 @@ jpegxl_cache_convert(struct content *c) } /* ensure buffer was allocated */ - if (guit->bitmap->get_buffer(bitmap) == NULL) { + output = guit->bitmap->get_buffer(bitmap); + if (output == NULL) { /* bitmap with no buffer available */ guit->bitmap->destroy(bitmap); JxlDecoderDestroy(jxldec); return NULL; } - - decstatus = JxlDecoderSetImageOutCallback(jxldec, &jxl_output_format, image_out_callback, bitmap); + decstatus = JxlDecoderSetImageOutBuffer(jxldec, &jxl_output_format, output, c->size); if (decstatus != JXL_DEC_SUCCESS) { NSLOG(netsurf, ERROR, "unable to set output buffer callback status:%d",decstatus); guit->bitmap->destroy(bitmap); |