af_lavcac3enc: switch to avcodec_encode_audio2()

avcodec_encode_audio() was deprecated, and was finally removed from
Libav and FFmpeg git.

This appears to work. I get heavy A/V desync with -ao alsa and -ao pcm,
but this was already so before this change.
image_writer: switch to avcodec_encode_video2()

avcodec_encode_video() was deprecated, and was finally removed from
Libav and FFmpeg git.

This change breaks compatibility with Libav 0.8.x. Thank the Libav
developers, not me.
Prefix CODEC_ID_ with AV_

The old names have been deprecated a while ago, but were needed for
supporting older ffmpeg/libav versions. The deprecated identifiers
have been removed from recent Libav and FFmpeg git.

This change breaks compatibility with Libav 0.8.x and equivalent
FFmpeg releases.
demux_lavf: use avg_frame_rate instead of r_frame_rate

r_frame_rate was deprecated and was finally removed from Libav and
FFmpeg git.

Not sure what's the correct replacement. avg_frame_rate may or may not
be worse than the fallback of using the time_base as guess. The
framerate is mostly unused, but needed for frame-based subtitles and for
encoding. (It appears encoding guesses a timebase based on the FPS, and
I'm not sure why we don't just use the source timebase.)
video: prepare for libavcodec refcounting

Some minor refactoring and moving code around.
There should be no functional changes.
video: make use of libavcodec refcounting

Now lavc_dr1.c is not used anymore if libavcodec is recent enough.
af_lavrresample: add new resampling filter to replace the old ones

Remove `af_resample` and `af_lavcresample`. The former is a mess while the
latter uses an API that was long deprecated in libavcodec and is now removed.

`af_lavrresample` rougly has the same features and structure of
`af_lavcresample`.

libswresample fallback by wm4.
configure: bump minimum FFmpeg/Libav versions, remove compat hacks

We consider FFmpeg 1.x and Libav 0.9.x releases compatible. Support
for FFmpeg 0.9.x and Libav 0.8.x is considered infeasible and has been
dropped in the previous commits. The bits that break compatibility are
mainly the CodecID renaming (trivial, but would require nasty hacks
everywhere), the avcodec_encode_video2() function (missing in older
releases, mandatory in newer ones), and the resampler changes (older
releases miss lib{av,sw}resample, newer versions removed the
libavcodec resampler).

Remove some other compatibility bits that were needed to for releases
for which we drop support.

The comment about Libav 0.9 in compat/libav.h is incorrect and should
have been 0.8 (the symbol is present in Libav 0.9).