Skip to main content
Topic: SELA v2 - A lossless audio codec with focus on simplicity and code quality (Read 1530 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

SELA v2 - A lossless audio codec with focus on simplicity and code quality

Before any of you get your pitchforks, this codec is supposed to be used for educational purposes not for compressing your CDs (there are better codecs for that  :D ). I wrote this codec 4 years ago as my final year project and recently I rewrote the whole thing from ground up in C++ and Java because I was unhappy with the code quality of original project. The main focus of this is code quality and simplicity so that people can understand how the math of lossless codecs work. The core encoder and decoder modules and the associated maths is just around 700 Lines of code and the total project is around 1.6k lines of code.

Project repository: https://github.com/sahaRatul/sela
Executables here: https://github.com/sahaRatul/sela/releases

How is the compression ratio you might ask. Well it's worse than FLAC but not hopeless. Most music comes to around 0.5-3 MB of file size differences though I have seen differences of upto 5-6 MBs as well in worst case scenarios.

Re: SELA v2 - A lossless audio codec with focus on simplicity and code quality

Reply #1
Difference in MBs is not informative, if the FLAC file is 7 MB, for example, then 6MB difference is big.
Much more interesting is to compare in %.
some ANC'd headphones + AutoEq-based impulse + Meier Crossfeed (30%)

Re: SELA v2 - A lossless audio codec with focus on simplicity and code quality

Reply #2
Very simple help when you run just the command line.
Seems to only accept 16-bit and 44.1kHz WAV files. Probably stereo only, too.

Tried a 24bit/96kHz file I bought from one of those digital stores and tried it out.
Resampled and lowered bit depth using "eac3to" to 16/44.1.
eac3to uses TPDF dithering and SSRC for resampling.

sample file: The Imperial Suite ("Rogue One: A Star Wars Story" soundtrack score by Michael Giacchino)
2:29.760 (14 376 961 samples), 24-bit, 96kHz (which metaflac says its 24bit (no wasted bits); do not care about the validity of the sample rate, as I downsample for encodes, anyway).
You can check out the track on DisneyMusicEVO on youtube to get an idea of what the content sounds like: https://www.youtube.com/watch?v=-C2wCcuKmLI


Using the 16/44.1 WAV file, the compressed encodes turned out as such:
14.3 MB (15,059,940 bytes) | Compression level 8 (exhaustive)
14.3 MB (15,075,885 bytes) | Compression level 8
14.4 MB (15,121,612 bytes) | Compression level 5 (default)
15.0 MB (15,796,422 bytes) | Compression level 0
15.1 MB (15,933,971 bytes) | SELA (unknown compression level)

Closer to Compression level 0 in FLAC, for default SELA parameters (as there are none to tweak).


Played it back in the command prompt window... THAT was weird. But it didn't sound bad. Wouldn't really know a difference unless I put headphones on and did a full double-blind ABX test.
Also, did not manage to record the timings for each encoding. FLAC.exe only tells me how many bytes were written and what the compression ratio was for each encode. I used CLI and no GUI.

Overall, not a bad experiment!
I like to use "HD audio" in PaulStretch. "HD audio", lol.

Re: SELA v2 - A lossless audio codec with focus on simplicity and code quality

Reply #3
Last version's exe file doesn't work, asks for three DLLs (libgcc_s_seh-1.dll, libstdc++-6.dll, libwinpthread-1.dll), after downloading god knows which versions from net, it won't start, 'Applications was unable to start correctly'.
Error 404; signature server not available.

Re: SELA v2 - A lossless audio codec with focus on simplicity and code quality

Reply #4
Very simple help when you run just the command line.
Seems to only accept 16-bit and 44.1kHz WAV files. Probably stereo only, too.

Tried a 24bit/96kHz file I bought from one of those digital stores and tried it out.
Resampled and lowered bit depth using "eac3to" to 16/44.1.
eac3to uses TPDF dithering and SSRC for resampling.

sample file: The Imperial Suite ("Rogue One: A Star Wars Story" soundtrack score by Michael Giacchino)
2:29.760 (14 376 961 samples), 24-bit, 96kHz (which metaflac says its 24bit (no wasted bits); do not care about the validity of the sample rate, as I downsample for encodes, anyway).
You can check out the track on DisneyMusicEVO on youtube to get an idea of what the content sounds like: https://www.youtube.com/watch?v=-C2wCcuKmLI


Using the 16/44.1 WAV file, the compressed encodes turned out as such:
14.3 MB (15,059,940 bytes) | Compression level 8 (exhaustive)
14.3 MB (15,075,885 bytes) | Compression level 8
14.4 MB (15,121,612 bytes) | Compression level 5 (default)
15.0 MB (15,796,422 bytes) | Compression level 0
15.1 MB (15,933,971 bytes) | SELA (unknown compression level)

Closer to Compression level 0 in FLAC, for default SELA parameters (as there are none to tweak).


Played it back in the command prompt window... THAT was weird. But it didn't sound bad. Wouldn't really know a difference unless I put headphones on and did a full double-blind ABX test.
Also, did not manage to record the timings for each encoding. FLAC.exe only tells me how many bytes were written and what the compression ratio was for each encode. I used CLI and no GUI.

Overall, not a bad experiment!

No there is no sample rate or channel count limitation. Only limitation is that it only supports 16 bit files but I am working on 24 bit support as well. Right now it's explicitly disabled sice there is a bug in Rice compression module which prevents file sizes from being generated correctly.

There shouldn't be any difference in audio quality since it's a lossless audio codec.

Programming a GUI is hard, so right now it simply plays in command line.

Re: SELA v2 - A lossless audio codec with focus on simplicity and code quality

Reply #5
Last version's exe file doesn't work, asks for three DLLs (libgcc_s_seh-1.dll, libstdc++-6.dll, libwinpthread-1.dll), after downloading god knows which versions from net, it won't start, 'Applications was unable to start correctly'.

Test the latest version because the last version is ancient, written 4 years ago. The latest one is basically a rewrite to bring code quality up to modern standards.

Re: SELA v2 - A lossless audio codec with focus on simplicity and code quality

Reply #6
Test the latest version because the last version is ancient, written 4 years ago. The latest one is basically a rewrite to bring code quality up to modern standards.

2.0.1, yes? That is the version that gives me problems. I've downloaded exe file and started it from command line.
Error 404; signature server not available.

Re: SELA v2 - A lossless audio codec with focus on simplicity and code quality

Reply #7
Interesting project! Kind of the same goal as my project SLAC, except that SLAC is just pure C.

I also had trouble running your new version because of its dependencies, but I was able to run your previous version (0.1.2-alpha). Surprisingly the compression ratio was almost identical to SLAC on the 1-hour corpus file I use for comparison testing.

Unfortunately, in about 3 places the restoration was not bit-exact over several samples. Hopefully that's been fixed in your new version, which I'll definitely try once there's a version without dependencies.

Re: SELA v2 - A lossless audio codec with focus on simplicity and code quality

Reply #8
RE: dependencies, I did a search for the first file mentioned (libgcc_s_seh-1.dll) and found it in several places (python, git, gnuplot,etc).
The only place where it's in the system's environment variables seems to be gnuplot.

For python and git, the env_var paths don't lead to where libgcc_s_seh-1.dll is located.

And regarding the sampling rate, I tried with 96kHz and it spat out some error that I've seen when the wrong format is used.
I like to use "HD audio" in PaulStretch. "HD audio", lol.

Re: SELA v2 - A lossless audio codec with focus on simplicity and code quality

Reply #9
Those dependencies are supposed to be copied from whichever version of MinGW was used to build the project, and are supposed to be bundled when distributed, since they change with every version of MinGW, therefore cannot simply be "downloaded from a DLL site".

Re: SELA v2 - A lossless audio codec with focus on simplicity and code quality

Reply #10
Those dependencies are supposed to be copied from whichever version of MinGW was used to build the project, and are supposed to be bundled when distributed, since they change with every version of MinGW, therefore cannot simply be "downloaded from a DLL site".

You are correct I guess, I have created a new release (v.2.0.2) and switched from MinGW to MSVC. That should fix DLL issues.

Re: SELA v2 - A lossless audio codec with focus on simplicity and code quality

Reply #11
Test the latest version because the last version is ancient, written 4 years ago. The latest one is basically a rewrite to bring code quality up to modern standards.

2.0.1, yes? That is the version that gives me problems. I've downloaded exe file and started it from command line.

Well, I have switched compilers from MinGW to MSVC and created a new release. Can you check v2.0.2 and see if that works :)?

