diff options
author | Dudemanguy <random342@airmail.cc> | 2023-12-13 15:36:58 -0600 |
---|---|---|
committer | Dudemanguy <random342@airmail.cc> | 2023-12-16 15:25:32 +0000 |
commit | b0f31a76376cae73506e3969dff805de8a18b198 (patch) | |
tree | e3771b0debf9d881539ca6889262ddb982ad4921 /options | |
parent | ace2d6506f20dfc6a30d0bbb6cfb959f2144bfc9 (diff) | |
download | mpv-b0f31a76376cae73506e3969dff805de8a18b198.tar.bz2 mpv-b0f31a76376cae73506e3969dff805de8a18b198.tar.xz |
player: refactor secondary subtitle options and properties
Over the years, we've accumulated several secondary subtitle related
options and properties, but the implementation was not really consistent
and it wasn't clear what the right process for adding more should be. So
to make things nicer, let's refactor all of the subtitle options with
secondary variants (sub-delay, sub-pos, and sub-visibility) and split
them off to a new, separate struct. All of the underlying values are
stored in an array instead for simplicity. Additionally, the
implementation of some secondary-sub-* properties were slightly changed
so there would be less redundancy.
Diffstat (limited to 'options')
-rw-r--r-- | options/options.c | 33 | ||||
-rw-r--r-- | options/options.h | 14 |
2 files changed, 32 insertions, 15 deletions
diff --git a/options/options.c b/options/options.c index 8fb566c6f6..401eda919d 100644 --- a/options/options.c +++ b/options/options.c @@ -283,20 +283,14 @@ const struct m_sub_options mp_sub_filter_opts = { const struct m_sub_options mp_subtitle_sub_opts = { .opts = (const struct m_option[]){ - {"sub-delay", OPT_FLOAT(sub_delay[0])}, - {"secondary-sub-delay", OPT_FLOAT(sub_delay[1])}, {"sub-fps", OPT_FLOAT(sub_fps)}, {"sub-speed", OPT_FLOAT(sub_speed)}, - {"sub-visibility", OPT_BOOL(sub_visibility)}, - {"secondary-sub-visibility", OPT_BOOL(sec_sub_visibility)}, {"sub-forced-events-only", OPT_BOOL(sub_forced_events_only)}, {"stretch-dvd-subs", OPT_BOOL(stretch_dvd_subs)}, {"stretch-image-subs-to-screen", OPT_BOOL(stretch_image_subs)}, {"image-subs-video-resolution", OPT_BOOL(image_subs_video_res)}, {"sub-fix-timing", OPT_BOOL(sub_fix_timing)}, {"sub-stretch-durations", OPT_BOOL(sub_stretch_durations)}, - {"sub-pos", OPT_FLOAT(sub_pos), M_RANGE(0.0, 150.0)}, - {"secondary-sub-pos", OPT_FLOAT(sec_sub_pos), M_RANGE(0.0, 150.0)}, {"sub-gauss", OPT_FLOAT(sub_gauss), M_RANGE(0.0, 3.0)}, {"sub-gray", OPT_BOOL(sub_gray)}, {"sub-ass", OPT_BOOL(ass_enabled), .flags = UPDATE_SUB_HARD}, @@ -334,10 +328,6 @@ const struct m_sub_options mp_subtitle_sub_opts = { }, .size = sizeof(OPT_BASE_STRUCT), .defaults = &(OPT_BASE_STRUCT){ - .sub_visibility = true, - .sec_sub_visibility = true, - .sub_pos = 100, - .sec_sub_pos = 0, .sub_speed = 1.0, .ass_enabled = true, .sub_scale_by_window = true, @@ -356,6 +346,28 @@ const struct m_sub_options mp_subtitle_sub_opts = { }; #undef OPT_BASE_STRUCT +#define OPT_BASE_STRUCT struct mp_subtitle_shared_opts + +const struct m_sub_options mp_subtitle_shared_sub_opts = { + .opts = (const struct m_option[]){ + {"sub-delay", OPT_FLOAT(sub_delay[0])}, + {"secondary-sub-delay", OPT_FLOAT(sub_delay[1])}, + {"sub-pos", OPT_FLOAT(sub_pos[0]), M_RANGE(0.0, 150.0)}, + {"secondary-sub-pos", OPT_FLOAT(sub_pos[1]), M_RANGE(0.0, 150.0)}, + {"sub-visibility", OPT_BOOL(sub_visibility[0])}, + {"secondary-sub-visibility", OPT_BOOL(sub_visibility[1])}, + {0} + }, + .size = sizeof(OPT_BASE_STRUCT), + .defaults = &(OPT_BASE_STRUCT){ + .sub_visibility[0] = true, + .sub_visibility[1] = true, + .sub_pos[0] = 100, + }, + .change_flags = UPDATE_OSD, +}; + +#undef OPT_BASE_STRUCT #define OPT_BASE_STRUCT struct mp_osd_render_opts const struct m_sub_options mp_osd_render_sub_opts = { @@ -669,6 +681,7 @@ static const m_option_t mp_opts[] = { {"cover-art-whitelist", OPT_BOOL(coverart_whitelist)}, {"", OPT_SUBSTRUCT(subs_rend, mp_subtitle_sub_opts)}, + {"", OPT_SUBSTRUCT(subs_shared, mp_subtitle_shared_sub_opts)}, {"", OPT_SUBSTRUCT(subs_filt, mp_sub_filter_opts)}, {"", OPT_SUBSTRUCT(osd_rend, mp_osd_render_sub_opts)}, diff --git a/options/options.h b/options/options.h index c0ffd2c325..86344c52f6 100644 --- a/options/options.h +++ b/options/options.h @@ -82,11 +82,6 @@ typedef struct mp_vo_opts { // Subtitle options needed by the subtitle decoders/renderers. struct mp_subtitle_opts { - bool sub_visibility; - bool sec_sub_visibility; - float sub_pos; - float sec_sub_pos; - float sub_delay[2]; float sub_fps; float sub_speed; bool sub_forced_events_only; @@ -121,6 +116,13 @@ struct mp_subtitle_opts { bool sub_past_video_end; }; +// Options for both primary and secondary subs. +struct mp_subtitle_shared_opts { + float sub_delay[2]; + float sub_pos[2]; + bool sub_visibility[2]; +}; + struct mp_sub_filter_opts { bool sub_filter_SDH; bool sub_filter_SDH_harder; @@ -199,6 +201,7 @@ typedef struct MPOpts { bool cursor_autohide_fs; struct mp_subtitle_opts *subs_rend; + struct mp_subtitle_shared_opts *subs_shared; struct mp_sub_filter_opts *subs_filt; struct mp_osd_render_opts *osd_rend; @@ -398,6 +401,7 @@ extern const struct m_sub_options vo_sub_opts; extern const struct m_sub_options cuda_conf; extern const struct m_sub_options dvd_conf; extern const struct m_sub_options mp_subtitle_sub_opts; +extern const struct m_sub_options mp_subtitle_shared_sub_opts; extern const struct m_sub_options mp_sub_filter_opts; extern const struct m_sub_options mp_osd_render_sub_opts; extern const struct m_sub_options filter_conf; |