mpv/sub
Avi Halachmi (:avih) 7ff4a27eb6 sub: jsre filter: abort init early on empty filter list
TL;DR: previously a JavaScript VM was created + destroyed whenever
       a sub track was initialized, even if no jsre filter was set.
       Now a JS VM is created only if jsre filters were set.

Sub filters are initialized once when a subtitle track is chosen, and
then whenever the sub track changes or when some sub options change.

Sub filters init is synchronous - playback is suspended till it ends.

A filter can abort init early (get disabled) depending on conditions
specific to each filter. The regex and jsre filters aborted early
if the filter is disabled (default is enabled) or if the track is not
ass (relativey rare, e.g. bitmap subs).

The init then iterates over the filter strings, and if the result is
empty (common - no filter was added, but also if all strings failed
regex init) then it's also aborted during init.

While this iteration step is cheap with filter regex, with jsre it
requires instanciating the JS VM (mujs) in advance in order to parse
the filter strings at the list, and the VM is then destroyed if the
list ends up empty.

This VM create+destroy is fast but measurable (0.2 - 0.7 ms, slowest
measured on 2010 MacBook Air), but can be avoided altogether if we
check that the filter list is not empty before we create the VM.

So now we do just that.
2022-06-09 14:38:24 +03:00
..
ass_mp.c sub: rename SUBBITMAP_RGBA to SUBBITMAP_BGRA 2022-01-11 23:45:08 +02:00
ass_mp.h
dec_sub.c options: only apply sub-visibility to primary subs 2022-01-22 16:22:25 +00:00
dec_sub.h options: only apply sub-visibility to primary subs 2022-01-22 16:22:25 +00:00
draw_bmp.c sub: rename SUBBITMAP_RGBA to SUBBITMAP_BGRA 2022-01-11 23:45:08 +02:00
draw_bmp.h
filter_jsre.c sub: jsre filter: abort init early on empty filter list 2022-06-09 14:38:24 +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 various: remove trailing whitespace 2022-05-14 14:51:34 +00:00
img_convert.c
img_convert.h
lavc_conv.c sub/lavc_conv: only set subtitle text format when required 2021-12-05 22:31:32 +02:00
osd.c sub/osd: use atomic for osd_state.force_video_pts 2022-04-02 21:41:58 +03:00
osd.h sub: rename SUBBITMAP_RGBA to SUBBITMAP_BGRA 2022-01-11 23:45:08 +02:00
osd_font.otf
osd_libass.c osd_libass: --osd-back-color: apply to the progress bar 2021-08-19 15:39:07 +03:00
osd_state.h sub/osd: use atomic for osd_state.force_video_pts 2022-04-02 21:41:58 +03: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 sub: rename SUBBITMAP_RGBA to SUBBITMAP_BGRA 2022-01-11 23:45:08 +02:00