mpv/sub
Guido Cella b6ebd1a15e sub: align ytdl-hook secondary subs to the top
29e15e6248 prefixed youtube-dl's subs url with an edl prefix to not
download them until they're selected, which is useful when there are
many sub languages. But this prefix broke the alignment of secondary
subs, which would overlap the primary subs instead of always being
placed at the top. This can be tested with
--sub-file='edl://!no_clip;!delay_open,media_type=sub;secondary_sub.srt'

When a sub is added, sub.c:reinit_sub() is called. This calls in
init_subdec() -> dec_sub.c:sub_create() -> init_decoder() ->
sd_ass:init(). Then reinit_sub() calls
sub_control(track->d_sub, SD_CTRL_SET_TOP, &(bool){!!order}) which sets
sd_ass_priv.on_top = true for secondary subs.

But for EDL subs the real sub is initialized again when in
dec_sub.c:sub_read_packets() is_new_segment() returns true and
update_segment() is called, or when sub_get_bitmaps() calls
update_segment(). update_segment() then calls init_decoder(), which
calls sd_ass:init(), so sd_ass_priv is reinitialized, and its on_top
property is left false. This commit sets it to true again.

For URLs that need to be downloaded it seems that the update_segment()
call that reinitializes sd_ass_priv is always the one in
sub_read_packets(), but with local subs sub_get_bitmaps() is usually
called earlier (though there shouldn't be a reason to use the EDL URL
for local subs), so I added the order parameter to sub_create(), rather
than adding it to all of update_segment(), sub_read_packets() and
sub_get_bitmaps().

Also removes the cast to bool in the other sub_control call, since
sub/sd_ass.c:control already casts arg to bool when cmd is
SD_CTRL_SET_TOP.
2021-08-11 18:15:35 +00: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 sub: align ytdl-hook secondary subs to the top 2021-08-11 18:15:35 +00:00
dec_sub.h sub: align ytdl-hook secondary subs to the top 2021-08-11 18:15:35 +00:00
draw_bmp.c video: clean up some imgfmt related stuff 2020-05-18 01:54:59 +02:00
draw_bmp.h draw_bmp: make another small guarantee to users 2020-05-13 22:46:29 +02:00
filter_jsre.c sub: sub-filter-regex and jsre: support ass-to-plaintext 2021-08-05 21:32:22 +03:00
filter_regex.c sub: sub-filter-regex and jsre: support ass-to-plaintext 2021-08-05 21:32:22 +03:00
filter_sdh.c sub: SDH filter: use unified text-extraction utils 2021-08-05 21:32:22 +03:00
img_convert.c
img_convert.h
lavc_conv.c build: address AVCodec, AVInputFormat, AVOutputFormat const warnings 2021-05-01 22:07:31 +02:00
osd.c sub/osd: hide secondary subtitles if secondary-sub-visibility is false 2021-05-19 15:56:43 +00:00
osd.h video: remove RGB32/BGR32 aliases 2020-05-11 19:57:34 +02:00
osd_font.otf osc: use custom symbols for window controls 2019-12-11 13:53:10 -08:00
osd_libass.c osd_libass: don't use deprecated ass_set_aspect_ratio 2020-08-28 19:52:48 +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 sub: sub-filter-regex and jsre: support ass-to-plaintext 2021-08-05 21:32:22 +03:00
sd_ass.c sub: sub-filter-regex and jsre: support ass-to-plaintext 2021-08-05 21:32:22 +03:00
sd_lavc.c build: address AVCodec, AVInputFormat, AVOutputFormat const warnings 2021-05-01 22:07:31 +02:00