wasm wrapper project

313 views
Skip to first unread message

Martin

unread,
Oct 2, 2022, 2:21:39 PM10/2/22
to WebP Discussion
Hi!

I'm trying to create a simple wrapper for the decoder (and encoder) without any dependencies. I'd like to "pass" an Uint8Array from JS to the decoder. AFAIK I'll need to malloc the buffer on the wasm heap, thus I export the functions webp_create_buffer and webp_delete_buffer as well.

uint8_t *webp_create_buffer(int size);
void webp_delete_buffer(void *buffer);
int webp_decode(const uint8_t *inputData, unsigned int inputDataSize, uint8_t *outputData);

First question: 
does this make sense? Is there any better interop between wasm and js available?

---
I've been testing the wasm build on windows 10 with latest emscripten toolchain (3.1.23).  

I get this output:

C:\webp\libwebp\webp_js>emmake make
make: C:\emsdk\mingw\4.6.2_32bit\mingw32-make.exe
-- Could NOT find ZLIB (missing: ZLIB_LIBRARY ZLIB_INCLUDE_DIR)
-- Could NOT find PNG (missing: PNG_LIBRARY PNG_PNG_INCLUDE_DIR)
-- Could NOT find JPEG (missing: JPEG_LIBRARY JPEG_INCLUDE_DIR)
TIFF is disabled when statically linking.
-- Could NOT find GIF (missing: GIF_LIBRARY GIF_INCLUDE_DIR)
-- Disabling SSE41 optimization.
-- Disabling SSE41 optimization.
-- Performing Test HAS_COMPILE_FLAG
-- Performing Test HAS_COMPILE_FLAG - Success
-- Disabling SSE2 optimization.    
-- Disabling SSE2 optimization.    
-- Performing Test HAS_COMPILE_FLAG
-- Performing Test HAS_COMPILE_FLAG - Success
-- Configuring done
-- Generating done
-- Build files have been written to: [...]
Consolidate compiler generated dependencies of target webpencode
[ 15%] Built target webpencode
Consolidate compiler generated dependencies of target sharpyuv
[ 19%] Built target sharpyuv
Consolidate compiler generated dependencies of target webputilsdecode
[ 25%] Built target webputilsdecode
Consolidate compiler generated dependencies of target webpdecode
[ 31%] Built target webpdecode
Consolidate compiler generated dependencies of target webpdspdecode
[ 52%] Built target webpdspdecode
[ 53%] Built target webpdecoder
Consolidate compiler generated dependencies of target webpdsp
[ 83%] Built target webpdsp
Consolidate compiler generated dependencies of target webputils
[ 91%] Built target webputils
[ 92%] Built target webp
Consolidate compiler generated dependencies of target webpdemux
[ 94%] Built target webpdemux
[ 95%] Building C object CMakeFiles/webp_wasm.dir/extras/webp_to_sdl.c.o
[ 96%] Linking C executable webp_wasm.js
emcc: error: undefined exported symbol: "[_WebpToSDL]" [-Wundefined] [-Werror]
mingw32-make[2]: *** [webp_wasm.js] Error 1
mingw32-make[1]: *** [CMakeFiles/webp_wasm.dir/all] Error 2
mingw32-make: *** [all] Error 2
emmake: error: 'C:\emsdk\mingw\4.6.2_32bit\mingw32-make.exe' failed (returned 2)

I cannot explain why emcc does not find the export. 
Is sdl required for this to work? 

Vincent Rabaud

unread,
Oct 3, 2022, 8:40:50 AM10/3/22
to webp-d...@webmproject.org
Hi,

I do not think we tested WASM on Windows.

For the second question, it seems webp_to_sdl.c.o is being built but it is empty because SDL is not found. Does your CMake find SDL ? Do you have WEBP_HAVE_SDL defined on the command line? (just run: emmake make VERBOSE=1).
Maybe it is due to bad quotes in CMake, I am proposing https://chromium-review.googlesource.com/c/webm/libwebp/+/3932942 to fix it.


--
You received this message because you are subscribed to the Google Groups "WebP Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to webp-discuss...@webmproject.org.
To view this discussion on the web visit https://groups.google.com/a/webmproject.org/d/msgid/webp-discuss/1a7c10d1-07f8-4fc5-abb8-ecd8cac28708n%40webmproject.org.

Martin

unread,
Oct 3, 2022, 1:11:06 PM10/3/22
to WebP Discussion, vra...@google.com
The quote fix solves my problem. I've created a simple wrapper (without sdl) and decoding works very well now. Thank you!
Reply all
Reply to author
Forward
0 new messages