Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion. Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules. |
|
|
Thread Tools | Search this Thread | Display Modes |
3rd May 2024, 06:30 | #1 | Link |
Registered User
Join Date: Apr 2024
Posts: 14
|
Digital Subband Video 1 - Wavelet Codec in Less than 5000 Lines of C
Hi Doom9, I recently developed this:
https://github.com/LMP88959/Digital-Subband-Video-1 DSV1 is comparable to MPEG-1 / MPEG-2 but uses wavelets instead of the DCT. Click to expand comparison images: I intend to use it as a video codec for my game but I believe it might be of interest to some of you here Here is a little slideshow presentation I made explaining the codec and some of my thoughts on video compression: https://www.youtube.com/watch?v=zDm4GN-znBo Please understand I developed this codec out of passion and interest in the field, I didn't develop this for serious/professional use. Here is a quick description: - uses mutliresolution subband analysis (aka wavelet decomposition) instead of DCT - half-pixel motion compensation - supports 4:1:1, 4:2:0, 4:2:2, and 4:4:4 chroma subsampling formats - adaptive quantization - closed GOP with intra and inter frames (no B frames, only P frames for simplicity) - no complex entropy coding (only interleaved exponential-Golomb coding) - support for much lower bitrates than MPEG-1 / MPEG-2 The README and the PDF files in the GitHub have more information if you're curious. I've seen Cineform's codec, Dirac, and Snow but none of these were made to be comparable to the first generation of MPEG video, and Snow ended up being abandoned. DSV1 is the first "complete" wavelet video codec I am aware of that is comparable to MPEG-1 / MPEG-2 and not trying to compete with H.264 or MPEG-4 part 2. Please let me know your thoughts, positive and negative. If you find any bugs please let me know as well - EMMIR Last edited by LMP88959; 3rd May 2024 at 17:18. Reason: Updated image links to a better image hosting site |
3rd May 2024, 22:55 | #2 | Link |
Registered User
Join Date: Dec 2023
Posts: 18
|
not sure i really need another video codec at this point, but i'm interested.
my superficial look is that DSV1 maintains a lot of detail at expense of blurring out other parts of the frame or worse. Last edited by modus-ms325c; 3rd May 2024 at 22:55. Reason: image -> frame |
3rd May 2024, 23:01 | #3 | Link | |
Registered User
Join Date: Jun 2013
Posts: 103
|
Quote:
__________________
https://github.com/MoSal |
|
3rd May 2024, 23:29 | #4 | Link | ||
Registered User
Join Date: Apr 2024
Posts: 14
|
Quote:
Quote:
1. To let people know DSV1 isn't competitive with codecs newer than MPEG-1 / MPEG-2 2. To help group it into the same era of video codecs. 3. To invite others to compare it with those video coding standards. I hope that clarifies things for you |
||
4th May 2024, 06:26 | #5 | Link |
Registered User
Join Date: Dec 2013
Location: Berlin, Germany
Posts: 404
|
This is great.
You probably won't be able to start a business based on that but I am sure you learned a lot. As you are using HAAR for most things, have you tried to partition the picture in macroblocks like MPEG-1/2 ? This might make things more manageable and HAAR does not have funny edge effects. And for Inter I know you want short Wavelets, have you tried Daubechies 3 ? I remember that one fondly for Inter, even if used with somewhat small pixel blocks. If you want to shave of bits from your coefficient coding I recommend Range Coding, maybe look up that IBM paper from G. N. N. Martin / 1979. I think AV1 is using a flavor of that one too. This will make things more complicated and slower though so if speed and simplicity is your goal just pass. As for no Wavelet based video codecs you know being comparable to Mpeg-1/2, please keep in mind that lots of people made Wavelet based video codecs, block based hybrid ones even, but almost none made it in the spotlight because they just don't perform as well as macroblock based DCT codecs. Wavelet Codecs are mostly some academic thing. Another thing: I stalked your Github, what do you think of the following 68K texture span inner loop (texture stride = 255) ? Code:
move.b (%a1,%d2.w),%d6 ; load texel move.b %d6,(%a0)+ ; write texel add.w %a3,%d4 ; vfrac inc scs.b %d7 ; vfrac overflowed ? add.w %a2,%d5 ; ufrac inc addx.w %d3,%d2 ; combined u int + v int + ufrac overflow texel step add.w %d7,%d2 ; additional v texel step if vfrac overflowed PS: DSV1_spec.pdf, Page 16, 2nd MIN() -> MAX |
4th May 2024, 15:34 | #6 | Link | |||||
Registered User
Join Date: Apr 2024
Posts: 14
|
Quote:
Quote:
Quote:
Quote:
Quote:
Thanks for catching that! I just fixed it in the repo |
|||||
5th May 2024, 03:42 | #7 | Link | ||||
Registered User
Join Date: Dec 2013
Location: Berlin, Germany
Posts: 404
|
Quote:
Quote:
Quote:
Quote:
Like for example I have done this: https://www.youtube.com/watch?v=3WvSVB4nqjw |
||||
5th May 2024, 05:01 | #8 | Link | ||||
Registered User
Join Date: Apr 2024
Posts: 14
|
Quote:
Quote:
Quote:
Quote:
|
||||
5th May 2024, 11:25 | #9 | Link | |||
Registered User
Join Date: Dec 2013
Location: Berlin, Germany
Posts: 404
|
Quote:
Quote:
Quote:
|
|||
5th May 2024, 19:18 | #10 | Link | |||
Registered User
Join Date: Apr 2024
Posts: 14
|
Quote:
Quote:
Quote:
|
|||
6th May 2024, 18:16 | #11 | Link |
Registered User
Join Date: Dec 2013
Location: Berlin, Germany
Posts: 404
|
Well I guess the more you quantize, given the wavelet transform, the smaller the numbers you get and Exp-Golomb might become more and more optimal with rising quantization. For higher level subbands with larger coefficients or lower level subbands at low quantization EG might not be that optimal. One would have to do some empirical analysis where the bits are spent and how much better other approaches are...
|
7th May 2024, 17:58 | #12 | Link | |
Registered User
Join Date: Apr 2024
Posts: 14
|
Quote:
|
|
7th May 2024, 20:19 | #13 | Link |
Registered User
Join Date: Dec 2013
Location: Berlin, Germany
Posts: 404
|
Well for a quick test, have you tried writing a couple of subbands to files and then gzip'ing or 7zip'ing these? This might give some sort of hint what is possible.
Keep in mind if you implement some sort of entropy coder and keep things modular you can use it elsewhere too. Once you have written a couple of different modules you are able to just glue some together to get things done in another fun project. Like for asset compression or so. No need to use the libraries of other people... and no need to license the Unreal Engine .. |
8th May 2024, 17:39 | #14 | Link | |
Registered User
Join Date: Apr 2024
Posts: 14
|
Quote:
I have a Huffman coder in my 'toolbox' + a simple byte oriented RLE and that suffices for most of the data that needs compression in my game. Realistically this compression is highly unnecessary for the modern era since the game itself is like 20MB where most of that is audio (which is already ADPCM + Huffman), so there are no AAA sized assets. Adding cutscenes/video playback to the game would be quite a burden in terms of storage size though which is why I think DSV1 is actually the only truly 'necessary' compression I have in my arsenal. |
|
9th May 2024, 00:36 | #15 | Link | |
Registered User
Join Date: Dec 2013
Location: Berlin, Germany
Posts: 404
|
Quote:
Code:
sign = coefficient < 0 ? 1 : 0; out = ( abs( coefficient ) << 1 ) | sign; I mean wasnt it like this for (1D) Haar given the two pels a and b ?: Code:
H = b - a L = a + ( H / 2 ) It says so on bearcave.com/misl/misl_tech/wavelets/lifting/basiclift.html too so I seem to recall at least the Haar lifting transform correctly. I just googled around and there even seems to be software available that can generate lifting schemes and stuff from wavelet definitions automagically, we did not have that back then I think! I am getting old... |
|
9th May 2024, 03:01 | #16 | Link | |
Registered User
Join Date: Apr 2024
Posts: 14
|
Quote:
These are all great ideas, and it has been a nice back and forth we've had. It'll be fun to try them out when I get back to messing around with compression |
|
Tags |
codec, subband, wavelet |
Thread Tools | Search this Thread |
Display Modes | |
|
|