Do not use separate buffer for grayscale/lightness/darkness inverse.

For grayscale image, the same values for the same buffer were returned, so
keep doing so. For colour images, calculating the value on the fly on hot
memory is not worse than reading cold memory.
Add stride value to the IMAGE structure, and use it to access the buffer.

This essentially allows us to reuse the buffer from the read AVFrame rather
than copy it into a newly-allocated buffer.
Remove the bitdepth setting from IMAGE structure.

This simplifies the code quite a bit, although it means that now the output
will be grayscale by default even for B/W input.
Use libav's AVFrame as internal representation and AVFrame for output.

This is a very wide change but it is needed to make sure that the code
works as intended. It also removes a lot of shortcut fastpaths that
probably hard performace quite a bit, but then it offloads a lot of work
back to libav.

The tests' output matches the original output bit by bit, with the
exception of the "generated by unpaper" comment that is gone.

The -d/--depth option is (temporarily) gone, in favour of the -t/--type
option that provides selection of 1-bit (pbm), 8-bit (pgm), 24-bit
(ppm). While right now we don't support any more output formats, it should
be trivial to add this back and collapse the three into "pnm", and adding a
separate "tiff" option.