Skip to content

Commit

Permalink
Merge subtree commit 'c1f74efcecfd4155775ff4aa17e48208b13df96e'
Browse files Browse the repository at this point in the history
Keeping libcimbar master up to date. The most interesting included PR is
probably #73.
  • Loading branch information
sz3 committed Jun 24, 2023
1 parent c4a5076 commit 3594597
Show file tree
Hide file tree
Showing 60 changed files with 1,166 additions and 470 deletions.
20 changes: 12 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@ jobs:
fail-fast: false
matrix:
config:
- name: "linux gcc7"
os: ubuntu-18.04
env: CXX="g++-7" CC="gcc-7"

- name: "linux gcc9"
os: ubuntu-20.04
env: CXX="g++-9" CC="gcc-9"

- name: "linux gcc-latest"
os: ubuntu-latest

- name: "linux clang"
os: ubuntu-18.04
os: ubuntu-20.04
env: CXX="clang++" CC="clang"
extra-packages: "clang"

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
submodules: 'recursive'

Expand All @@ -45,11 +45,15 @@ jobs:
working-directory: ${{runner.workspace}}/build
run: make test CTEST_OUTPUT_ON_FAILURE=TRUE

- name: Usage test
working-directory: ${{runner.workspace}}/libcimbar/test/py
run: python3 -m unittest

cppcheck:
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Install dependencies
run: sudo apt-get install cppcheck
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Get the code
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
submodules: 'recursive'

Expand All @@ -23,7 +23,7 @@ jobs:
- name: Run the build process with Docker
uses: addnab/docker-run-action@v3
with:
image: emscripten/emsdk:latest
image: emscripten/emsdk:3.1.39
options: -v ${{ github.workspace }}:/usr/src/app
shell: bash
run: |
Expand All @@ -39,4 +39,5 @@ jobs:
files: |
web/cimbar.asmjs.zip
web/cimbar.wasm.tar.gz
web/cimbar_js.html
2 changes: 1 addition & 1 deletion DETAILS.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ The above is a 4x4(x4) cimbar grid -- encoding 64 bits of data. A real cimbar im

![an example cimbar code](https://github.com/sz3/cimbar-samples/blob/v0.5/6bit/4color_ecc30_fountain_0.png)

... and contains 1550 tiles for data. For 6-bit cimbar (4 symbol bits, 2 color bits), this means 9300 bytes per image.
... and contains 12400 tiles for data. For 6-bit cimbar (4 symbol bits, 2 color bits), this means 9300 bytes per image.

### Error Correction

Expand Down
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,17 @@ Encode:
* large input files may fill up your disk with pngs!

```
./cimbar --encode -i inputfile.txt -o outputprefix -f
./cimbar --encode -i inputfile.txt -o outputprefix
```

Decode (extracts file into output directory):
```
./cimbar outputprefix*.png -o /tmp -f
./cimbar outputprefix*.png -o /tmp
```

Decode a series of encoded images from stdin:
```
echo outputprefix*.png | ./cimbar -o /tmp
```

Encode and animate to window:
Expand Down
Binary file added bitmap/2/00.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bitmap/2/01.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bitmap/2/02.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bitmap/2/03.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 36 additions & 0 deletions package-cimbar-html.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@

def get_path(name):
fns = {
'index': 'web/index.html',
'cimbar_js': 'web/cimbar_js.js',
'main_js': 'web/main.js',
'output': 'web/cimbar_js.html',
}
return fns[name]


def read_file(name):
with open(get_path(name), 'rt') as f:
return f.read()


def read_script(name):
script = read_file(name)
return '<script type="text/javascript">\n' + script + '\n'


def main():
contents = read_file('index')
main_js = read_script('main_js')
cimbar_js = read_script('cimbar_js')

contents = contents.replace('<script src="main.js">', main_js)
contents = contents.replace('<script src="cimbar_js.js">', cimbar_js)

with open(get_path('output'), 'wt') as f:
f.write(contents)



if __name__ == '__main__':
main()
2 changes: 1 addition & 1 deletion package-portable-linux.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
## targeting old glibc
# docker run --mount type=bind,source="$(pwd)",target="/usr/src/app" -it ubuntu:16.04

Expand Down
11 changes: 7 additions & 4 deletions package-wasm.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#!/bin/sh
#docker run --mount type=bind,source="$(pwd)",target="/usr/src/app" -it emscripten/emsdk:latest
#!/bin/bash
#docker run --mount type=bind,source="$(pwd)",target="/usr/src/app" -it emscripten/emsdk:3.1.39

cd /usr/src/app

apt update
apt install python -y
apt install python3 -y

cd opencv4/
mkdir opencv-build-wasm && cd opencv-build-wasm
python ../platforms/js/build_js.py build_wasm --build_wasm --emscripten_dir=/emsdk/upstream/emscripten
python3 ../platforms/js/build_js.py build_wasm --build_wasm --emscripten_dir=/emsdk/upstream/emscripten

cd /usr/src/app
mkdir build-wasm && cd build-wasm
Expand All @@ -21,3 +21,6 @@ mkdir build-asmjs && cd build-asmjs
emcmake cmake .. -DUSE_WASM=2 -DOPENCV_DIR=/usr/src/app/opencv4
make -j5 install
(cd ../web/ && zip cimbar.asmjs.zip cimbar_js.js index.html main.js)

(cd ../ && python3 package-cimbar-html.py)

10 changes: 8 additions & 2 deletions src/exe/build_image_assets/build_image_assets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ map<string, string> getFileBlobs(string dir_path)
blobs[file_path] = base91::encode(contents);
}

for (int i = 0; i < 4; ++i)
{
string file_path = fmt::format("{}/2/{:02x}.png", dir_path, i);
string contents = File(file_path).read_all();
blobs[file_path] = base91::encode(contents);
}
for (int i = 0; i < 16; ++i)
{
string file_path = fmt::format("{}/4/{:02x}.png", dir_path, i);
Expand All @@ -43,8 +49,8 @@ int main(int argc, char** argv)
cxxopts::Options options("build_image_assets", "Build a C++ class file (header-only) that contains base91 png asset data.");

options.add_options()
("b,bitmap", "Bitmap directory", cxxopts::value<std::string>())
("h,help", "Print usage")
("b,bitmap", "Bitmap directory", cxxopts::value<std::string>())
("h,help", "Print usage")
;

auto result = options.parse(argc, argv);
Expand Down
1 change: 1 addition & 0 deletions src/exe/cimbar/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ target_link_libraries(cimbar
wirehair
zstd
${OPENCV_LIBS}
${CPPFILESYSTEM}
)

add_custom_command(
Expand Down
Loading

0 comments on commit 3594597

Please sign in to comment.