phoboslab / qoa

The “Quite OK Audio Format” for fast, lossy audio compression
MIT License
747 stars 41 forks source link

How does the 1-bit variant work? #47

Open ElijahHamilton opened 3 months ago

ElijahHamilton commented 3 months ago

Hi, how does QOA work at 1-bit? Does it only store the residual at 1-bit? Or Something else?

phoboslab commented 3 months ago

Yes. It works similar to the other variants. Samples are divided into slices of 60. For each slice a 4-bit scalefactor and 60 1-bit residuals are stored. The 4-bit scalefactor and 1-bit residuals combined represent one of these values.

ElijahHamilton commented 3 months ago

Wouldn't that give a bitrate of 8533.33333 bits/s?

phoboslab commented 3 months ago

For 8khz mono, yes.

I guess I misunderstood your initial question.

Does it only store the residual at 1-bit

So, no, the scalefactor for every slice of 60 samples is also stored. That means the effective bitrate is 1.0666 bits per sample (ignoring the overhead for file and frame headers).