From 9cce6ed4a74b3dd0f0cdc48d90b595cd0b8d9030 Mon Sep 17 00:00:00 2001 From: Aous Naman Date: Sun, 27 Oct 2019 11:38:10 +1100 Subject: [PATCH] Update README.md, and removed unnecessary -s in the CMakeLists.txt file for javascript compilation --- README.md | 30 ++++++++++++++++-- .../UserInterfaceState.xcuserstate | Bin 177604 -> 177613 bytes subprojects/js/CMakeLists.txt | 2 +- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index f5c401d..20c1eae 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ The provided command line tools ojph\_compress and ojph\_expand accepts and gene The code employs the *cmake* tool to generate a variety of build enviroments. -** For Linux ** +**For Linux** cd build cmake ../ @@ -26,14 +26,14 @@ The code employs the *cmake* tool to generate a variety of build enviroments. The generated library and executables will be in the bin folder. -** For Windows ** +**For Windows** cd build cmake ../ -G "Visual Studio 14 2015 Win64" cmake support other visual studio versions. This command generates a solution in the build folder, which can be build using visual studio -** For macOS ** +**For macOS** You can use the "For Linux" approach above. Alternatively, you can use the Xcode project in src/apps/apps.xcodeproj, which I use. Another approach is to use cmake to generate an xcode project, in the build folder, using @@ -43,6 +43,25 @@ You can use the "For Linux" approach above. Alternatively, you can use the Xcod The generated library and executables will be in the bin folder. +# Compiling to javascript/wasm # + +The library can now be compiled to javascript/wasm. For this purpose, a small wrapper file (ojph_wrapper.cpp) has been written to interface between javascript and C++; the wrapper currently supports decoding only. A small demo page demonstrating the script can be accessed [here](https://openjph.org/javascript/demo.html). + +Compilation needs the [emscripten](https://emscripten.org/) tools. The tools are activated using +```bash +emsdk_env.sh +``` +Then, the javascript decoder can be compiled using +```bash +cd subprojects/js/build +emmake cmake .. +make +``` +This creates libopenjph.js and libopenjph.wasm in subprojects/js/html folder. That html folder also has the demo webpage index.html and a compressed image test.j2c which the script in index.html decodes. To run the demo webpage on your machine, you need a webserver running on the machine -- Due to security reasons, javascript engines running in a browser cannot access local files on the machine. A simple python webserver can be run +```python +python -m SimpleHTTPServer 8000 +``` +from inside the html folder. Here, 8000 is the port number at which the webserver will be listening. The webpage can then be accessed by open 127.0.0.1:8000 in you browser. Any browser supporting webassembly can be used to view this webpage; examples include Firefox, Chrome, Safari, and Edge, on a desktop, mobile, or tablet. # Usage Example # @@ -54,4 +73,9 @@ The generated library and executables will be in the bin folder. ojph_expand -i input_file.j2c -o output_file.ppm ojph_expand -i input_file.j2c -o output_file.yuv +# Related # + +The standard is available [here](https://www.itu.int/rec/T-REC-T.814/en). It is currently free of charge; I do not know if this is temporary or permanent. + +The associate site [openjph.org](https://openjph.org) serves as a blog. It currently host the [javascript](https://openjph.org/javascript/demo.html) demo of the decoder; the webpage demonstrates that the library can be compiled to javascript, and can run inside a web-browser. Any browser supporting webassembly can be used to view this webpage; examples include Firefox, Chrome, Safari, and Edge, on a desktop, mobile, or tablet. diff --git a/src/apps/apps.xcodeproj/project.xcworkspace/xcuserdata/aous.xcuserdatad/UserInterfaceState.xcuserstate b/src/apps/apps.xcodeproj/project.xcworkspace/xcuserdata/aous.xcuserdatad/UserInterfaceState.xcuserstate index 1ea13f738fdf745ade93c9908b9bb7e257921e9b..f4b6fa84224bd7c40691a7397df9404f0897716d 100644 GIT binary patch delta 5427 zcmYk;d3codwFmI|y)#HfEh<%`sKf%IVv!I;xmveYt9UEub=PvyTT!pp9d{XVsn!KI zFcdAQwXPMV(#Bg?RJ1A~nJkdZWQEL-J((=vg7to|_m6A+jPK*)yyu+nIm6SBJ4cjt zj<|DG*f$!N_^9Bhf}<0w3yxVZ{IEMmE(n)?|Mz7JhEG{A{P6A1!>7G@(Urxa}nD3y&{+sx% z@jK!V#h1n3kC(-3;_dOl__jnmv2$WfVq)T$#Eit8#1)Af5_c!=P289GUE+bngNcU| z3lonf9#1SvJegRMSekgcq~n_~CM+)_

