v4l2 is very liberal when it comes to formats: e.g. capture devices can deliver frames in virtually any format.
So if you are writing a user-land tool (application, library,...; as opposed to a kernel-driver), though shalt not fiddle with codecs (if you can avoid it).
Imagine each and every application in the world that wants to read v4l2-streams, having to add code to decode frames in SQ905C
or MJPEG
or whatnot codec (each application adding their own set of buggy implementation)
Instead, smart people created a library which will decompress the frames delivered by your capture device and provide these frames in a standard way: libv4l2.
Incidentally, if you insist on writing your own code, libv4l2
is a good reference implementation.
Oh, and if you were thinking about simpy loading a module to the encoding/decoding in kernel-space (e.g. you have webcam "foo" which delivers images in format "XYZ" but you want it to deliver images in format "ABC" by means of adding a kernel-module) then you are out of luck.
Linus T. has been quite clear [missing reference] that codec conversion code is not to be run within kernel-space.