terminal: abstract terminal color handling

Instead of making msg.c an ifdef hell for unix vs. windows code, move
the code to separate functions defined in terminal-unix.c/terminal-
win.c.

Drop the code that selects random colors for --msgmodule prefixes.
terminal: remove separate formatting for --msgmodule

Instead, --msgmodule uses the same formatting as -v.
msg: change hack to silence command line pre-parse error messages

mp_msg_levels[] will go away.
msg: cosmetic changes

In particular, condense the legacy MSGT_ defines and move them to the
end of the file.
msg: change --msglevel, reduce legacy glue

Basically, reimplement --msglevel. Instead of making the new msg code
use the legacy code, make the legacy code use the reimplemented
functionality.

The handling of the deprecated --identify switch changes. It temporarily
stops working; this will be fixed in later commits.

The actual sub-options syntax (like --msglevel-vo=...) goes away, but I
bet nobody knew about this or used this anyway.
msg: use a global lock to synchronize printing

We have certain race conditions coming from doing multiple fprintf()
calls (setting up colors etc.). I'm not sure whether it would be worth
changing to code such that we do only one fprintf() call (and assume
this synchronizes access), but considering it would be hard to do
(Windows compatibility, ...), and that stdio uses per FILE locks anyway,
this is simpler and probably not less efficient. Also, there's no
problem handling the weird statusline special case this way.

Note that mp_msg_* calls which are silent won't acquire the lock, and
acquiring the lock happens on actual output only (which is slow and
serialized anyway).
msg: handle vsnprintf errors

I don't know under which circumstances this can error (other than a
broken format string). It seems it won't return an error code on I/O
errors, so maybe broken format strings are the only case. Either way,
don't continue if an error is returned.
ao_alsa: don't set ALSA message callback

This could output additional, potentially useful error messages. But the
callback is global and not library-safe, and would require us to add
additional state. Remove it, because it's obviously too much of a pain.
Also, it seems ALSA prints stuff to stderr anyway.
x11: don't set global error handler

This has similar problems as the ALSA message callback, though in theory
we could use the Display handle to find the right mpv instance from the
global callback. It still wouldn't work if another library happens to
set the error handler at the same time. There doesn't seem much of an
advantage overriding the error handler (though it used to be required),
so remove it.
video/filter: mp_msg conversions
video/decode: mp_msg conversions

Doesn't cover vdpau/vaapi parts yet, because these are a bit messier.
video/out: pass along global context

Will be needed for other parts (especially in gl_lcms.c).
gl_lcms: use global lock to deal with crappy lcms2 message callback

lcms2 has a global message callback for error reporting. If you don't
set this, these error messages are silently thrown away. I think we
still want the error messages, so we have to do dumb stuff to avoid
clashes. This doesn't handle the case if another library in the same
process sets the message callback, but at least this should exclude
possible memory errors when running multiple instances of mpv.
sws_utils: mp_msg conversions

This requires the caller to provide a mp_log in order to see error
messages. Unfortunately we don't do this in most places, but I guess we
have to live with it.
image_writer: mp_msg conversions

Adds an awkward mp_log argument for error messages.
video/fmt-conversion.c: remove unknown pixel format messages

This removes the messages printed on unknown pixel format messages.
Passing a mp_log to them would be too messy. Actually, this is a good
change, because in the past we often had trouble with these messages
printed too often (causing terminal spam etc.), and printing warnings or
error messages on the caller sides is much cleaner.

vd_lavc.c had a change earlier to print an error message if a decoder
outputs an unsupported pixel format.
vdpau: mp_msg conversions
vaapi: mp_msg conversions

This ended up a little bit messy. In order to get a mp_log everywhere,
mostly make use of the fact that va_surface already references global
state anyway.
bitmap_packer: use printf() for fatal message

This is printed right before abort(), which is bad style anyway.
Converting this to mp_msg will help nobody, and passing through a mp_log
is effort.
img_format: drop message about unknown pixel formats

Too bad.