libav: major update and refactoring (close #839)

Also leaving 0_8 branch, as it's compatible with older ffmpeg versions.
I'm planning that all expressions will be able to switch easily
between ffmpeg and libav (whatever default we choose, but I prefer libav).

Edited (twice) according to notes on the reverted b003138.