Skip to content

OpenXISF 1.1.0

Latest

Choose a tag to compare

@github-actions github-actions released this 03 Nov 15:33
ceca3ad

OpenXISF 1.1.0 reads and writes regions of interest: a box of pixels and a range of channels of an image, read alone
from a unit, and written in place in a file, so that an application such as a stacking program works on its frames
tile by tile without holding them whole. It also bounds more of what an untrusted unit can cost, closes races of the
file system, and follows Revision 2 of the specification. The API of 1.0 compiles as it is. The ABI is that of a new
minor version, so programs built against 1.0 are rebuilt for 1.1: the shared library is libopenxisf.so.1.1, and the
Windows DLL is named after the minor version as well, openxisf-1.1.dll. Some changes alter what a call does; they are
listed under Behaviour changes.

Regions of interest. pixel_read_options::region reads a pixel_region of an image alone, into memory of the
library or of the application, and pitch places its rows in a larger buffer, such as a tile in its place in a frame.
What a region costs follows how the image is stored: uncompressed data are read run by run, the stretches of the block
that the region fills, runs close together in one read; a compressed block decodes only the subblocks that hold the
region, a few at a time, so that a region of a large image takes a few subblocks of memory, whatever its size; a block
compressed with byte shuffling is read in parts too, gathered byte by byte. A block with a checksum is read whole and
verified first, unless the application opts out with verify_checksum, for data that it verified once. A source whose
content lies in memory, as that of memory_source and a file that the application maps into memory do, gives it with
the new input_source::bytes(), and regions are then taken from it in place. On a desktop with a PCIe 5 NVMe disk, the
same 512 x 512 tile of 32 frames of 5120 x 5120 Float32 samples, from files not yet in memory, is read in 74 ms
uncompressed, where the whole frames take 435 ms, and in 256 ms compressed with Zstandard and byte shuffling in
subblocks of 4 MiB, where decoding the whole frames takes 870 ms on 16 threads.

Writing in place. openxisf::editor opens a monolithic file and writes regions of the pixel data of its images
where they are, with write_pixels() and pixel_write_options, from any number of threads at once for regions that
share no sample. commit() then writes in place the checksums of the blocks written; until then a reader finds such a
block corrupt, so an output left incomplete is not taken for a complete one. A block with a checksum is verified once,
before its first write. writer::add_reserved_image() writes an image as zeros, without its data in memory: the room
that an editor fills, with the checksum of its zeros when the options ask for checksums. The editor writes into
uncompressed attached blocks, and refuses any other block, and a distributed unit, with errc::not_editable. It reads
and writes through a random_access_device: file_device, memory_device, or a device of the application. The new
sample stack_regions.cpp shows the pattern: input frames written for region access, and a reserved output filled tile
by tile from several threads, each tile the mean of the same tile of every input.

Block facts. reader::block() tells how the pixel data of an image are stored, before anything is read
(block_info): where the block is (block_location), the byte order of its samples, its codec and byte shuffling, the
size of its largest subblock and their number, its checksum algorithm, and its sizes as stored and uncompressed, so that
an application knows what a read of a region costs.

Specification. OpenXISF follows Revision 2 of the XISF 1.0 specification, which defines the uncompressed subblocks
that OpenXISF already wrote and read (§10.6.1): a subblock whose compressed and uncompressed sizes are equal holds its
data as they are, and one longer than its data is decompressed. PixInsight 1.9.6 stores so each subblock that does not
compress, and its units, with SHA3-256 and SHA3-512 checksums too, are among the samples that the tests read. The
writer divides a compressed block into subblocks of 4 MiB by default, as PixInsight 1.9.6 does, which readers decode in
parallel and a region read decodes in part (see Behaviour changes).

Untrusted input and the file system. New limits, each with a default that every real unit stays within:
limits::max_diagnostics, the number of diagnostics that an open lists, 10,000 as in 1.0 and 0 for all;
max_index_elements, 16,777,216 elements over the block index of a data blocks file, whose walk a sparse file of
2^32 - 1 elements could make take minutes; max_model_objects, 1,000,000 images, thumbnails, properties, FITS keywords,
tables, fields and elements that describe images, counted before any object is made, an image taking about 2 KB; and
max_zstd_expansion, the bytes that a Zstandard block may declare for each of its stored bytes, 32768 by default, the
bound of the format, which a service lowers for data of a known kind as it lowers max_allocation. On POSIX systems
the default resolver of distributed units opens each directory of the path of a file from the one before, without
following links, so that a program that swaps a directory for a link meanwhile makes the open fail rather than lead it
outside the directory of the header file, as Windows has read through the handle that it checked since 1.0.0.
file_sink looks at its target again before it replaces it. On Windows a path of the device namespace, such as
\\.\COM1, \\.\pipe\name or \\?\GLOBALROOT\..., is refused by its text before anything opens it, and a directory
that is a reparse point of another kind than a link, such as the placeholder of a cloud file system, is a directory.
The resolver applies its rules for . and .. steps to absolute locations too. reader::load_ancillary_data() takes
the external files that the reader holds open, instead of opening a second set.