Re: SELA v2 - A lossless audio codec with focus on simplicity and code quality

Reply #12
Interesting project! Kind of the same goal as my project SLAC, except that SLAC is just pure C.

I also had trouble running your new version because of its dependencies, but I was able to run your previous version (0.1.2-alpha). Surprisingly the compression ratio was almost identical to SLAC on the 1-hour corpus file I use for comparison testing.

Unfortunately, in about 3 places the restoration was not bit-exact over several samples. Hopefully that's been fixed in your new version, which I'll definitely try once there's a version without dependencies.

Hi David, I have switched to MSVC and created a new release. Can you check now? I was aware of the issue you mentioned. That was one of the motivations for the rewrite. 

Re: SELA v2 - A lossless audio codec with focus on simplicity and code quality

Reply #13
RE: dependencies, I did a search for the first file mentioned (libgcc_s_seh-1.dll) and found it in several places (python, git, gnuplot,etc).
The only place where it's in the system's environment variables seems to be gnuplot.

For python and git, the env_var paths don't lead to where libgcc_s_seh-1.dll is located.

And regarding the sampling rate, I tried with 96kHz and it spat out some error that I've seen when the wrong format is used.

Did you manage to run v2.0.1/v2.0.2? What error did you receive for the file you tested?

Re: SELA v2 - A lossless audio codec with focus on simplicity and code quality

