I'm looking for an audio or image compression algorithm that can compress a torrent of 16-bit samples
My data has characteristics of images and audio (2-dimensional, correlated in both dimensions and audiolike in one dimension) so algorithms for audio or images might both be appropriate.
An obvious thing to try would be this one-dimensional algorithm:
For example, I could store 3101 in 16 bits, and store a scaling factor ceil(6678/256) = 27
in 8 bits, then convert each 16-bit sample to 8-bit as s8 = (s16 - base) / scale
where base = 3101 + 27>>1, scale = 27
, with the obvious decompression "algorithm" of s16 = s8 * 27 + 3101
.) Compression ratio: 128/67 = 1.91.
I've played with some ideas to avoid the division operation, but hasn't someone by now invented a superfast algorithm that could preserve fidelity better than this one?
Note: this page says that FLAC compresses at 22 million samples per second (44MB/s) at -q6
which is pretty darn good (assuming its implementation is still single-threaded), if not quite enough for my application. Another page says FLAC has similar performance (40MB/s on a 3.4GHz i3-3240, -q5) as 3 other codecs, depending on quality level.
The QOA format is the only thing I've found that provides predictable compression: lossy, 3.2 bits per sample ― 5x compression.
QOI by the same author is lossless but is not meant for 16-bit samples, and could increase data size by up to 25% if the data is incompressible. But I find the format inspiring ― one could potentially design something that incorporates elements of QOA and QOI to tailor a compression algorithm for one's use case.