From e056ad374fba75790f9703e967af2a29f3204257 Mon Sep 17 00:00:00 2001 From: nanahi <130121847+na-na-hi@users.noreply.github.com> Date: Sat, 26 Oct 2024 09:32:20 -0400 Subject: [PATCH] options: move mp_sub_filter_opts to sd_ass.c Also use sub-filter common prefix. --- options/options.c | 27 +++------------------------ options/options.h | 12 ------------ sub/sd.h | 11 +++++++++++ sub/sd_ass.c | 23 +++++++++++++++++++++++ 4 files changed, 37 insertions(+), 36 deletions(-) diff --git a/options/options.c b/options/options.c index 9b7df014de..a507cd37a1 100644 --- a/options/options.c +++ b/options/options.c @@ -101,6 +101,8 @@ extern const struct m_sub_options wingl_conf; extern const struct m_sub_options vaapi_conf; extern const struct m_sub_options egl_conf; +extern const struct m_sub_options mp_sub_filter_opts; + static const struct m_sub_options screenshot_conf = { .opts = image_writer_opts, .size = sizeof(struct image_writer_opts), @@ -275,29 +277,6 @@ const struct m_sub_options vo_sub_opts = { }, }; -#undef OPT_BASE_STRUCT -#define OPT_BASE_STRUCT struct mp_sub_filter_opts - -const struct m_sub_options mp_sub_filter_opts = { - .opts = (const struct m_option[]){ - {"sub-filter-sdh", OPT_BOOL(sub_filter_SDH)}, - {"sub-filter-sdh-harder", OPT_BOOL(sub_filter_SDH_harder)}, - {"sub-filter-sdh-enclosures", OPT_STRING(sub_filter_SDH_enclosures)}, - {"sub-filter-regex-enable", OPT_BOOL(rf_enable)}, - {"sub-filter-regex-plain", OPT_BOOL(rf_plain)}, - {"sub-filter-regex", OPT_STRINGLIST(rf_items)}, - {"sub-filter-jsre", OPT_STRINGLIST(jsre_items)}, - {"sub-filter-regex-warn", OPT_BOOL(rf_warn)}, - {0} - }, - .size = sizeof(OPT_BASE_STRUCT), - .defaults = &(OPT_BASE_STRUCT){ - .sub_filter_SDH_enclosures = "([\uFF08", - .rf_enable = true, - }, - .change_flags = UPDATE_SUB_FILT, -}; - #undef OPT_BASE_STRUCT #define OPT_BASE_STRUCT struct mp_subtitle_opts @@ -747,7 +726,7 @@ static const m_option_t mp_opts[] = { {"", 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)}, + {"sub-filter", OPT_SUBSTRUCT(subs_filt, mp_sub_filter_opts)}, {"", OPT_SUBSTRUCT(osd_rend, mp_osd_render_sub_opts)}, {"osd-bar", OPT_BOOL(osd_bar_visible), .flags = UPDATE_OSD}, diff --git a/options/options.h b/options/options.h index 347746f7c8..1af3e08871 100644 --- a/options/options.h +++ b/options/options.h @@ -134,17 +134,6 @@ struct mp_subtitle_shared_opts { int ass_style_override[2]; }; -struct mp_sub_filter_opts { - bool sub_filter_SDH; - bool sub_filter_SDH_harder; - char *sub_filter_SDH_enclosures; - bool rf_enable; - bool rf_plain; - char **rf_items; - char **jsre_items; - bool rf_warn; -}; - struct mp_osd_render_opts { float osd_bar_align_x; float osd_bar_align_y; @@ -424,7 +413,6 @@ 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; extern const struct m_sub_options resample_conf; diff --git a/sub/sd.h b/sub/sd.h index cb80c2eb22..284a60903c 100644 --- a/sub/sd.h +++ b/sub/sd.h @@ -67,6 +67,17 @@ bool lavc_conv_is_styled(struct lavc_conv *priv); void lavc_conv_reset(struct lavc_conv *priv); void lavc_conv_uninit(struct lavc_conv *priv); +struct mp_sub_filter_opts { + bool sub_filter_SDH; + bool sub_filter_SDH_harder; + char *sub_filter_SDH_enclosures; + bool rf_enable; + bool rf_plain; + char **rf_items; + char **jsre_items; + bool rf_warn; +}; + struct sd_filter { struct mpv_global *global; struct mp_log *log; diff --git a/sub/sd_ass.c b/sub/sd_ass.c index 2d837e8bf7..9e61c8c756 100644 --- a/sub/sd_ass.c +++ b/sub/sd_ass.c @@ -67,6 +67,29 @@ struct seen_packet { double pts; }; +#undef OPT_BASE_STRUCT +#define OPT_BASE_STRUCT struct mp_sub_filter_opts + +const struct m_sub_options mp_sub_filter_opts = { + .opts = (const struct m_option[]){ + {"sdh", OPT_BOOL(sub_filter_SDH)}, + {"sdh-harder", OPT_BOOL(sub_filter_SDH_harder)}, + {"sdh-enclosures", OPT_STRING(sub_filter_SDH_enclosures)}, + {"regex-enable", OPT_BOOL(rf_enable)}, + {"regex-plain", OPT_BOOL(rf_plain)}, + {"regex", OPT_STRINGLIST(rf_items)}, + {"jsre", OPT_STRINGLIST(jsre_items)}, + {"regex-warn", OPT_BOOL(rf_warn)}, + {0} + }, + .size = sizeof(OPT_BASE_STRUCT), + .defaults = &(OPT_BASE_STRUCT){ + .sub_filter_SDH_enclosures = "([\uFF08", + .rf_enable = true, + }, + .change_flags = UPDATE_SUB_FILT, +}; + static void mangle_colors(struct sd *sd, struct sub_bitmaps *parts); static void fill_plaintext(struct sd *sd, double pts);