Skip to content

OpenXISF 0.4.0

Choose a tag to compare

@github-actions github-actions released this 05 Oct 06:33
· 20 commits to main since this release
00ac59c

OpenXISF 0.4.0 implements the algorithms that the XISF specification defines, to show and convert images, and reads and writes data faster. Before 1.0, minor versions may change the API.

The algorithms of the specification

  • Colour transformations (<openxisf/color.h>, Annex B). color_converter works relative to one RGB working space, sRGB by default with its own functions, or one with a gamma exponent: it converts between RGB, CIE XYZ and the normalized CIE L*a*b* that XISF units store, and computes the colorimetric grayscale component. Its luminance coefficients are derived from the chromaticities of the primaries, as Annex B requires; luminance_coefficients() gives them to applications that build a working space of their own. convert_rgb_to_lab() converts the pixel data of an image to CIE L*a*b* before it is written, and convert_lab_to_rgb() converts them back after it is read, in place, through the representable range of the image and with its RGB working space. RGB, L*a*b* and grayscale components are clipped to [0, 1], and black stays exactly black.
  • Display functions (<openxisf/display.h>). apply_display_function() evaluates a display function for one component (clipping, midtones transfer and expansion), and midtones_transfer() is the midtones transfer function alone. adaptive_display_function() computes a display function from the median and the normalized median absolute deviation of each channel of an image, the adaptive algorithm of the specification: for each channel, or with one set of parameters for the three channels of an RGB image, which keeps its colour balance.
  • Orientation (<openxisf/orientation.h>). orient_pixels() turns the pixel data of a two-dimensional image, in either storage model, to one of the eight orientations of the specification, and oriented_geometry() gives the size of the result. As the specification requires, this is for showing images only: the reader never applies an orientation.
  • Property format specifiers (<openxisf/format.h>). format_value() writes a property value as text, as its format specifier asks: width, fill character and alignment, sign, precision, fixed, scientific or automatic notation (the g conversion of printf), Booleans as words or digits, and integers in binary, octal, decimal or hexadecimal, 128-bit ones included. The parts of complex numbers and the elements of vectors and matrices are formatted one by one, and format_element() writes a single element of a long vector. Width and precision count up to 1024, so that the format of a property read from a file cannot ask for gigabytes.
  • The new sample program preview writes an 8-bit PGM or PPM file of the first image of a unit, as an application shows it: converted from CIE L*a*b* when it is stored so, stretched with its display function or with an adaptive one, and turned to its orientation. read_info now writes property values with their format specifiers.

The CIE L*a*b* values agree with those of PixInsight 1.9.5 within 1e-6, and the adaptive display functions with those that PixInsight's own statistics give. Reference values for Annex B, computed by an independent script in 50-digit decimal arithmetic, are part of the tests.

Faster

  • Pixel data read into memory of the application go straight from the source into it when they are neither compressed nor converted to the other storage model, and compressed blocks are decompressed into it: reading 100 MiB from memory now takes about as long as copying them. A block that fails its checksum leaves zeros there, and limits::max_allocation applies only to the memory that the library allocates.
  • Byte shuffling uses SSE2 on x86-64 for items of 2, 4 and 8 bytes, 2.5 to 23 times faster than the portable code, behind the new CMake option OPENXISF_ENABLE_SIMD (on by default); arm64 still uses the portable code. Conversion between the planar and normal storage models is 2.5 to 3.8 times faster.
  • The new option OPENXISF_WITH_TBB (off by default; vcpkg feature tbb) compresses and decompresses the subblocks of a block in parallel with oneTBB, in the task arena of the calling thread, and converts large images in pieces; sources, sinks and progress functions are still called from the calling thread. On 8 threads, writing a 100 MiB frame in subblocks gets 2 to 4.1 times faster, and reading it 1.4 to 2.7 times, depending on the codec.
  • The new option OPENXISF_WITH_OPENSSL (off by default; vcpkg feature openssl) computes checksums with OpenSSL's libcrypto: SHA-1 3.6 times and SHA-256 6.3 times faster than the built-in code. A failure of libcrypto is reported with the new errc::hash_failure.
  • OPENXISF_BUILD_BENCHMARKS builds the benchmarks, with Google Benchmark.

Compatibility

  • The new headers are included by <openxisf/openxisf.h>. The rest of the API is unchanged, apart from errc::hash_failure, added at the end of errc.
  • A read into memory of the application that fails or is cancelled may leave part of the data there, as documented since 0.1.0, and now more of it, since data go straight into it; data that fail their checksum are never left there.

Not yet

Astrometric solutions and signed units. Float128 values are formatted from their nearest double. arm64 has no NEON kernels for byte shuffling yet.

Building and testing

The library builds with CMake 3.25 or newer and installs a CMake package (find_package(openxisf CONFIG REQUIRED)) and a pkg-config file. Its dependencies are pugixml, zlib, LZ4 and Zstandard; oneTBB and OpenSSL are optional. See the README for the presets and options.

The tests of this release pass in CI on Linux (GCC 14 and Clang 18 with libstdc++ and libc++, x64 and arm64, with AddressSanitizer, UndefinedBehaviorSanitizer and ThreadSanitizer, clang-tidy and fuzzing, and builds with oneTBB and OpenSSL), on Windows (MSVC x64 and arm64, clang-cl, MSYS2 UCRT64 and CLANG64) and on macOS (AppleClang, arm64 and x64), and the vcpkg port builds on all three.

The API documentation is attached as openxisf-0.4.0-docs.tar.gz.