mpv/sub
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
..
ass_mp.c video: make OSD/subtitle bitmaps refcounted (sort of) 2020-04-26 23:34:32 +02:00
ass_mp.h command: extend osd-overlay command with bounds reporting 2020-03-06 18:20:11 +01:00
dec_sub.c video: make OSD/subtitle bitmaps refcounted (sort of) 2020-04-26 23:34:32 +02:00
dec_sub.h video: make OSD/subtitle bitmaps refcounted (sort of) 2020-04-26 23:34:32 +02:00
draw_bmp.c draw_bmp: rewrite 2020-05-09 18:02:57 +02:00
draw_bmp.h draw_bmp: rewrite 2020-05-09 18:02:57 +02:00
filter_regex.c sub: add an option to filter subtitles by regex 2020-02-16 02:07:24 +01:00
filter_sdh.c sub: make filter_sdh a "proper" filter, allow runtime changes 2020-02-16 02:07:24 +01:00
img_convert.c Replace uses of FFMIN/MAX with MPMIN/MAX 2019-10-31 11:24:20 +01:00
img_convert.h
lavc_conv.c Remove remains of Libav compatibility 2020-02-16 15:14:55 +01:00
osd.c draw_bmp: rewrite 2020-05-09 18:02:57 +02:00
osd.h osd: add change timestamp and screen size to struct sub_bitmap_list 2020-05-09 18:02:57 +02:00
osd_font.otf osc: use custom symbols for window controls 2019-12-11 13:53:10 -08:00
osd_libass.c video: make OSD/subtitle bitmaps refcounted (sort of) 2020-04-26 23:34:32 +02:00
osd_state.h osd: add change timestamp and screen size to struct sub_bitmap_list 2020-05-09 18:02:57 +02:00
sd.h video: make OSD/subtitle bitmaps refcounted (sort of) 2020-04-26 23:34:32 +02:00
sd_ass.c video: make OSD/subtitle bitmaps refcounted (sort of) 2020-04-26 23:34:32 +02:00
sd_lavc.c sd_lavc: fix occasional problems with certain VOs when changing scaling 2020-05-09 18:02:57 +02:00