build: add '--enable-libmpv-static' option

Signed-off-by: wm4 <wm4@nowhere>
gl_lcms: use thread-safe lcms API, require lcms2 2.6

The error log callback was not thread-safe and not library-safe. And
apparently there were some other details that made it not library-safe,
such as a global lcms plugin registry.

Switch the the thread-safe API provided by lcms2 starting with 2.6.
Remove our approximate thread-safety hacks.

Note that lcms basically provides 2 APIs now, the old functions, and
the thread-safe alternatives whose names end with THR. Some functions
don't change, because they already have a context of some sort. Care
must be taken not to accidentally use old APIs.
video: introduce failure path for image allocations

Until now, failure to allocate image data resulted in a crash (i.e.
abort() was called). This was intentional, because it's pretty silly to
degrade playback, and in almost all situations, the OOM will probably
kill you anyway. (And then there's the standard Linux overcommit
behavior, which also will kill you at some point.)

But I changed my opinion, so here we go. This change does not affect
_all_ memory allocations, just image data. Now in most failure cases,
the output will just be skipped. For video filters, this coincidentally
means that failure is treated as EOF (because the playback core assumes
EOF if nothing comes out of the video filter chain). In other
situations, output might be in some way degraded, like skipping frames,
not scaling OSD, and such.

Functions whose return values changed semantics:

  mp_image_alloc
  mp_image_new_copy
  mp_image_new_ref
  mp_image_make_writeable
  mp_image_setrefp
  mp_image_to_av_frame_and_unref
  mp_image_from_av_frame
  mp_image_new_external_ref
  mp_image_new_custom_ref
  mp_image_pool_make_writeable
  mp_image_pool_get
  mp_image_pool_new_copy
  mp_vdpau_mixed_frame_create
  vf_alloc_out_image
  vf_make_out_image_writeable
  glGetWindowScreenshot
video: check image parameters

Make sure every video filter has valid parameters for input and output.
(This also ensures we don't take possibly invalid decoder output, or
feed invalid decodr/filter output to VOs.)

Also, the updated image size check now (almost) works like the
corresponding check in FFmpeg.
encode: disable playback framedropping

--framedrop is intended for playback only, and does nothing good with
encoding. It would just randomly drop frames.
demux_mkv: add S_DVBSUB

Probably works; untested.
build: check for 64bit stdatomic.h operations too

This fixes the build on platform where the atomic calls can't be turned into
lock-free instructions and thus need the external libatomic library (e.g. mips).
vo: make draw_image and vo_queue_image transfer image ownership

Basically a cosmetic change. This is probably more intuitive.
DOCS: remove coding-style.md to contribute.md

I wonder if this is better. The intention is to make the instructions
for sending patches more visible.
DOCS/contribute.md: move instructions for sending patches to the top

Separate to not confuse git history tracking.
video: remove redundant function

mp_image_params_from_image() is now trivial and can be removed.
video: correct spelling: mp_image_params_equals -> mp_image_params_equal

The type is struct mp_image_params, so the "params" should have a "s".
"equals" shouldn't, because it's plural for 2 params. Important.
sd_lavc: improve bitmap subtitle timing

Until now, bitmap subtitles were decoded at "some" point, and then
simply replaced the old subtitle. Although the subtitle is selected
by time (PTS), it could happen that a subtitle was replaced too early.
One consequence is that this might lead to flicker even if the
subtitles are timed to follow each other without a gap (although most
subtitles are explicitly timed to introduce such a gap). With this
commit the past 4 subtitles are kept (instead of 1), so that the
correct one can be picked by time. This should fix the aforementioned
cases, but more importantly will allow demuxing/decoding and video
display to be somewhat asynchronous.

Still missing: somehow making sure the correct range of decoded
subtitles is available, instead of just passing along whatever comes
from the demuxer, and hoping that 4 queued subtitles are enough. But it
should certainly be good enough for now.

This removes a check that resets the subtitles if the PTS is 5 minutes
before the end of the current subtitle; this is probably not needed.
options: allow adding multiple files with --audio-file

At least 1 person expected that this works this way.
gl_video: fix refcounting
manpage: remove bogus significant whitespace

Made the first line formatted differently.
vo_opengl: fix regression with opengl:pbo

In the pbo case, mpi was reassigned to a stack pointer, and later
deallocated. Just change the code so it doesn't need to be reassigned.
bootstrap: update waf website and version

Signed-off-by: Timothy Gu <timothygu99@gmail.com>
Signed-off-by: wm4 <wm4@nowhere>
video/out: fix redrawing with no video frame for some VOs

With the change to merge osd drawing into video frame drawing, some
bogus logic got in: they skipped drawing the OSD if no video frame is
available. This broke --no-video --force-window mode.
vo_sdl: fix clearing the screen on reconfig

Clear the texture on reconfig(). (We could probably also do this simpler
with a flag, but this is actually less complicated - except that we move
the code to "map" a texture to a separate function.)