phoboslab / qoa

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

How does the 1-bit variant work? #47

Open ElijahHamilton opened 6 months ago

ElijahHamilton commented 6 months ago

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

phoboslab commented 6 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 6 months ago

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

phoboslab commented 6 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).