Blame README.webp_js

Packit 9c6abc
     __   __ ____ ____ ____     __  ____
Packit 9c6abc
    /  \\/  \  _ \  _ \  _ \   (__)/  __\
Packit 9c6abc
    \       /  __/ _  \  __/   _)  \_   \
Packit 9c6abc
     \__\__/_____/____/_/     /____/____/
Packit 9c6abc
Packit 9c6abc
Description:
Packit 9c6abc
============
Packit 9c6abc
Packit 9c6abc
This file describes the compilation of libwebp into a JavaScript decoder
Packit 9c6abc
using Emscripten and CMake.
Packit 9c6abc
Packit 9c6abc
 - install the Emscripten SDK following the procedure described at:
Packit 9c6abc
   https://kripken.github.io/emscripten-site/docs/getting_started/downloads.html
Packit 9c6abc
   After installation, you should have some global variable positioned to the
Packit 9c6abc
   location of the SDK. In particular, $EMSCRIPTEN should point to the
Packit 9c6abc
   top-level directory containing Emscripten tools.
Packit 9c6abc
Packit 9c6abc
 - make sure the file $EMSCRIPTEN/cmake/Modules/Platform/Emscripten.cmake is
Packit 9c6abc
   accessible. This is the toolchain file used by CMake to invoke Emscripten.
Packit 9c6abc
Packit 9c6abc
 - configure the project 'WEBP_JS' with CMake using:
Packit 9c6abc
Packit 9c6abc
 cd webp_js && \
Packit 9c6abc
 cmake -DWEBP_BUILD_WEBP_JS=ON \
Packit 9c6abc
       -DEMSCRIPTEN_GENERATE_BITCODE_STATIC_LIBRARIES=1 \
Packit 9c6abc
       -DCMAKE_TOOLCHAIN_FILE=$EMSCRIPTEN/cmake/Modules/Platform/Emscripten.cmake \
Packit 9c6abc
       ../
Packit 9c6abc
Packit 9c6abc
 - compile webp.js using 'make'.
Packit 9c6abc
Packit 9c6abc
 - that's it! Upon completion, you should have the webp.js and
Packit 9c6abc
   webp.js.mem files generated.
Packit 9c6abc
Packit 9c6abc
The callable JavaScript function is WebPToSDL(), which decodes a raw WebP
Packit 9c6abc
bitstream into a canvas. See webp_js/index.html for a simple usage sample
Packit 9c6abc
(see below for instructions).
Packit 9c6abc
Packit 9c6abc
Demo HTML page:
Packit 9c6abc
===============
Packit 9c6abc
Packit 9c6abc
   The HTML page webp_js/index.html requires an HTTP server to serve the WebP
Packit 9c6abc
   image example. It's easy to just use Python for that.
Packit 9c6abc
Packit 9c6abc
cd webp_js && python -m SimpleHTTPServer 8080
Packit 9c6abc
Packit 9c6abc
and then navigate to http://localhost:8080 in your favorite browser.
Packit 9c6abc
Packit 9c6abc
Packit 9c6abc
Web-Assembly (WASM) version:
Packit 9c6abc
============================
Packit 9c6abc
Packit 9c6abc
  CMakeLists.txt is configured to build the WASM version when using
Packit 9c6abc
  the option WEBP_BUILD_WEBP_JS=ON. The compilation step will assemble
Packit 9c6abc
  the files 'webp_wasm.js', 'webp_wasm.wasm' in the webp_js/ directory.
Packit 9c6abc
  See webp_js/index_wasm.html for a simple demo page using the WASM version
Packit 9c6abc
  of the library.
Packit 9c6abc
Packit 9c6abc
  You will need a fairly recent version of Emscripten (at least 1.37.8) and of
Packit 9c6abc
  your WASM-enabled browser to run this version. Consider it very experimental!
Packit 9c6abc
Packit 9c6abc
Caveat:
Packit 9c6abc
=======
Packit 9c6abc
Packit 9c6abc
  - First decoding using the library is usually slower, due to just-in-time
Packit 9c6abc
    compilation.
Packit 9c6abc
Packit 9c6abc
  - Some versions of llvm produce the following compile error when SSE2 is
Packit 9c6abc
    enabled.
Packit 9c6abc
Packit 9c6abc
"Unsupported:   %516 = bitcast <8 x i16> %481 to i128
Packit 9c6abc
 LLVM ERROR: BitCast Instruction not yet supported for integer types larger than 64 bits"
Packit 9c6abc
Packit 9c6abc
    The corresponding Emscripten bug is at:
Packit 9c6abc
    https://github.com/kripken/emscripten/issues/3788
Packit 9c6abc
Packit 9c6abc
    Therefore, SSE2 optimization is currently disabled in CMakeLists.txt.