ao_lavc: stop using av_get_alt_sample_fmt

Use av_get_planar_sample_fmt instead.
[fix] compilation with Libav 0.8.x
[fix] mp_image: why not
[fix] alloc_mpi
[fix] "documentation"
[fix] unused
[fix] vf: some herp derp
[fix] remove some MP_IMAGE_ macros

These are accessible in a more direct way now.
video: cleanup: replace old mp_image function names

mp_image_alloc() also changes argument order compared to alloc_mpi().
The format now comes first, then width/height.
vo_lavc: use reference counting

Helps avoiding additional copies.
vd_lavc: make non-reference frames writeable

This allows avoiding a copy.

The logic about using the AVFrame.reference field if buffer hints are
not available is similar to mplayer-svn's direct rendering code. This is
needed because h264 decoding doesn't set buffer hints.

<wm4> michaelni: couldn't it set buffer hints from AVFrame.reference then?
<michaelni> i see no reason ATM why that wouldnt be possible

OK...
vd_lavc: prefer AVFrame over AVCodecContext fields

This is more correct and fixes pixel format changes during decoding. Not
all frame specific fields are in AVFrame, such as colorspace and
color_range.
video: simplify mp_image_make_writeable() usage, use image pool

Change mp_image_make_writeable() to take a mp_image* argument instead
of mp_image**. This means the image reference is the same even if the
image has to be copied, but its plane pointers will be set to the new
image data.

This makes the implementation of mp_image_make_writeable() more awkward
(requires the strange mp_image_steal_data() function), but should
simplify code that calls this function.

Also add vf_make_out_image_writeable(), which allocates new image data
from a pool. This avoids actual allocation/deallocation of image data
on each frame, which we consider something that should be avoided. Use
it for vf_divtc, which is the only filter which uses this function.
sub: do not copy the target image if there is no OSD/subs

It's not easy to tell whether the OSD/subs are empty, or if something is
drawn. In general you have to use osd_draw() with a custom callback. If
nothing is visible, the callback is never invoked. (The actual reason
why this is so "hard" is the implementation of osd_libass.c, which
doesn't allow separating rendering and drawing of OSD elements, because
all OSD elements share the same ASS_Renderer.)

To simplify avoiding copies, make osd_draw_on_image() instead of the
caller use mp_image_make_writeable(). Introduce osd_draw_on_image_p(),
which works like osd_draw_on_image(), but gets the new image allocation
from an image pool. This is supposed to be an optimization, because it
reduces the frequency of large allocations/deallocations for image data.

The result of this is that the frequency of copies needed in conjunction
with vf_sub, screenshots, and vo_lavc (encoding) should be reduced.
vf_sub now always does true pass-through if no subs are shown.

Drop the pts check from vf_sub. This didn't make much sense.
vo_xv: simplify

We can do this because slice support has been removed.
vo_x11: simplify
vo_xv, vo_x11: simplify OSD redrawing

In order to support OSD redrawing for vo_xv and vo_x11, draw_bmp.c
included an awkward "backup" mechanism to copy and restore image
regions that have been changed by OSD/subtitles.

Replace this by a much simpler mechanism: keep a reference to the
original image, and use that to restore the Xv/X framebuffers.

In the worst case, this may increase cache pressure, even if no OSD
or subtitles are rendered.
vo_xv: fix OSD redrawing flicker

redraw_frame() copied the image into the currently visible buffer. This
resulted in flicker when doing heavy OSD redrawing (like changing the
subtitle size to something absurdly large).

Use the same logic as draw_image instead.
vo_image: render subs

This makes it behave like vo_lavc.

Unfortunately, the code for setting up the OSD dimensions (mp_osd_res)
is copied from vo_lavc, but it doesn't look like something that should
be factored out.