Reply #14
RE: dependencies, I did a search for the first file mentioned (libgcc_s_seh-1.dll) and found it in several places (python, git, gnuplot,etc).
The only place where it's in the system's environment variables seems to be gnuplot.

For python and git, the env_var paths don't lead to where libgcc_s_seh-1.dll is located.

And regarding the sampling rate, I tried with 96kHz and it spat out some error that I've seen when the wrong format is used.

Did you manage to run v2.0.1/v2.0.2? What error did you receive for the file you tested?

I'm not sure what happened, but it encodes the 96kHz file now.
v.1 and .2 encode the 96kHz wav file.
I like to use "HD audio" in PaulStretch. "HD audio", lol.

Re: SELA v2 - A lossless audio codec with focus on simplicity and code quality

Reply #15
Interesting project! Kind of the same goal as my project SLAC, except that SLAC is just pure C.

I also had trouble running your new version because of its dependencies, but I was able to run your previous version (0.1.2-alpha). Surprisingly the compression ratio was almost identical to SLAC on the 1-hour corpus file I use for comparison testing.

Unfortunately, in about 3 places the restoration was not bit-exact over several samples. Hopefully that's been fixed in your new version, which I'll definitely try once there's a version without dependencies.

Hi David, I have switched to MSVC and created a new release. Can you check now? I was aware of the issue you mentioned. That was one of the motivations for the rewrite. 
Okay, the new MSVC works for me now. Tried a 1-minute and a 5-minute file and they decoded bit-perfect, except that a tiny portion was missing from the end in both cases.

However, when I tried my 1-hour plus file the program gobbled up all available memory and most of the CPU and I could barely regain control of the system! Not sure what's going on there, but it prevented me from verifying the data (it had generated no output once I was finally able to kill it). I'm on Windows 7.

Another thing I noticed is that it crashes if the input file doesn't exist.  :)

Re: SELA v2 - A lossless audio codec with focus on simplicity and code quality

Reply #16
Interesting project! Kind of the same goal as my project SLAC, except that SLAC is just pure C.

I also had trouble running your new version because of its dependencies, but I was able to run your previous version (0.1.2-alpha). Surprisingly the compression ratio was almost identical to SLAC on the 1-hour corpus file I use for comparison testing.

Unfortunately, in about 3 places the restoration was not bit-exact over several samples. Hopefully that's been fixed in your new version, which I'll definitely try once there's a version without dependencies.

Hi David, I have switched to MSVC and created a new release. Can you check now? I was aware of the issue you mentioned. That was one of the motivations for the rewrite. 
Okay, the new MSVC works for me now. Tried a 1-minute and a 5-minute file and they decoded bit-perfect, except that a tiny portion was missing from the end in both cases.

However, when I tried my 1-hour plus file the program gobbled up all available memory and most of the CPU and I could barely regain control of the system! Not sure what's going on there, but it prevented me from verifying the data (it had generated no output once I was finally able to kill it). I'm on Windows 7.

Another thing I noticed is that it crashes if the input file doesn't exist.  :)

To keep things simple, the entire wav file will be loaded to memory before processing. Plus the program also stores the entire encoded file on memory as well before writing it on disk. Also, it uses C++ vectors instead of C style arrays which have their own overhead. CPU usage can be explained by the fact that both encoder and decoder is multithreaded which means it will use all cores you have in your CPU for encoding/decoding. So yeah, overall the code is not very optimized :).

Re: SELA v2 - A lossless audio codec with focus on simplicity and code quality

Reply #17
It turns out a very strong break with FLAC  :o > test file


Re: SELA v2 - A lossless audio codec with focus on simplicity and code quality

Reply #19
It turns out a very strong break with FLAC  :o > test file

Whelp, that is definitely one of the worst results I have seen from this codec.
You have to check for zeroed LSBs to do well on this file. It's really just an 8-bit file.

 
SimplePortal 1.0.0 RC1 © 2008-2020