Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvement try to add feature threading #4

Merged
merged 10 commits into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
build/*.bc
emscripten/
src/*.jpg
src/*.png
src/output/
tools/
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,13 @@ e.g ` node app.js -i image.png -level=4 -min_thresh=8 `

## Build
Build emscripten files with docker:
docker run --rm -v $(pwd):/src -u $(id -u):$(id -g) -e "EMSCRIPTEN=/emsdk/upstream/emscripten" emscripten/emsdk:3.1.26 npm run build-local

docker run --rm -v $(pwd):/src -u $(id -u):$(id -g) -e "EMSCRIPTEN=/emsdk/upstream/emscripten" emscripten/emsdk:3.1.26 npm run build-local

or better create a docker container and run the build command inside it:

docker run -dit --name emscripten-nft-marker-creator-app -v $(pwd):/src emscripten/emsdk:3.1.26 bash
docker exec emscripten-nft-marker-creator-app npm run build-local

## Planned Features
- [ ] Multi threading support to speed up the creation of the markers.
16 changes: 8 additions & 8 deletions build/NftMarkerCreator.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/NftMarkerCreator_wasm.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions build/NftMarkerCreator_wasm.thread.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions build/NftMarkerCreator_wasm.thread.worker.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions emscripten/WebARKitLib
Submodule WebARKitLib added at 0eb8bc
48 changes: 0 additions & 48 deletions emscripten/markerCompress.c

This file was deleted.

54 changes: 54 additions & 0 deletions emscripten/markerCompress.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#include <emscripten.h>

#ifdef _WIN32
#include <Windows.h>
#else
#include <sys/stat.h>
#endif

#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <AR/ar.h>
#include "zlib/zlib.h"

static const char *zipname = "/tempBinFile.bin";

extern "C"
{

uint compressZip(char *src, int srclen)
{
FILE *fp;

char *b = new char[srclen];

printf("Uncompressed size is: %lu", strlen(src));
printf("\n----------\n");

z_stream defstream;
defstream.zalloc = Z_NULL;
defstream.zfree = Z_NULL;
defstream.opaque = Z_NULL;
defstream.avail_in = (uInt)srclen;
defstream.next_in = (Bytef *)src;
defstream.avail_out = (uInt)srclen;
defstream.next_out = (Bytef *)b;

deflateInit(&defstream, Z_BEST_COMPRESSION);
deflate(&defstream, Z_FINISH);
deflateEnd(&defstream);

printf("Compressed size is: %lu\n", strlen(b));

fp = fopen(zipname, "wb");
fwrite(b, defstream.total_out, 1, fp);
fclose(fp);

delete[] b;

return 0;
}

} // extern "C"
Loading