mYvFJoX(k?!}nlnx6JZm&`|mOq>l$#h^fmLQNr(ejlc0W@39(dC{Iy~mzFouLK~e} zPkA2$u}~5CAqOxKms4>(QmZ(X(@2V~Li827t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&z5S>7Aj>2~dnF?XHBDV)ZcNV7|tU6*nh=G`?Lv+a7E=MYra%e)eW z9lMr!SiuK;oJ{>tc9}72m%IB&!3WLOa!bz+Ifg)HJWo5~H8~TzLu82+AY2PSp+#fr#aWYeqi&ywxD2;8L#XKHF!5e+IHm;@(W9#0Y ziCC#_O?O+J?q8z$?rWIK_56lgxd&%;Kf+?3l?w&?23Ku z+k?GueBTkA%XQe8zW?D}jIXZ>NA|5jKz)rgvjJE1^^s=~IrV)Tg?{Dt+tU7Pc|fTB zZ+Q?x|7SR~Ul{$u=yza$FJ9~yaR1gQJj@cRan!(e?8!tXaS+8EjH3rm;e7NpZ~_0tuQ1mE-?4$) zxf2^aa6eDtJ6AIBvGJn$F3q>M@wGf>M~2BI*y3;G-M4IK0h9MtFF zflTFRoXJ`IoO8IEo4JKsS?DkNLER5ZdvGaI9$d*g{4YWtG~K}ptj?g-88qp^3<@Zi zZox(uCLo!DWD1fgD4<|%3deFheisxZR5*B0zzR56951J diff --git a/subprojects/js/CMakeLists.txt b/subprojects/js/CMakeLists.txt index 1ec815f..b2bbf80 100644 --- a/subprojects/js/CMakeLists.txt +++ b/subprojects/js/CMakeLists.txt @@ -24,6 +24,6 @@ endif() if (BUILD_TEST) else() - set_target_properties(libopenjph PROPERTIES SUFFIX ".js" LINK_FLAGS "-s WASM=1 -s ENVIRONMENT=web -s EXPORTED_FUNCTIONS=[_create_j2c_data,_init_j2c_data,_get_j2c_width,_get_j2c_height,_get_j2c_bit_depth,_get_j2c_is_signed,_get_j2c_num_components,_get_j2c_downsampling_x,_get_j2c_downsampling_y,_parse_j2c_data,_pull_j2c_line,_release_j2c_data,_free,_malloc] -s EXTRA_EXPORTED_RUNTIME_METHODS=[ccall,cwrap] -s NO_EXIT_RUNTIME=1 -s -s ALLOW_MEMORY_GROWTH=1") + set_target_properties(libopenjph PROPERTIES SUFFIX ".js" LINK_FLAGS "-s WASM=1 -s ENVIRONMENT=web -s EXPORTED_FUNCTIONS=[_create_j2c_data,_init_j2c_data,_get_j2c_width,_get_j2c_height,_get_j2c_bit_depth,_get_j2c_is_signed,_get_j2c_num_components,_get_j2c_downsampling_x,_get_j2c_downsampling_y,_parse_j2c_data,_pull_j2c_line,_release_j2c_data,_free,_malloc] -s EXTRA_EXPORTED_RUNTIME_METHODS=[ccall,cwrap] -s NO_EXIT_RUNTIME=1 -s ALLOW_MEMORY_GROWTH=1") endif()