For last couple of weeks I’ve been working on documenting and restructuring NihAV
. In result I’ve documented every public thing in my crates (except H.263 decoder skeleton but I need to need to debug and maybe rework it anyway) and NihAV
have final crate structure.
Speaking about crate structure, modern languages often suffer from npm.js
syndrome—when almost any trivial action has a separate package and most of the packages consist of imports from other packages. The other extremity would be to have two or three monolithic libraries with everything. I don’t think there’s a perfectly balanced solution so I split features using a few principles and I’ll stick to the scheme:
nihav-core
—the basis structure definitions like frame, packet, demuxer and decoder interfaces etc etc and utility code that should be used by both crates implementingNihAV
format support and various users (like my own decoding tool and player);nihav-registry
contains essentially three things: codec descriptions, codec mapping from e.g. FOURCC to codec name used byNihAV
(IMO it’s better to use a string as codec identifier instead of arbitrary number that may or may be not recognized by the different version of the library) and container detection code (i.e. something like whatfile
utility on UNIX does). This functionality can belong tonihav-core
but it’s expected to be updated way more often than the base code so I decided to finally split it out;nihav-codec-support
contains various pieces of code and data that are reused by many various decoders. It is intended just for decoders and has such bits as functions for testing decoder on some file, the skeleton for H.263 decoder (just add some functions for parsing headers and your new decoder is ready), motion compensation code, audio DSP bits (including FFT) and more;- various crates that cover codec families and related containers:
nihav-commonfmt
for AVI and codecs like AAC;nihav-duck
,nihav-indeo
,nihav-rad
andnihav-realmedia
for supporting corresponding codec families with e.g. Bink or RealMedia demuxers as well; andnihav-game
for supporting various codecs from various games with their unique demuxers; - and finally
nihav-allstuff
that simply re-exports decoder and demuxer registrations in singlenihav_register_all_codecs()
andnihav_register_all_demuxers()
. Also it has a test to check that all registered decoders have codec description innihav-registry
but nobody beside me should care about that.
Now with all of this done at last I can return to polishing other decoders which I still find more pleasant than documenting.