1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-23 23:32:26 +00:00
mpv/video/filter
wm4 c1a961ad78 draw_bmp: rewrite
draw_bmp.c is the software blender for subtitles and OSD. It's used by
encoding mode (burning subtitles), and some VOs, like vo_drm, vo_x11,
vo_xv, and possibly more.

This changes the algorithm from upsampling the video to 4:4:4 and then
blending to downsampling the OSD and then blending directly to video.
This has far-reaching consequences for its internals, and results in an
effective rewrite.

Since I wanted to avoid un-premultiplying, all blending is done with
premultiplied alpha. That's actually the sane thing to do. The old code
just didn't do it, because it's very weird in YUV fixed point.
Essentially, you'd have to compensate for the chroma centering constant
by subtracting src_alpha/255*128. This seemed so hairy (especially with
correct rounding and high bit depths involved) that I went for using
float.

I think it turned out mostly OK, although it's more complex and less
maintainable than before. reinit() is certainly a bit too long. While it
should be possible to optimize the RGB path more (for example by
blending directly instead of doing the stupid float conversion), this is
probably slower. vo_xv users probably lose in this, because it takes the
slowest path (due to subsampling requirements and using YUV).

Why this rewrite? Nobody knows. I simply forgot the reason. But you'll
have it anyway. Whether or not this would have required a full rewrite,
at least it supports target alpha now (you can for example hard sub
transparent PNGs, if you ever wanted to use mpv for this).

Remove the check in vf_sub. The new draw_bmp.c is not as reliant on
libswscale anymore (mostly uses repack.c now), and osd.c shows an
error message on missing support instead now.

Formats with chroma subsampling of 4 are not supported, because FFmpeg
doesn't provide pixfmt definitions for alpha variants. We could provide
those ourselves (relatively trivial), but why bother.
2020-05-09 18:02:57 +02:00
..
refqueue.c
refqueue.h
vf_d3d11vpp.c options: change option macros and all option declarations 2020-03-18 19:52:01 +01:00
vf_fingerprint.c options: change option macros and all option declarations 2020-03-18 19:52:01 +01:00
vf_format.c vf:format: don't error when using convert=yes and not specifying fmt 2020-05-06 15:27:25 +02:00
vf_gpu.c options: change option macros and all option declarations 2020-03-18 19:52:01 +01:00
vf_sub.c draw_bmp: rewrite 2020-05-09 18:02:57 +02:00
vf_vapoursynth.c video: change chroma_w/chroma_h fields to use shift instead of size 2020-04-23 13:24:35 +02:00
vf_vavpp.c options: change option macros and all option declarations 2020-03-18 19:52:01 +01:00
vf_vdpaupp.c options: change option macros and all option declarations 2020-03-18 19:52:01 +01:00