API. version_numbers() gives the version of the library as numbers (version_info), whose major and minor
numbers tell whether a library belongs to the headers in use. writer::add_image() and editor::write_pixels() take a
span of samples that are not const, such as std::span(samples) of a vector. property_value takes vectors and
matrices of integers of any C++ integer type, such as std::vector<long>, as the fixed-width type of their width and
signedness, as it takes scalars. New error codes, appended to errc: too_many_index_elements,
too_many_model_objects, not_editable and zstd_expansion_too_large.

Behaviour changes.

  • The Windows DLL is named after the minor version, openxisf-1.1.dll (libopenxisf-1.1.dll with MinGW,
    openxisf-1.1d.dll in Debug), as the soname is on other systems, so that a program built against 1.0 does not load
    the DLL of 1.1 that it finds first. The import library keeps its name, openxisf.lib (libopenxisf.dll.a), so link
    lines stay as they are; a program that ships the DLL ships the new one.
  • write_options::subblock_size is 4 MiB by default, where it was 0: a compressed block larger than that is written in
    subblocks, and a subblock that does not compress is stored as it is, which decoders of earlier revisions of the
    specification may not read. A unit meant for them is written with subblock_size 0, a single subblock, as before; a
    block that does not compress at all is still written uncompressed, which every decoder reads.
  • writer::save(path) writes to the path it is given, whatever its suffix, so that a unit can be written under a
    temporary name and renamed into place: the specification asks for .xisf, which the application gives.
    save_distributed() keeps .xish and .xisb.
  • A header-only open (read_options::header_only) of a distributed unit leaves its external files closed until the
    pixels of an image in one of them are read, or load_ancillary_data() runs, so that a resolver that is costly to
    call is called only for the files that are used: the diagnostics of the open no longer list the problems of those
    files, a strict header-only open no longer fails for them, and a read of an image in such a file throws the error of
    its block.
  • limits::max_external_files is 128 by default, where it was 256: half of the file descriptors that a macOS
    application has by default.
  • An application that raised limits::max_xml_elements to read a header of more than 1,000,000 images, properties,
    FITS keywords, fields or elements that describe images raises max_model_objects too. The rows and cells of tables do
    not count, so a large table still needs max_xml_elements alone.
  • file_sink::finish() refuses a target that has become a directory, a FIFO, a socket or a device since the sink was
    made (errc::not_a_regular_file).
  • The constructors of property_value from char, wchar_t, char8_t, char16_t and char32_t are deprecated,
    and 2.0 deletes them: a character is an integer there, so set("Instrument:Filter", 'R') sets the number 82. Give a
    String, "R", or the integer meant.
  • 2.0 will give a thumbnail the defaults of an image_info, UInt16 samples and the Gray colour space, where 1.x has
    UInt8 and RGB: a thumbnail that sets its sample format and colour space is written the same by both.

Build and packaging. The version is 1.1.0; the installed package accepts requests of 1.0 and 1.1
(SameMajorVersion), and the vcpkg overlay port of the repository is at 1.1.0.

Documentation. The README describes regions of interest and the editor, with excerpts of read_pixels.cpp, which
now reads a region into a tile with a margin, and of stack_regions.cpp. The headers say what a region read costs for
each form of block, how to write a frame for region access (subblocks of a few MiB, and no checksum or
verify_checksum off), and what an editor may share with readers of the same file.

Tests and CI. About 250 new tests (1,975 with MSVC, against 1,728 in 1.0.1), among them every region of small
images in every form of block, in both storage models, with and without a pitch, against the samples of the whole read;
the reads that each path makes; region reads and writes from 16 threads; the memory that region reads and reserved
images allocate; and a failure at each write of an editor's fill. fuzz_roundtrip reads random regions and compares
them with the samples written. Samples written by PixInsight 1.9.6 join those of 1.9.4 and 1.9.5, and every unit that
the tests and the sample programs write opens in PixInsight 1.9.6 with the values written. The benchmarks measure
regions read from memory, from files that the system holds in its cache and from files read around that cache, and a
frame filled through an editor. The release workflow no longer runs the platform matrix again on the tagged commit: it
needs the run of the merge to have passed, and fuzzes each target for ten minutes in a workflow of its own.