-
Notifications
You must be signed in to change notification settings - Fork 25
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
Adding / importing JPEG filter #85
Comments
Hi, It sounds possible to add it to If you feel like, Pull Request welcomed! See https://github.com/silx-kit/hdf5plugin/blob/master/doc/contribute.rst and of course, we can provide support. |
Besides the license, that should not be a big issue, the main issue I see is if we want to build ourselves the libjpeg library or if we want to rely on that of the system. System libjpeg libraries seem to use libjpeg-turbo that has plenty of compilation options for the different architectures and it would be a nightmare to try to solve at our side. |
Indeed, that can be a bit complicated. For generating the wheels, libjpeg-turbo is in the manylinux docker, so it should be possible to make wheels which will embed the libjpeg. |
I guess the simplest solution is to provide the reference old implementation with the possibility for the user to compile and link against the system libjpeg. That way the default implementation would be 2x or 6x slower but it would still work. That filter seems to work only for 8-bit integers. |
I reached out to the author and he now added a licence to the file ( Apache 2 ) |
I have tried to incorporate the plugin into our hdf5plugin building chain. It is straightforward if one can rely on an installed version of libjpeg-turbo. We have to take a decision. After all, it is a filter just for uint8 data. |
Alright, that sounds good. |
The only thing you should need to use this filter is a shareable library or DLL with that filter in the directory pointed to by the HDF5_PLUGIN_PATH environment variable. Here is an example where I have an existing HDF5 file that I saved with the JPEG plugin. I am using a very old version of h5dump (1.8.12), so it cannot possibly know about the JPEG filter.
This is the contents of the HDF5 file:
This is h5dump -p which shows the filter information.
So it finds the JPEG plugin, prints the correct information, and decodes the data correctly. This is 1024x1024 UInt8 image, so it would be about 1MB if it were not compressed. It was compressed with Quality=90, and this is the actual size:
This is my HDF5_PLUGIN_PATH
These are the jpeg files in that directory.
In my case I am building libjpeg from source and putting it that directory. I do that so I can ensure that libjpeg is available and a working version on all architectures that I build for. This includes 32 and 64-bit Windows, 32 and 64-bit Linux, MacOS, vxWorks and a number of others. It saves my users from needing to find and install the libjpeg library. But this is not necessary, it should also work fine with the system version of libjpeg. |
@MarkRivers, what sources of libjpeg are you using? |
The branch jpeg https://github.com/silx-kit/hdf5plugin/tree/jpeg shows how things would look like to add the plugin using a static version of libjpeg-turbo as jpeg library. That code is just for illustration purposes and it is only for windows. I do not think we'll integrate the filter. The main interest of hdf5plugin is that it allows to decouple the version of the HDF5 library used when building the plugin from the HDF5 version available when using the plugin. If the plugins supplied by Mark can be used on multiple versions of HDF5, then there is little interest on adding this filter to our list. You can just take the plugin from him. |
The repository where I build libjpeg is here: It builds the following libraries:
Each directory has a README.epics that says what version of the source code is used and any modifications made. The Makefile is always new, because the builds are done using the EPICS build system for OS-independence. In many cases minor changes were made to the source code to allow it to be built on vxWorks, etc. When building areaDetector one can select whether to use the system version of any library, or to use the version built in ADSupport. The ADSupport versions have the following advantages:
|
@MarkRivers Thank you. I have seen you are using compatibility with JPEG version 9 when the default compatibility mode for libjpeg-turbo is 6.2 Clearly if one wants to remain compatible with the source (you), only your sources have to be used. |
I am not sure that is true. I shared my JPEG plugin with the HDF Group, but not my version of libjpeg built from source. They added it to the HDF5 distribution, both the HDF5 source and plugin binaries, and they tested it. But they must have tested with some system version of libjpeg, because they did not use my libjpeg source. Maybe the API for the functions the plugin uses has not changed between 6.2 and 9? |
It could well be. Not being an expert I do not know if the incompatibilities can affect the output. I have been able to build your plugin against libjpeg-turbo built with 6.2 compatibility mode (its default). However, unless you perform a systematic check to verify it, I would not take the risk to use libraries built with different compatibility settings. The modern jpeg libraries can be built with different compatibility settings, perhaps it is enough that you specify your targeted compatibility. |
6.2 and 9 are maintained by different organizations. 9 is maintained by the Independent JPEG group: https://www.ijg.org/. 6.2 appears to be a dead-end with no further development. In October 2016 I updated ADSupport from JPEG 6.2 to 9b. However, at that time I did not need to make any changes to the areaDetector JPEG file writing plugin: https://github.com/areaDetector/ADCore/blob/master/ADApp/pluginSrc/NDFileJPEG.cpp. This tells me that the API did not change between 6.2 and 9b. |
If you do not use any extension mentioned in https://en.wikipedia.org/wiki/Libjpeg it should be fine. |
I managed to use the jpeg filter following your guide @MarkRivers . In **hdf5plugin.jpeg i guess it would have been arguments, but i cant really find that in the jpeg branch. |
I added a commit (777f14a) to the jpeg branch with the handling of arguments. |
Thank you Thomas. It seems to be working :-) |
59b7f38a updating for 1.0.0 (silx-kit#85) 3802c0f7 Tests: (fix) Makefile - CFLAGS and clean target (silx-kit#84) 111e5a19 Fix Silo doc section and warnings (silx-kit#83) 9dd45462 Use ZFP's version string (silx-kit#80) 557a4f61 Pin zfp version in windows ci (silx-kit#82) f51ac59f added parameter to fortran const (silx-kit#76) 35a08e06 [github] add windows build config (silx-kit#72) 1844b5b5 Fixed detection of CFP availability (silx-kit#74) c8544d3e [windows] enable compilation in windows with ClangCL (silx-kit#71) 7b34cacf Update installation.rst (silx-kit#66) e153bf9d Feature direct write zfp array (silx-kit#43) 20b0f1f3 Added missing HDF5 include (CMake) (silx-kit#63) 20b893a1 Test and fix working with HDF5-1.12 (silx-kit#62) 497e9420 CMake: (fix) Autotools build HDF5 (silx-kit#59) 8f63f7d3 Add missing headers for string functions and fix printfs for cd_nelmts (silx-kit#60) 8de12f77 Added generic interface fortran wrappers with tests (silx-kit#58) 983a1870 find zfp and hdf5 in lib64 instead of lib (silx-kit#56) e6c9c14c Fix typos f7670c43 Fix second typo in h5repack docs (silx-kit#55) 57a849de handle optional/mandatory flag (silx-kit#54) 48126d3c CMake: (feature) Added CMake build configuration (silx-kit#52) bee74347 fix link to travis badge (silx-kit#51) 00146c12 update to download from github (silx-kit#49) 259feb8f Remove include for HDF5 header file (silx-kit#48) 3d0b1768 adding missing call to h5z_zfp_finaliz() (silx-kit#45) b642fe8a minor fixes to docs and h5repack utility (silx-kit#42) git-subtree-dir: src/H5Z-ZFP git-subtree-split: 59b7f38a063b6adce3db074a945ee47bc50856da
cd5422c Compatibility with Visual Studio 2019 (silx-kit#93) bcff4d2 CMake: (fix) Missing header file. (silx-kit#90) 59b7f38 updating for 1.0.0 (silx-kit#85) 3802c0f Tests: (fix) Makefile - CFLAGS and clean target (silx-kit#84) 111e5a1 Fix Silo doc section and warnings (silx-kit#83) 9dd4546 Use ZFP's version string (silx-kit#80) 557a4f6 Pin zfp version in windows ci (silx-kit#82) f51ac59 added parameter to fortran const (silx-kit#76) 35a08e0 [github] add windows build config (silx-kit#72) 1844b5b Fixed detection of CFP availability (silx-kit#74) c8544d3 [windows] enable compilation in windows with ClangCL (silx-kit#71) 7b34cac Update installation.rst (silx-kit#66) e153bf9 Feature direct write zfp array (silx-kit#43) 20b0f1f Added missing HDF5 include (CMake) (silx-kit#63) 20b893a Test and fix working with HDF5-1.12 (silx-kit#62) 497e942 CMake: (fix) Autotools build HDF5 (silx-kit#59) 8f63f7d Add missing headers for string functions and fix printfs for cd_nelmts (silx-kit#60) 8de12f7 Added generic interface fortran wrappers with tests (silx-kit#58) 983a187 find zfp and hdf5 in lib64 instead of lib (silx-kit#56) e6c9c14 Fix typos f7670c4 Fix second typo in h5repack docs (silx-kit#55) 57a849d handle optional/mandatory flag (silx-kit#54) 48126d3 CMake: (feature) Added CMake build configuration (silx-kit#52) bee7434 fix link to travis badge (silx-kit#51) 00146c1 update to download from github (silx-kit#49) 259feb8 Remove include for HDF5 header file (silx-kit#48) 3d0b176 adding missing call to h5z_zfp_finaliz() (silx-kit#45) b642fe8 minor fixes to docs and h5repack utility (silx-kit#42) git-subtree-dir: src/H5Z-ZFP git-subtree-split: cd5422c146836e17c7a0380bfb05cf52d0c4467c
Hi.
I've been looking at this lossy jpeg filter : https://github.com/CARS-UChicago/jpegHDF5 which i'd very much like to try.
Is it possible to add it / import it with the hdf5plugin module?
Best regards
Peter
The text was updated successfully, but these errors were encountered: