The single header lib also includes source code for an encoder utility and a playback app (both which makes use of other single header libs), behind conditional compile switches (ifdefs). Instructions for how to build them can be found at the top of the file.
31.08.2025 18:48 โ ๐ 2 ๐ 1 ๐ฌ 0 ๐ 0
The code is public domain, and available here github.com/mattiasgusta...
For most uses, you are probably better off using a real codec. But for something small, simple, self-contained with no dependencies, this might fit the bill.
31.08.2025 18:48 โ ๐ 8 ๐ 1 ๐ฌ 1 ๐ 0
The videos in the examples are compressed with my "default" setting, which makes them quite small, with ok-ish quality. On "max" they are more like dvd in size/quality. I focused on avoiding temporal aliasing, and I think i pulled that off quite well.
31.08.2025 18:48 โ ๐ 1 ๐ 1 ๐ฌ 1 ๐ 0
All in all, it seems like my quality/compression is maybe around dvd quality (?), so not in the same league as modern codecs (but attempting that would start to infringe on patents, so I don't particularly want to go down that route).
31.08.2025 18:48 โ ๐ 6 ๐ 1 ๐ฌ 1 ๐ 0
Here are two sample video snippets:
mattiasgustavsson.com/wasm/fmv.html
mattiasgustavsson.com/wasm/fmvdl.h...
(both are displayed with my CRT filter, because that's how I am most likely to be using this myself, but it can be toggled with F9).
31.08.2025 18:48 โ ๐ 2 ๐ 1 ๐ฌ 1 ๐ 0
I tried my hand at making a video codec. I didn't know the first thing about video codecs when I started, so was quite fun to learn about the concepts and how to implement them.
I packaged the result in a stb-style, single-file header-only lib, < 2500 loc with no dependencies.
31.08.2025 18:48 โ ๐ 84 ๐ 22 ๐ฌ 5 ๐ 1
QOI, and, by the looks of it, QOV (cool, I didn't know about that one) are both lossless, which is super cool, and such wonderfully simple formats too. Mine is a very lossy mpeg-like encoding, doing DCT compression and motion vectors and such things, so quite different, but still video compression ๐
31.08.2025 23:46 โ ๐ 1 ๐ 0 ๐ฌ 0 ๐ 0
The single header lib also includes source code for an encoder utility and a playback app (both which makes use of other single header libs), behind conditional compile switches (ifdefs). Instructions for how to build them can be found at the top of the file.
31.08.2025 18:48 โ ๐ 2 ๐ 1 ๐ฌ 0 ๐ 0
The code is public domain, and available here github.com/mattiasgusta...
For most uses, you are probably better off using a real codec. But for something small, simple, self-contained with no dependencies, this might fit the bill.
31.08.2025 18:48 โ ๐ 8 ๐ 1 ๐ฌ 1 ๐ 0
The videos in the examples are compressed with my "default" setting, which makes them quite small, with ok-ish quality. On "max" they are more like dvd in size/quality. I focused on avoiding temporal aliasing, and I think i pulled that off quite well.
31.08.2025 18:48 โ ๐ 1 ๐ 1 ๐ฌ 1 ๐ 0
All in all, it seems like my quality/compression is maybe around dvd quality (?), so not in the same league as modern codecs (but attempting that would start to infringe on patents, so I don't particularly want to go down that route).
31.08.2025 18:48 โ ๐ 6 ๐ 1 ๐ฌ 1 ๐ 0
Here are two sample video snippets:
mattiasgustavsson.com/wasm/fmv.html
mattiasgustavsson.com/wasm/fmvdl.h...
(both are displayed with my CRT filter, because that's how I am most likely to be using this myself, but it can be toggled with F9).
31.08.2025 18:48 โ ๐ 2 ๐ 1 ๐ฌ 1 ๐ 0
I tried my hand at making a video codec. I didn't know the first thing about video codecs when I started, so was quite fun to learn about the concepts and how to implement them.
I packaged the result in a stb-style, single-file header-only lib, < 2500 loc with no dependencies.
31.08.2025 18:48 โ ๐ 84 ๐ 22 ๐ฌ 5 ๐ 1
pow2_ceil.h
GitHub Gist: instantly share code, notes, and snippets.
Round a uint32 up to the nearest power-of-two value:
gist.github.com/mattiasgusta...
01.08.2025 13:45 โ ๐ 9 ๐ 1 ๐ฌ 1 ๐ 0
I found that on the latest compiler versions, my previous intrinsics-based implementations tripped some undefined behavior optimizations. fixed it now
03.08.2025 00:57 โ ๐ 0 ๐ 0 ๐ฌ 0 ๐ 0
pow2_ceil.h
GitHub Gist: instantly share code, notes, and snippets.
Round a uint32 up to the nearest power-of-two value:
gist.github.com/mattiasgusta...
01.08.2025 13:45 โ ๐ 9 ๐ 1 ๐ฌ 1 ๐ 0
I am excited to share this new single-header C library I have been working on for a while now: vecmath.h, a comprehensive vector/matrix math library for graphics/games/3d.
It allows you to write vector math code in C that looks like this:
21.07.2025 15:09 โ ๐ 99 ๐ 22 ๐ฌ 4 ๐ 0
that'd be cool :) the current vecmath.h is already very large, but I tried to limit its features to those found in HLSL and D3DX, to have as a baseline. There's many convenience functions and higher level functionality that could be added, so I'm considering a "vecmath_util.h" for all of those
25.07.2025 07:36 โ ๐ 1 ๐ 0 ๐ฌ 1 ๐ 0
If you're looking for a vector math lib for C (or C++) check it out
github.com/mattiasgusta...
If you do take a look, please let me know what you think about it - getting feedback is a big part of the reward releasing libraries like this, and I spent a lot of time and effort on it
21.07.2025 15:09 โ ๐ 11 ๐ 1 ๐ฌ 0 ๐ 0
It's been tested on windows, mac, linux and web-assembly, using msvc, clang, gcc and tcc (tiny c compiler).
21.07.2025 15:09 โ ๐ 6 ๐ 1 ๐ฌ 1 ๐ 0
It is not trying to be the most optimized library, not using any SIMD intrinsics or assembly code, just straightforward, fully portable, simple implementations of a large number of math functions.
21.07.2025 15:09 โ ๐ 7 ๐ 1 ๐ฌ 1 ๐ 0
It has a large set of functions, as it attempts to implement most of what you get in shader languages like HLSL and GLSL, and also most of the utility functions from libraries like D3DX in DirectX.
21.07.2025 15:09 โ ๐ 7 ๐ 1 ๐ฌ 1 ๐ 0
Even though it is primarily designed as a C library, I have also tried to make it fairly nice to use from C++, conditionally adding operator overloads and constructors, but it is not trying to be idiomatic "modern C++" in any way.
21.07.2025 15:09 โ ๐ 7 ๐ 1 ๐ฌ 1 ๐ 0
Here is the library: github.com/mattiasgusta...
Now, you get the best ergonomics if you use it with clang compiler in C11 or later, as it makes (optional) use of C11 _Generics and clang vector type extension, but it doesn't require either to work.
21.07.2025 15:09 โ ๐ 11 ๐ 3 ๐ฌ 1 ๐ 0
I see those kind of operations as very much outside the scope of this library, which focus more on basic operations matching the features of HLSL and D3DX. I think for any user that needs special case functions like that, it's easy for them to build out of the primitives provided in the lib
22.07.2025 07:14 โ ๐ 0 ๐ 0 ๐ฌ 0 ๐ 0
No, I don't use any optimizations like that, it's just pretty much the simplest implementation of textbook Cramerโs rule, for generic inversion
21.07.2025 17:39 โ ๐ 2 ๐ 0 ๐ฌ 1 ๐ 0
yeah, definitely give clang a go! i find that for my use cases, it compiles faster AND generates more performant code than both msvc and gcc. and, it got that taste vector extension :)
21.07.2025 17:33 โ ๐ 2 ๐ 0 ๐ฌ 0 ๐ 0
Oh, itโs got full support for matrices and quaternions too, the lib is very comprehensive - they are just not in the small example :)
21.07.2025 16:34 โ ๐ 5 ๐ 0 ๐ฌ 2 ๐ 0
it is similar, but also quite different - it does not allow you to access the elements using .x, .y, .z etc, only using [0],[1],[2].. so it didn't work well with the rest of my library design, so I opted to only support the clang one
21.07.2025 15:39 โ ๐ 4 ๐ 0 ๐ฌ 1 ๐ 0
Clang has a custom compiler extension for "vector types", so the operators part only works if you're building with clang - but clang is actually great on all platforms I use, so that works out ok :)
21.07.2025 15:24 โ ๐ 6 ๐ 0 ๐ฌ 1 ๐ 0
๐ซก Dyslexic, noisy introvert, contrarian technologist & Ai ethicist ๐ค
๐ Writer of odd books โก๏ธ www.trainor.fyi/books
๐ Creator of www.comicvault.cc
๐ด๐ต Palace Fan ๐ฆ
who mainly (re)posts about comics, Ai & music.
โก๏ธDonโt do things better, do better things ๐ซ
twitch: https://twitch.tv/tiger_j
YT: https://youtube.com/@TigerJGameJams
itch: https://tigerj.itch.io/
I stream game jam games and game dev.
~ Platinum Sponsor of Godot since 2023 ~ https://fund.godotengine.org/
~ Lifetime IGDA member since 2018
http://gcbaccaris.com ใWriter โข Game Developer ใ๐ชTwine Grimoire โฆ ๐ฎHarmony (DON'T NOD) โฆ ๐ชResurrection Gate โฆ TGA Future Class โฆ @IFtechfoundation.org Volunteer โฆ + editing, localization, narrative design
๐ชฉ patreon.com/gcbaccaris
๐ซ http://ko-fi.com/grimdev
First-Person Adventure RPG in development by Rambling Indie Games
https://patreon.com/lostrigdev
Maker of Things.
He / Him.
๐ง http://tarwin.art
๐ SF _ Melbourne
๐ค @tarwin@mastodon.social
๐ค @tarwin
๐ code & music for games โจ she/they
๐ worker-owner at @veryevildemons.com
Aspiring game designer ๐ซ
he/him
lead engine programmer at Insomniac Games, focusing on animation tech - my team develops the animation, cinematics, physics and destruction systems that underpin all our games
Photography (https://curious-creature.com), Blog (https://romainguy.dev). In the past: Engineering Director, Android Toolkit team at Google.
https://thenumb.at
Computer Graphics, Programming, Math, OxCaml, C++
I never had a crab cocktail in Malmรถ
Art, Music, and Code for Timeballs. Drummer. Atheist. Can't stand poetry and/or toxic positivity. No DMs please. Anthro/Furries creep me TF out #GameDev #SoloDev #GameMaker #noai #Smokefleet https://www.youtube.com/@bengelman2600
master of none
http://ivansafrin.com
currently working on:
https://store.steampowered.com/app/2886700/Star_Scum/
.. and another secret thing.
Developer (videogame & more : C++/C# unity3d/mobile and more currently engine/C++)
Bike/Vรฉlo : #velotaf / raymondistant le weekend / bikenerd / MDB / #Strava / #Squadrats / Sobre Versatile / Randocycle
Cook / Bread
Senior developer at Microsoft. Demoscener. Babylon.js core team. Technical Emmy Award winner with Golaem. AFOL. Personal views here!
Used to make games for a living, now I make games for fun! ๐น๏ธ
Biromantic ace, neurodivergent ๐ฆ He/him
Propic by @nannasaurus.bsky.social
https://www.giorgiopomettini.eu/
Game Designer/Artist | LFW | Designer/artist @ Valve | Lead Designer @ Double Fine | Lead Designer @ 3DO | Psychonauts, Brutal Legend, Portal2, CSGO, DOTA 2, The Lab, Artifact
25+ years making games professionally. On Signal @ ErikRobson.47