Skip to content

Commit

Permalink
fix(libultrahdr-wasm): encoding of odd sized images (#31)
Browse files Browse the repository at this point in the history
Fixes a bug in libultrahdr-wasm which prevented the encoding of odd-sized (non divisible by two) images. The problem originated from external code which operated the check for even sizes for unknown reasons.
  • Loading branch information
daniele-pelagatti authored Feb 9, 2024
1 parent b06ac91 commit efd52c3
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion libultrahdr-wasm
Submodule libultrahdr-wasm updated 62 files
+7 −0 .clang-format
+27 −0 .github/workflows/cifuzz.yml
+3 −3 .github/workflows/cmake.yml
+11 −11 Android.bp
+238 −129 CMakeLists.txt
+2 −2 README.md
+41 −0 examples/Android.bp
+991 −0 examples/ultrahdr_app.cpp
+72 −73 fuzzer/README.md
+1 −1 fuzzer/ossfuzz.sh
+32 −32 fuzzer/ultrahdr_dec_fuzzer.cpp
+242 −248 fuzzer/ultrahdr_enc_fuzzer.cpp
+0 −688 icc.cpp
+0 −263 include/ultrahdr/icc.h
+0 −158 include/ultrahdr/jpegdecoderhelper.h
+0 −106 include/ultrahdr/jpegencoderhelper.h
+0 −465 include/ultrahdr/jpegr.h
+0 −64 include/ultrahdr/ultrahdrcommon.h
+19 −9 index.html
+0 −657 jpegdecoderhelper.cpp
+0 −294 jpegencoderhelper.cpp
+0 −631 jpegrutils.cpp
+142 −183 lib/gainmapmath.cpp
+22 −29 lib/gainmapmath.h
+680 −0 lib/icc.cpp
+259 −0 lib/icc.h
+625 −0 lib/jpegdecoderhelper.cpp
+157 −0 lib/jpegdecoderhelper.h
+287 −0 lib/jpegencoderhelper.cpp
+106 −0 lib/jpegencoderhelper.h
+204 −204 lib/jpegr.cpp
+464 −0 lib/jpegr.h
+611 −0 lib/jpegrutils.cpp
+23 −26 lib/jpegrutils.h
+92 −0 lib/multipictureformat.cpp
+9 −9 lib/multipictureformat.h
+5 −5 lib/ultrahdr.h
+64 −0 lib/ultrahdrcommon.h
+4 −4 libultrahdr-wasm.cpp
+8 −8 meson.build
+0 −94 multipictureformat.cpp
+0 −21 tests/Android.bp
+0 −0 tests/data/LICENSE
+ tests/data/jpeg_image.jpg
+0 −0 tests/data/minnie-318x240.yu12
+ tests/data/minnie-320x240-y.jpg
+ tests/data/minnie-320x240-yuv-icc.jpg
+ tests/data/minnie-320x240-yuv.jpg
+0 −0 tests/data/minnie-320x240.y
+0 −0 tests/data/minnie-320x240.yu12
+ tests/data/raw_p010_image.p010
+0 −0 tests/data/raw_yuv420_image.yuv420
+328 −299 tests/gainmapmath_test.cpp
+36 −37 tests/icchelper_test.cpp
+73 −86 tests/jpegdecoderhelper_test.cpp
+63 −79 tests/jpegencoderhelper_test.cpp
+562 −547 tests/jpegr_test.cpp
+0 −857 tests/ultrahdr_app.cpp
+9 −11 third_party/image_io/CMakeLists.txt
+2 −2 third_party/image_io/includes/image_io/base/data_range.h
+3 −3 third_party/image_io/src/utils/file_utils.cc
+0 −84 utils.cmake
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions tests/encode/encode-and-compress.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,22 @@ test('encodes and compresses from exr', async ({ page }) => {
expect(resized).toMatchSnapshot('memorial.exr-encode-result.png')
})

test('encodes and compresses odd sized images', async ({ page }) => {
await page.goto('/tests/testbed.html', { waitUntil: 'networkidle' })

const script = page.getByTestId('script')
await expect(script).toBeAttached()

const result = await page.evaluate(encodeAndCompressInBrowser, { file: 'files/odd-sized.exr' })

const resized = await sharp(Buffer.from(result))
.resize({ width: 500, height: 500, fit: 'inside' })
.png({ compressionLevel: 9, effort: 10 })
.toBuffer()

expect(resized).toMatchSnapshot('odd-sized.exr-encode-result.png')
})

test('encodes and compresses from exr using worker', async ({ page }) => {
await page.goto('/tests/testbed.html', { waitUntil: 'networkidle' })

Expand Down
Binary file added tests/files/odd-sized.exr
Binary file not shown.

0 comments on commit efd52c3

Please sign in to comment.