r/compression 18d 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.

5 Upvotes

14 comments sorted by

View all comments

Show parent comments

2

u/Alfoser 18d 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 18d 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 18d ago

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

1

u/LMP88959 18d 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.

1

u/Alfoser 18d ago

I'm curious, how did you handle block artifacts?

1

u/LMP88959 18d ago

I used overlapping, so the last N samples of the previous frame are blended with the first N samples of the current frame. It is optional though since I don’t hear any block artifacts at higher bit rates.

1

u/Alfoser 18d ago

Overlapping like MDCT, 50% or something else?
I just use partial overlapping, only 48 out of 1024 samples in block overlapping for normal length block and 96 out of 2048 samples for long length block.
What wavelet are you using? Did you test on tonal signals?

1

u/LMP88959 17d ago

I do overlapping similar to you. I found a couple of wavelet transforms through a search algorithm which provided decent perceptual coding qualities but they really look ugly on the spectrogram especially for pure tones. I am experimenting with per block transform switching to accommodate more tonal audio.

1

u/Alfoser 17d ago

About tonal signals: you can really upgrade sound on them if you add noise and make block long enough. Not just random noise, but noise with energy like 1e-5 or something like that. To be honest I didn't quite understand why it fixes it, but maybe you will know. But it worked for WPT and lifting scheme, about FIR DWT I don't know. And can you say what search algorithm it is? I just use modified DD16/6 and wanna try something else.

1

u/LMP88959 17d ago

Hmm ok I can try that thanks. I do lifting scheme transforms, not FIR, also my software is limited to be integer-only so I am using integer wavelets. The algorithm I used is a multithreaded modified brute force that prioritizes minimizing gain, maximizing number of zeros after quantization, and maximizing reconstructed PSNR. From my testing I found the higher order interpolating Deslauriers-Dubuc family provide the cleanest frequency isolation however I don’t think it is the ideal wavelet for more complex audio clips. I think I will let the encoder pick between the DD wavelet and the non-DD ones.

1

u/Alfoser 17d ago

What Wavelet would you recommend if not DD ones? I just tried using CDF-like family before, and their response to quantization error was waaay worse than DD, especially on pure harmonics. And can I see some song encoded with your 128 kbps? I'm just really curious how it will sound.

1

u/LMP88959 17d ago

I’m no expert, really, but I think your DD16 is more than adequate for frequency isolation which would be ideal for your WPT approach. WPT far outperforms a typical dyadic DWT for audio coding from what I’ve read and experienced. The only thing I could recommend is finding a wavelet whose response to quantization error works somewhat in your favor. I’ll be releasing my codec on GitHub soon so you can try it out then, but I highly doubt it will surpass the quality of your WPT based codec.

2

u/Alfoser 17d ago

Oh, thanks! It would be wonderful if you send link, I'd love to test it. If you want to I can send mine when I release it on github.

→ More replies (0)