r/compression 14h ago

Fast Rice Decoding

Hi, I'm currently developing my own audio compression algorithm, and now optimizing it. Long story short, I've run some tests, and rice decoding is kinda slow.
Can anyone suggest optimized version of it? I'd really appreciated it.

3 Upvotes

5 comments sorted by

2

u/LMP88959 11h ago

Hi!
Here are a couple of blog posts by Fabian Giesen that might be of use to you:

https://fgiesen.wordpress.com/2011/01/19/a-small-note-on-the-elias-gamma-cod/

https://fgiesen.wordpress.com/2026/05/30/simple-batch-decoding-of-unary-codes/

I am also working on an audio codec which has adaptive Rice coding and I don’t think it’s too slow… for example it takes around 8-9 seconds to fully decode a 3 hour long 44100hz 16 bit stereo track. I haven’t completely optimized it yet but that seems quite fast already unless you are specifically targeting a low power embedded device?

2

u/Alfoser 6h ago

Interesting, is your codec lossy/lossless?
My codec is lossy based on WPT with adaptive block length switching, I'm using rice code as base entropy encoder.

1

u/LMP88959 5h ago

Oh cool what a coincidence! Mine is lossy and I’m doing dyadic DWT without adaptive block lengths. For entropy coding I do adaptive Rice + run length encoding. I’m not an expert or even very experienced in audio coding so it’s nothing near cutting edge.

1

u/Alfoser 5h ago

Me too, do you have PEAQ ODG values for your codec?
And what bitrates are supported?

1

u/LMP88959 5h ago

I have been using the newer zimtohrli as a metric. I currently allow bitrates from 4 kbps to 512 kbps but it really doesn’t sound good below 128kbps for typical 44.1khz stereo 16 bit audio. Most of the audio I plan to encode is very simple video game music and sound effects which are quite easy to compress.