Now Reading
QOA Benchmark Outcomes and File Format Specification

QOA Benchmark Outcomes and File Format Specification

2023-04-28 03:17:56

— Tuesday, April twenty fifth 2023

The specification for the Quite OK Audio Format,
introduced in a previous blog post,
is now finalized. QOA is a lossy audio compression format. Typical audio
alerts (44100hz, stereo) are encoded into 278 kbits/s, or extra exactly 3.2
bits per pattern – precisely 1/5 of the bits wanted for an uncompressed WAV.

qoa Logo

The QOA-Specification fits on a single-page PDF.
Extra data and take a look at samples could be discovered on qoaformat.org.
The supply is on github.

Efficiency Enhancements

Over the previous few weeks I carried out some adjustments to the reference en-/decoder
to enhance efficiency, particularly when decoding.

The biggest efficiency achieve, an 8% enchancment, got here from a considerably
counter-intuitive wanting change: a specialization of the qoa_clamp() perform.

static inline int qoa_clamp(int v, int min, int max) {
    if (v < min) { return min; }
    if (v > max) { return max; }
    return v;
}

static inline int qoa_clamp_s16(int v) {
    if ((unsigned int)(v + 32768) > 65535) {
        if (v < -32768) { return -32768; }
        if (v >  32767) { return  32767; }
    }
    return v;
}

The clamp perform within the decoder is extraordinarily scorching. It’s known as for every
output pattern to clamp it into the 16 bit vary. The rationale that qoa_clamp_s16()
is quicker than qoa_clamp() is owed to the truth that these output samples are
very hardly ever clamped in any respect.

The additional if assertion right here checks for each branches (v < -32768 and v > 32767)
concurrently and could be very hardly ever taken. This helps the CPU’s department predictor to
accurately predict and skip the department within the overwhelming majority of instances.

I additionally tried to re-implement the entire internal decoder loop with x86/x64 SIMD
intrinsics, however did not make it sooner than what gcc -O3 would produce – a
testomony to the advances of recent compilers! Fortunately, QOA is already fairly
quick.

Benchmark Outcomes

For these benchmarks I used the two hour 43 minute stereo audio observe of the
Bladerunner 2049 film. All codecs have been examined single threaded
(-threads 1 for ffmpeg) and output was despatched to /dev/null. The Vorbis, Opus,
MP3, M4A and ADPCM information have been encoded with ffmpeg’s default settings.

My CPU is an Intel i7-6700k; enter information have been saved on an NVME SSD. The
measurements have been taken with time within the terminal, utilizing the most effective out of 5 runs.
Please take these outcomes right here with an enormous grain of salt. That is solely meant to
give a basic thought of the efficiency between varied codecs
.

Outcomes for bladerunner.wav, stereo 44100 hz, 9807 sec, 1650 mb:

Format Lib/Software encode (s) decode (s) measurement (mb)
wv -b3 wavpack 42.175 29.800 304
wv -b2 wavpack 37.821 25.690 234
opus ffmpeg 315.232 20.410 116
wv wavpack 26.494 15.584 558
vorbis stb_vorbis 13.593
mp3 ffmpeg 146.223 9.631 149
vorbis ffmpeg 145.125 8.732 200
flac ffmpeg 18.148 8.715 552
mp3 dr_mp3 7.503
aac ffmpeg 86.884 6.636 151
flac dr_flac 6.429
adpcm_ms ffmpeg 10.424 3.690 417
qoa qoaconv 25.752 2.996 333

Curiously, even MS ADPCM is slower to decode than QOA. I believe that ffmpeg
itself has some appreciable overhead, with the info touring via many
layers of abstractions.

In order it stands, QOA is the quickest format to decode in my (admittedly restricted)
checks. In any case, I imagine that QOA affords a worthwhile tradeoff between file
measurement, high quality and decoding velocity.

See Also

Implementations

Aside from the reference implementation, QOA
has already been ported to plenty of completely different languages, together with
JavaScript,
C++,
R,
Rust,
D and this
Ć project by @pfusik which transpiles to C, C++, C#, Java, JavaScript,
Python, Swift and TypeScript.

As a part of @pfusik’s venture he additionally gives a QOA Plugin for Foobar2000.
With Foobar2000 being one in every of my favourite items of software program, that is very cool to see!

QOA Plugin for Foobar2000

QOA can be supported within the recreation engine raylib. It is most likely only a matter of time till we
see the primary recreation that makes use of QOA for audio playback. I am excited!

The Specification

The ultimate specification particulars the precise file format in addition to the steps
wanted to decode. Once more, the entire specification is only a
single page PDF:

qoa File Format Specification

Source Link

What's Your Reaction?
Excited
0
Happy
0
In Love
0
Not Sure
0
Silly
0
View Comments (0)

Leave a Reply

Your email address will not be published.

2022 Blinking Robots.
WordPress by Doejo

Scroll To Top