-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
MRF: JPEG-XL (brunsli) support #3945
Conversation
tested read
By default, JPEGs are written as JPEG-XL, except if noJXL option is set
The compiler complains if a variable is not used
CC'ing @tbonfort @lucianpls I wasn't aware of https://github.com/google/brunsli, but in https://github.com/rouault/gdal/commits/jxl I have preliminary work to use JPEG-XL as a TIFF codec, based on the https://gitlab.com/wg1/jpeg-xl implementation. I'm not completely clear if a google/brunsli blob is a valid JPEG-XL one ? It would be best to converge on a single JPEG-XL implementation for GDAL. |
Brunsli is a subset of JPEG-XL. JPEG-XL lite if you want. There is also the issue of dependencies. libbrunsli only depends on brotli, and even that dependency is non-essential and could be removed, although I'm not sure that it can be considered JPEG-XL in that case. The full JPEG XL code is much more complex AFAICT. In general, I prefer the simplicity and clarity of brunsli over the full JPEG-XL. It does one thing and it does it well. |
@lucianpls from a user's point of view, supporting brunsli requires bumping the gdal version and adding some new dependencies, whereas adding full jxl support requires bumping the gdal version and adding a different set of dependencies. Not very different in my book. The full jxl suite has some very attractive support for n>3 bands along with more than 8bit and lossless which rivals j2k, and should see mainstream support in distros, it would seem to be a pity to only support brunsli, even though it would mean more effort to implement in the mrf driver. |
@tbonfort |
@lucianpls What I would wish to avoid is to have both Brunsli and libjxl as dependencies of GDAL. Would it be possible to leverage libjxl to deal with the Brunsli payload for MRF ? |
@rouault |
yes, seeing https://github.com/libjxl/libjxl/tree/main/third_party . But as far as I remember, the install of the JXL library doesn't make brunsli headers available. They're likely considered as an implementation detail |
doc/source/drivers/raster/marfa.rst would probably need some updates too |
The MRF detailed documentation is in the MUG, the rst is just a pointer to that document. I will update the MUG to discuss the brunsli implications. |
Assume brunsli include files are preinstalled and that libraries are in the library path
BRUNSLI_ENABLED="yes" | ||
AC_SUBST(BRUNSLI_ENABLED, $BRUNSLI_ENABLED) | ||
AC_SUBST(BRUNSLI_INCLUDE, -I$prefix/include) | ||
AC_SUBST(BRUNSLI_LIB, "-lbrunslicommon -lbrunslienc -lbrunslidec -lbrotlicommon -lbrotlienc -lbrotlidec") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BRUNSLI_LIB
is super fragile:
-
lib ordering is wrong: brotlicommon is a dependency of brotlienc and brotlidec, same for brunsli.
-
Lib names of brunsli seem wrong: https://github.com/google/brunsli/blob/v0.1/brunsli.cmake#L50-L85. Installation of brunsli is not neat, but CMakeLists suggests it's always shared and lib names are
brunslidec-c
andbrunslienc-c
. -
brotli lib names are different if static (
-static
suffix)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we'll probably not put too much effort in autoconf support for Brunsli, but I've filed #5068 to add support for it to CMake builds
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* Lib names of brunsli seem wrong: https://github.com/google/brunsli/blob/v0.1/brunsli.cmake#L50-L85. Installation of brunsli is not neat, but CMakeLists suggests it's always shared and lib names are `brunslidec-c` and `brunslienc-c`.
Those are for the C API, which is much more limited than the C++ one if I recall.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, but it's worth noting that the very few package managers having this lib don't even package the static libs (C++), only the shared C lib. I don't know whether C++ headers are intended to be used by consumers (there is no install target nor API documentation so it's unclear, but at least the folder of C/C++ files is called c
).
Anyway, static lib names have -static suffix as you can see in CMakeLists.
What does this PR do?
brunsli (part of JPEG-XL) is an open source licensed lossless packer for JFIF files from Google.
The brunsli blobs are usually 22% smaller than the source JFIF JPEG on the average, while increasing the compression and decompression time. The source JFIF form is fully restored, thus brunsli requires only minor changes to the existing code and does not affect the image quality or any other JPEG features. It can only handle the most common 8bit JFIF format, but it does pass-through all JFIF chunk, brotli compressed.
This PR includes the changes to make the MRF driver capable of encoding and decoding tiles in the brunsli format, when the brunsli support is enabled. Since brunsli/brotli libraries are not usually available as packages, support for this feature has to be enabled manually at this point.
I intend to add a standalone JPEG-XL (brunsli for starters) driver shortly, with read/write capabilities.
I would appreciate any help or advice on adding brunsli/brotli libraries to the CI workflow so these changes can be fully tested.
What are related issues/pull requests?
Tasklist
Environment
Provide environment details, if relevant: