9 ms·
QOA, the Quite OK Audio Format
- GoblinSlayer 4y agoI made little endian formats and didn't notice any complications. int quantized = (slice >> 57) & 0x7; You wouldn't need this shift with a little endian format. If you store samples in order and read them as big endian, the first sample will be in high bits and the last sample in low bits, which is unnatural for shift and mask, that's what I call complication.
- bArray 4y agoPotentially the killer application for this would be those wireless earbuds and music players. I would like to hear what this sounds like at lower bit rates when signals become strained. Really cool work!
- Computeiful 4y agoQOI caused a huge burst in interest for image formats. Audio is a little harder to work with and understanding so I can imagine less impact for QOA (still good though). What I'm really looking forward to is QOV (video).
- actionfromafar 4y agoQOI is only 8-bit depth (per channel) so it's a no-go for me. But interesting, yes.
- stefncb 4y agoOut of curiosity, what for?
- deleted 4y ago[deleted]
- dylan604 4y agoNot the OP but as an example, the difference between 8-bit and 10-bit on visual complexities like gradients are very noticeable.
- actionfromafar 4y agoI have a pipeline for scanning of analog sources like film. Since these are meant to be edited after scanning, 8-bit range is much to limited.
- thanatos519 4y agoI render accumulation fractals like the Buddhabrot at 32 bits per channel. So far I have only used about 27 bits but it's nice to have a bit of headroom.
- deleted 4y ago[deleted]
- creshal 4y agoI wonder how much complexity it would add to support 10 or 16 bit per channel in the file format.
- adgjlsfhk1 4y agoyou'd have to totally redesign the format. QOI is very specialized on 8 bits per channel (and RGBA)
- creshal 4y agoThe physical layout, sure, but would it conceptually involve more than just defining twice as large chunk types for 16 bit channels? Unless I'm missing something, it should be fairly uncomplicated code-wise?
- p0nce 4y agoI've extended QOI for 10-bit here: https://github.com/AuburnSounds/gamut https://github.com/AuburnSounds/gamut (and also grey and grey+alpha). So it's a separate incompatible codec yes. The problem with a QOI that would have 16-bit is that lossless becomes more expensive, exact match in the color table is more rare too and not worth it anymore. You will start to need more prediction modes + offsets. Using QOIX for elevation maps in PBR currently.
- adgjlsfhk1 4y agoNot really. QOI's opcodes are very specifically designed based on the characteristics of 8 bit images. For example, there is an 8 bit opcode for a run of up to 64 identical pixels. This makes a lot of sense for an 8 bit image, but is a lot less likely to appear in a 16 bit picture. For a 16 bit photo, the minimal QOI modification would almost certainly be worse than uncompressed since noise in the sensor will prevent any of the 8 bit opcodes from working.
- creshal 4y agoRLE doesn't really work for photos even at 8 bit depth, the noise is noticeable even there. It's mainly useful for drawn/rendered content, where solid colored areas are far more common. That won't be much different at 16 bit depth.
- srott2 4y agoQuite OK article :) A few years ago, a guy made his own video compression format, but I can't find it anymore, is it still available online?
- lifthrasiir 4y agoAre you looking for this? https://blog.tempus-ex.com/hello-video-codec/ https://blog.tempus-ex.com/hello-video-codec/
- metadaemon 4y agoI remember this post, so probably right.
- srott2 4y agoI think the style is similar, but it was more complex. He was also showing off the codec on his face, probably this is a newer version. Anyway, I'm grateful.
- gkbrk 4y agoAre you looking for this series of articles? The author makes his own video codec for a video chat app, and has a lot of test videos of faces. https://bengarney.com/2016/06/25/video-conference-part-1-these-things-suck/ https://bengarney.com/2016/06/25/video-conference-part-1-the...
- srott2 4y agoexactly!
- hcs 4y ago> Most GameCube games used their own 8-bit ADPCM format Minor quibble but, at least for music, most GC games used a native 4-bit ADPCM ("DSP", decoded by the DSP, or the ADP/DTK format, like CD-XA ADPCM and also handled in hardware), and the most common cross-console audio middleware (CRI) also generally used 4-bit ADX ADPCM. In this old list, everything marked ADP, ADX, DSP is using 4-bit (and others are usually just different containers for DSP): http://web.archive.org/web/20080420105759/https://hcs64.com/mboard/gcstreamdb.php http://web.archive.org/web/20080420105759/https://hcs64.com/... PS1 and PS2 were similar. I've usually only encountered 8-bit DPCM on PC, though the 3DO had a version in hardware. The old table-driven style of ADPCM might be the poor quality the author has in mind, all of these consoles get much better quality at 4 bits, using the same kind of linear predictor (usually with 2 samples of history) with scales per frame as QOA. Edit: I hadn't read carefully enough, QOA is doing something more complicated by updating the weights rather than using a fixed set of filters chosen per frame (ADX has only one per sample rate, GC DSP uses 8, XA/PS uses 4 or 5). That seems a little overcomplicated, but maybe needed at 3 bits per sample?
- Jasper_ 4y agoYeah, I don't understand the disparaging of 4-bit ADPCM as being terrible quality when this is effectively a 3-bit ADPCM. Most ADPCM codecs I've seen shipped have a similar table based system with a frame header with coefficients for your two history samples rather than the weight update scheme here, and it works quite well.
- phoboslab 4y agoTraditional ADPCM is not terrible, it's just "meh". Compare: - Original, 4039kb: https://phoboslab.org/files/qoa-samples/adpcm_comp/orig.wav https://phoboslab.org/files/qoa-samples/adpcm_comp/orig.wav - MS ADPCM, 1022kb: https://phoboslab.org/files/qoa-samples/adpcm_comp/ms_adpcm.wav https://phoboslab.org/files/qoa-samples/adpcm_comp/ms_adpcm.... - QOA, 812kb: https://phoboslab.org/files/qoa-samples/adpcm_comp/qoa.wav https://phoboslab.org/files/qoa-samples/adpcm_comp/qoa.wav IMA ADPCM is in the same ballpark as MS ADPCM. ADX (not listed) comes close to QOA, but at 1136kb is also larger than those traditional ADPCM flavors.
- mouse_ 4y agoI was reading that article, and geez, as a non-programmer I have to ask, why does libflac look like such a nightmare compared to flacloader? It's like night and day. Is this a "WireGuard makes OpenVPN look quite silly" moment? https://github.com/xiph/flac/tree/master/src/libFLAC https://github.com/xiph/flac/tree/master/src/libFLAC https://github.com/SerenityOS/serenity/blob/master/Userland/Libraries/LibAudio/FlacLoader.cpp https://github.com/SerenityOS/serenity/blob/master/Userland/...
- lifthrasiir 4y agoBecause a shorter code is not necessarily performant, readable, or correct. Also the Serenity version delegates most dependencies like bit readers to its built-in library, while libflac implements all of them by itself.
- stephc_int13 4y agoThis is more frequent than you think. It does not mean that the code is bad or inefficient, but the style and architecture is not the simplest to read. Pretty much in the same way that published scientific papers are quite unpleasant to read.
- bartwe 4y agoVery interesting, when better formats like vorbis were too cpu intensive for my game I ended up with striped and delta encoded wav compressed using lz4hc for something that was somewhat compressed, streamable and light on the cpu, this seems somewhat close to that.
- weepy 4y agowhat is delta encoded ? ADPCM ?
- rogerhoward 4y ago"The first lossless audio format to gain widespread adoption (FLAC) was released 6 years after MP3." AIFF and WAV say what?
- jefftk 4y agoFrom context they mean lossless compression audio format, and standard AIFF and WAV are uncompressed PCM. On the other hand, AIFF does have a compressed variant ("AIFF-C") spec'd in 1991 [1], which I suspect the author wasn't aware of. [1] https://www.mmsp.ece.mcgill.ca/Documents/AudioFormats/AIFF/AIFF.html https://www.mmsp.ece.mcgill.ca/Documents/AudioFormats/AIFF/A...
- deleted 4y ago[deleted]
- bad_username 4y agoWAV is just a container format that can hold any audio stream, uncompressed (PCM) or compressed.
- jefftk 4y agoIt's not clear to me why Opus doesn't meet their needs. They write it off for not being simple, but is the problem that it's too slow for their application? Are they doing something where they need a very small compiled size [1]? Aesthetically prefer things that are simpler? [1] I ship an Opus encoder and decoder to the browser to support https://www.jefftk.com/p/bucket-brigade-singing https://www.jefftk.com/p/bucket-brigade-singing and it's just 310KB for compression and 470KB for decompression, which are small enough that I don't even minify them.
- super256 4y agoThis looks interesting! Do you have a link to the source code of the opus encoder and decoder? The code in the github repo (html/opusjs/decoder.js) looks generated and is hard to understand.
- jefftk 4y agoPretty sure it was https://github.com/Rillke/opusenc.js https://github.com/Rillke/opusenc.js (Normally this would be in the commit description but it looks like we forgot to include that https://github.com/jeffkaufman/bucket-brigade/commit/d96b6f31331da92c83f78bc6a182a4fcb6b8ea34 https://github.com/jeffkaufman/bucket-brigade/commit/d96b6f3...)
- phoboslab 4y agoCuriosity mostly. As stated in the article, Opus is excellent and better than QOA in every way except in complexity (and as a result, performance). A possible application for QOA is games, where you need to play dozens of audio files immediately. I haven't done any formal benchmarks, but with a simple `time` on the command line QOA encodes 10x faster and decodes 7x faster than Opus. QOA should be quite suitable for SIMD optimizations, which would improve performance even more. Still on my todo list.
- bsder 4y ago> (and as a result, performance) Citation, please. Opus (at that time it was called CELT) does have more resource requirements in terms of memory than an MP3 decoder. However, I have run the decoder on things as small as a 33MHz ARM7 and still had lots of CPU left over. An MP3 decoder had no hope on that system.
- distantsounds 4y ago"There still remains a huge gap between lossless codecs at ~800kb/s and MP3 at 128kb/s with seemingly little interest to fill it." Not only does mp3 go to 320kbps, 192kbps was considered the 'standard' for ripping audio CDs, with the V0 variable bit rate being another common choice. if this only does 277, what am I getting aside from. another audio codec?
- skrebbel 4y agoSimplicity and low cpu requirements.
- distantsounds 4y agothe only time I ever had issues playing MP3s was on an old overclocked 486
- skrebbel 4y agoThen maybe you’re not the target audience
- distantsounds 4y agothe target audience is practically non-existent. nobody with 40 year old hardware is clamoring for a new audio codec.
- cybrox 4y agoHave you heard about IoT and low-end consumer devices?
- distantsounds 4y agooh, you mean things like the ESP8266, which costs mere dollars and can definitely can already decode and play MP3s? 40 lines of code to play MP3s on an ESP32 as well.
- PaulHoule 4y agoLately I have been collecting MiniDisc hardware, one of those things that progresses from "I'll buy a deck from Japan" to seeing a deck at the thrift store and taking it home right away. The ATRAC codec used in Minidisc is similar in bitrate to the QOA although it is transform-based. I had a music technology prof ask me "How do you stand listening to something compressed?" I also have a monster CD changer https://www.crutchfield.com/S-sTSOm8D5jfj/p_158CDPX355/Sony-CDP-CX355.html https://www.crutchfield.com/S-sTSOm8D5jfj/p_158CDPX355/Sony-... which I am filling up with 5.1 DTS disks that play on my home theater. I told my son that I find it hard to listen to 2-channel minidiscs next to really good 5.1 recordings with good bass management, but this weekend I did some heads-up listening testing between 2-channel CDs and minidiscs I made from the CDs and I could not tell the difference on my stereo. I am somewhat picky, I think "128 kbps MP3 suck" and can prove it. More careful A/B testing through headphones might reveal more weaknesses in ATRAC and any codec has some files that will stress it, but I am impressed with the quality of ATRAC and also with the low complexity. I have a portable player that plays for hours that runs off a single AA battery, mechanical parts and all.
- ogurechny 4y agoNice, but if 24_tuba_arpegio_melodious_phrase_stereo on the samples page is not a conversion error, it might explain why at least basic psychoacoustic model and/or post-processing filter are expected. That static beat is noticeable precisely because of its repetition.
- phoboslab 4y agoGood catch! That's likely an artifact of the LMS state being quantized[1] at every frame border. I will look for ways to improve this. [1] https://github.com/phoboslab/qoa/blob/master/qoa.h#L324-L336 https://github.com/phoboslab/qoa/blob/master/qoa.h#L324-L336
- hcs 4y agoGiven how large the frames are in QOA, it doesn't seem like too much overhead to have the full history and weights stored per frame (if seeking to any frame is required).
- skrebbel 4y agoBack in the day I made a few GameBoy Advance demos and we generally stored ADPCM encoded audio streams for the music, at like 4x the space of an equivalent MP3. Thing is, cartridge space was effectively uncapped but CPU speed (4MHz iirc) was very limited. If we had gone for MP3 (or even a reasonably complex tracker module), we’d hardly have had any CPU left for the visuals. QOA would have likely been the perfect alternative! We’d have better sound quality with no downsides, I think.
- Jam-O 4y agoGreat! Excellent fit for DAWs where lots of samples stay in memory and decode concurrently.
- munificent 4y agoA DAW is definitely not going to want to use a lossy format. Most DAWs store audio internally as uncompressed 32-bit floats. That gives them plenty of headroom (which is important for gain staging).
- peterbmarks 4y agoI'd like to see a comparison with codec2 https://www.rowetel.com/wordpress/?page_id=452 https://www.rowetel.com/wordpress/?page_id=452
- nayuki 4y ago> All in all FLAC is not a complicated format. Not quite 400-lines-simple, but far from the complexities of Opus. Actually, FLAC is under 400-lines-simple. > This is my independent implementation FLAC, optimizing the code for clarity to a human reader. The decoder is implemented in about 300 lines of source code, and the encoder in ~200 lines. -- https://www.nayuki.io/page/simple-flac-implementation https://www.nayuki.io/page/simple-flac-implementation
- weepy 4y agoCould the algo prevent clicks in the case of packet loss in low latency streaming ?