diff --git a/codecs/mozjpeg_enc/README.md b/codecs/mozjpeg_enc/README.md new file mode 100644 index 00000000..1e7bd950 --- /dev/null +++ b/codecs/mozjpeg_enc/README.md @@ -0,0 +1,38 @@ +# MozJPEG encoder + +- Source: +- Version: v3.3.1 + +## Example + +See `example.html` + +## API + +### `int version()` + +Returns the version of MozJPEG as a number. va.b.c is encoded as 0x0a0b0c + +### `uint8_t* create_buffer(int width, int height)` + +Allocates an RGBA buffer for an image with the given dimension. + +### `void destroy_buffer(uint8_t* p)` + +Frees a buffer created with `create_buffer`. + +### `void encode(uint8_t* image_buffer, int image_width, int image_height, int quality)` + +Encodes the given image with given dimension to JPEG. `quality` is a number between 0 and 100. The higher the number, the better the quality of the encoded image. The result is implicitly stored and can be accessed using the `get_result_*()` functions. + +### `void free_result()` + +Frees the result created by `encode()`. + +### `int get_result_pointer()` + +Returns the pointer to the start of the buffer holding the encoded data. + +### `int get_result_size()` + +Returns the length of the buffer holding the encoded data. diff --git a/codecs/mozjpeg_enc/example.html b/codecs/mozjpeg_enc/example.html new file mode 100644 index 00000000..ffdeeb04 --- /dev/null +++ b/codecs/mozjpeg_enc/example.html @@ -0,0 +1,47 @@ + + + diff --git a/codecs/mozjpeg_enc/example.png b/codecs/mozjpeg_enc/example.png new file mode 100644 index 00000000..ae0e1110 Binary files /dev/null and b/codecs/mozjpeg_enc/example.png differ diff --git a/codecs/mozjpeg_enc/mozjpeg_enc.c b/codecs/mozjpeg_enc/mozjpeg_enc.c index f991e9ba..52e485a5 100644 --- a/codecs/mozjpeg_enc/mozjpeg_enc.c +++ b/codecs/mozjpeg_enc/mozjpeg_enc.c @@ -162,8 +162,8 @@ void encode(uint8_t* image_buffer, int image_width, int image_height, int qualit } EMSCRIPTEN_KEEPALIVE -void free_result(uint8_t* result) { - free(result); // not sure if this is right with mozjpeg +void free_result() { + free(result[0]); // not sure if this is right with mozjpeg } EMSCRIPTEN_KEEPALIVE diff --git a/codecs/webp_enc/README.md b/codecs/webp_enc/README.md new file mode 100644 index 00000000..793d8984 --- /dev/null +++ b/codecs/webp_enc/README.md @@ -0,0 +1,38 @@ +# WebP encoder + +- Source: +- Version: v0.6.1 + +## Example + +See `example.html` + +## API + +### `int version()` + +Returns the version of libwebp as a number. va.b.c is encoded as 0x0a0b0c + +### `uint8_t* create_buffer(int width, int height)` + +Allocates an RGBA buffer for an image with the given dimension. + +### `void destroy_buffer(uint8_t* p)` + +Frees a buffer created with `create_buffer`. + +### `void encode(uint8_t* image_buffer, int image_width, int image_height, float quality)` + +Encodes the given image with given dimension to WebP. `quality` is a number between 0 and 100. The higher the number, the better the quality of the encoded image. The result is implicitly stored and can be accessed using the `get_result_*()` functions. + +### `void free_result()` + +Frees the result created by `encode()`. + +### `int get_result_pointer()` + +Returns the pointer to the start of the buffer holding the encoded data. + +### `int get_result_size()` + +Returns the length of the buffer holding the encoded data. diff --git a/codecs/webp_enc/example.html b/codecs/webp_enc/example.html new file mode 100644 index 00000000..7e474683 --- /dev/null +++ b/codecs/webp_enc/example.html @@ -0,0 +1,47 @@ + + + diff --git a/codecs/webp_enc/example.png b/codecs/webp_enc/example.png new file mode 100644 index 00000000..ae0e1110 Binary files /dev/null and b/codecs/webp_enc/example.png differ diff --git a/codecs/webp_enc/webp_enc.c b/codecs/webp_enc/webp_enc.c index 108de867..491a55b3 100644 --- a/codecs/webp_enc/webp_enc.c +++ b/codecs/webp_enc/webp_enc.c @@ -28,8 +28,8 @@ void encode(uint8_t* img_in, int width, int height, float quality) { } EMSCRIPTEN_KEEPALIVE -void free_result(uint8_t* result) { - WebPFree(result); +void free_result() { + WebPFree(result[0]); } EMSCRIPTEN_KEEPALIVE