Unified · Split
| @@ -0,0 +1,6 @@ | |||
| 1 | add `--sub-border-style` and `--osd-border-style` options | ||
| 2 | the border style does not depend on `--(sub/osd)-border-color` and `--(sub/osd)-shadow-color`; now it depends solely on `--(sub/osd)-border-style` | ||
| 3 | make `--(sub/osd)-border-color` an alias of `--(sub/osd)-outline-color` | ||
| 4 | make `--(sub/osd)-border-size` an alias of `--(sub/osd)-outline-size` | ||
| 5 | make `--(sub/osd)-shadow-color` an alias of `--(sub/osd)-back-color`; they cannot both be set now | ||
| 6 | make `--osd-bar-border-size` an alias of `--osd-bar-outline-size` | ||
| @@ -2832,10 +2832,6 @@ Subtitles · 2831 unmodified lines | |||
| 2832 | 2832 | ||
| 2833 | Default: 55. | 2833 | Default: 55. |
| 2834 | 2834 | ||
| 2835 | ``--sub-back-color=<color>`` | ||
| 2836 | See ``--sub-color``. Color used for sub text background. You can use | ||
| 2837 | ``--sub-shadow-offset`` to change its size relative to the text. | ||
| 2838 | |||
| 2839 | ``--sub-blur=<0..20.0>`` | 2835 | ``--sub-blur=<0..20.0>`` |
| 2840 | Gaussian blur factor applied to the sub font border. | 2836 | Gaussian blur factor applied to the sub font border. |
| 2841 | 0 means no blur applied (default). | 2837 | 0 means no blur applied (default). |
| @@ -2846,15 +2842,48 @@ Subtitles · 4 unmodified lines | |||
| 2846 | ``--sub-italic=<yes|no>`` | 2842 | ``--sub-italic=<yes|no>`` |
| 2847 | Format text on italic. | 2843 | Format text on italic. |
| 2848 | 2844 | ||
| 2849 | ``--sub-border-color=<color>`` | 2845 | ``--sub-outline-color=<color>`` |
| 2850 | See ``--sub-color``. Color used for the sub font border. | 2846 | See ``--sub-color``. Color used for the sub font outline. |
| 2847 | |||
| 2848 | ``--sub-border-color`` is an alias for ``--sub-outline-color``. | ||
| 2849 | |||
| 2850 | ``--sub-back-color=<color>`` | ||
| 2851 | See ``--sub-color``. Color used for sub text background. | ||
| 2852 | |||
| 2853 | ``--sub-shadow-color`` is an alias for ``--sub-back-color``. | ||
| 2854 | |||
| 2855 | ``--sub-outline-size=<size>`` | ||
| 2856 | Size of the sub font outline in scaled pixels (see ``--sub-font-size`` | ||
| 2857 | for details). A value of 0 disables outlines. | ||
| 2851 | 2858 | ||
| 2852 | ``--sub-border-size=<size>`` | 2859 | ``--sub-border-size`` is an alias for ``--sub-outline-size``. |
| 2853 | Size of the sub font border in scaled pixels (see ``--sub-font-size`` | ||
| 2854 | for details). A value of 0 disables borders. | ||
| 2855 | 2860 | ||
| 2856 | Default: 3. | 2861 | Default: 3. |
| 2857 | 2862 | ||
| 2863 | ``--sub-border-style=<outline-and-shadow|opaque-box|background-box>`` | ||
| 2864 | The style of the border. | ||
| 2865 | |||
| 2866 | - ``outline-and-shadow``: draw outline and shadow. | ||
| 2867 | The size of the outline is determined by ``--sub-outline-size``, | ||
| 2868 | and the offset of the shadow is determined by ``--sub-shadow-offset``. | ||
| 2869 | The outline is colored by ``--sub-outline-color``, | ||
| 2870 | and the shadow is colored by ``--sub-back-color``. | ||
| 2871 | This corresponds to ``BorderStyle=1`` in the ASS spec. | ||
| 2872 | - ``opaque-box``: draw outline and shadow as opaque boxes that tightly wrap each lines of text. | ||
| 2873 | The margin of the outline opaque box is determined by ``--sub-outline-size``, | ||
| 2874 | and the offset of the shadow opaque box is determined by ``--sub-shadow-offset``. | ||
| 2875 | The outline opaque box is colored by ``--sub-outline-color``, | ||
| 2876 | and the shadow opaque box is colored by ``--sub-back-color``. | ||
| 2877 | Despite its name, the opaque box can be semi-transparent. | ||
| 2878 | This corresponds to ``BorderStyle=3`` in the ASS spec. | ||
| 2879 | - ``background-box``: draw a background box that bounds all lines of text. | ||
| 2880 | The background box is colored by ``--sub-back-color``, | ||
| 2881 | and the margin of the background box is determined by ``--sub-shadow-offset``. | ||
| 2882 | The behavior of the outline is the same as the ``outline-and-shadow`` style. | ||
| 2883 | This corresponds to ``BorderStyle=4``, which is a libass-specific extension. | ||
| 2884 | |||
| 2885 | Default: ``outline-and-shadow``. | ||
| 2886 | |||
| 2858 | ``--sub-color=<color>`` | 2887 | ``--sub-color=<color>`` |
| 2859 | Specify the color used for unstyled text subtitles. | 2888 | Specify the color used for unstyled text subtitles. |
| 2860 | 2889 | ||
| @@ -2924,15 +2953,6 @@ Subtitles · 63 unmodified lines | |||
| 2924 | if ``--sub-ass-override`` is not set to ``no``. | 2953 | if ``--sub-ass-override`` is not set to ``no``. |
| 2925 | Default: ``no``. | 2954 | Default: ``no``. |
| 2926 | 2955 | ||
| 2927 | ``--sub-shadow-color=<color>`` | ||
| 2928 | See ``--sub-color``. Color used for sub text shadow. | ||
| 2929 | |||
| 2930 | .. note:: | ||
| 2931 | |||
| 2932 | ignored when ``--sub-back-color`` is | ||
| 2933 | specified (or more exactly: when that option is not set to completely | ||
| 2934 | transparent). | ||
| 2935 | |||
| 2936 | ``--sub-shadow-offset=<size>`` | 2956 | ``--sub-shadow-offset=<size>`` |
| 2937 | Displacement of the sub text shadow in scaled pixels (see | 2957 | Displacement of the sub text shadow in scaled pixels (see |
| 2938 | ``--sub-font-size`` for details). A value of 0 disables shadows. | 2958 | ``--sub-font-size`` for details). A value of 0 disables shadows. |
| @@ -4411,14 +4431,13 @@ OSD · 1472 unmodified lines | |||
| 4411 | ``--osd-bar-h=<0.1-50>`` | 4431 | ``--osd-bar-h=<0.1-50>`` |
| 4412 | Height of the OSD bar, in percentage of the screen height (default: 3.125). | 4432 | Height of the OSD bar, in percentage of the screen height (default: 3.125). |
| 4413 | 4433 | ||
| 4414 | ``--osd-bar-border-size=<size>`` | 4434 | ``--osd-bar-outline-size=<size>`` |
| 4415 | Size of the border of the OSD bar in scaled pixels (see ``--sub-font-size`` | 4435 | Size of the outline of the OSD bar in scaled pixels (see ``--sub-font-size`` |
| 4416 | for details). | 4436 | for details). |
| 4417 | 4437 | ||
| 4418 | Default: 0.5. | 4438 | ``--osd-bar-border-size`` is an alias for ``--osd-bar-outline-size``. |
| 4419 | 4439 | ||
| 4420 | ``--osd-back-color=<color>`` | 4440 | Default: 0.5. |
| 4421 | See ``--sub-color``. Color used for OSD text background. | ||
| 4422 | 4441 | ||
| 4423 | ``--osd-blur=<0..20.0>`` | 4442 | ``--osd-blur=<0..20.0>`` |
| 4424 | Gaussian blur factor applied to the OSD font border. | 4443 | Gaussian blur factor applied to the OSD font border. |
| @@ -4430,15 +4449,27 @@ OSD · 5 unmodified lines | |||
| 4430 | ``--osd-italic=<yes|no>`` | 4449 | ``--osd-italic=<yes|no>`` |
| 4431 | Format text on italic. | 4450 | Format text on italic. |
| 4432 | 4451 | ||
| 4433 | ``--osd-border-color=<color>`` | 4452 | ``--osd-outline-color=<color>`` |
| 4434 | See ``--sub-color``. Color used for the OSD font border. | 4453 | See ``--sub-color``. Color used for the OSD font outline. |
| 4454 | |||
| 4455 | ``--osd-border-color`` is an alias for ``--osd-outline-color``. | ||
| 4456 | |||
| 4457 | ``--osd-back-color=<color>`` | ||
| 4458 | See ``--sub-color``. Color used for OSD text background. | ||
| 4459 | |||
| 4460 | ``--osd-shadow-color`` is an alias for ``--osd-back-color``. | ||
| 4435 | 4461 | ||
| 4436 | ``--osd-border-size=<size>`` | 4462 | ``--osd-outline-size=<size>`` |
| 4437 | Size of the OSD font border in scaled pixels (see ``--sub-font-size`` | 4463 | Size of the OSD font outline in scaled pixels (see ``--sub-font-size`` |
| 4438 | for details). A value of 0 disables borders. | 4464 | for details). A value of 0 disables outlines. |
| 4465 | |||
| 4466 | ``--osd-border-size`` is an alias for ``--osd-outline-size``. | ||
| 4439 | 4467 | ||
| 4440 | Default: 3. | 4468 | Default: 3. |
| 4441 | 4469 | ||
| 4470 | ``--osd-border-style=<outline-and-shadow|opaque-box|background-box>`` | ||
| 4471 | See ``--sub-border-style``. Style used for OSD text border. | ||
| 4472 | |||
| 4442 | ``--osd-color=<color>`` | 4473 | ``--osd-color=<color>`` |
| 4443 | Specify the color used for OSD. | 4474 | Specify the color used for OSD. |
| 4444 | See ``--sub-color`` for details. | 4475 | See ``--sub-color`` for details. |
| @@ -4495,14 +4526,6 @@ OSD · 50 unmodified lines | |||
| 4495 | respect the value of this option when deciding whether the elements | 4526 | respect the value of this option when deciding whether the elements |
| 4496 | are scaled with window size or not. | 4527 | are scaled with window size or not. |
| 4497 | 4528 | ||
| 4498 | ``--osd-shadow-color=<color>`` | ||
| 4499 | See ``--sub-color``. Color used for OSD shadow. | ||
| 4500 | |||
| 4501 | .. note:: | ||
| 4502 | |||
| 4503 | Ignored when ``--osd-back-color`` is specified (or more exactly: when | ||
| 4504 | that option is not set to completely transparent). | ||
| 4505 | |||
| 4506 | ``--osd-shadow-offset=<size>`` | 4529 | ``--osd-shadow-offset=<size>`` |
| 4507 | Displacement of the OSD shadow in scaled pixels (see | 4530 | Displacement of the OSD shadow in scaled pixels (see |
| 4508 | ``--sub-font-size`` for details). A value of 0 disables shadows. | 4531 | ``--sub-font-size`` for details). A value of 0 disables shadows. |
| @@ -398,7 +398,8 @@ const struct m_sub_options mp_osd_render_sub_opts = { · 397 unmodified lines | |||
| 398 | {"osd-bar-align-y", OPT_FLOAT(osd_bar_align_y), M_RANGE(-1.0, +1.0)}, | 398 | {"osd-bar-align-y", OPT_FLOAT(osd_bar_align_y), M_RANGE(-1.0, +1.0)}, |
| 399 | {"osd-bar-w", OPT_FLOAT(osd_bar_w), M_RANGE(1, 100)}, | 399 | {"osd-bar-w", OPT_FLOAT(osd_bar_w), M_RANGE(1, 100)}, |
| 400 | {"osd-bar-h", OPT_FLOAT(osd_bar_h), M_RANGE(0.1, 50)}, | 400 | {"osd-bar-h", OPT_FLOAT(osd_bar_h), M_RANGE(0.1, 50)}, |
| 401 | {"osd-bar-border-size", OPT_FLOAT(osd_bar_border_size), M_RANGE(0, 1000.0)}, | 401 | {"osd-bar-outline-size", OPT_FLOAT(osd_bar_outline_size), M_RANGE(0, 1000.0)}, |
| 402 | {"osd-bar-border-size", OPT_ALIAS("osd-bar-outline-size")}, | ||
| 402 | {"osd", OPT_SUBSTRUCT(osd_style, osd_style_conf)}, | 403 | {"osd", OPT_SUBSTRUCT(osd_style, osd_style_conf)}, |
| 403 | {"osd-scale", OPT_FLOAT(osd_scale), M_RANGE(0, 100)}, | 404 | {"osd-scale", OPT_FLOAT(osd_scale), M_RANGE(0, 100)}, |
| 404 | {"osd-scale-by-window", OPT_BOOL(osd_scale_by_window)}, | 405 | {"osd-scale-by-window", OPT_BOOL(osd_scale_by_window)}, |
| @@ -410,7 +411,7 @@ const struct m_sub_options mp_osd_render_sub_opts = { · 5 unmodified lines | |||
| 410 | .osd_bar_align_y = 0.5, | 411 | .osd_bar_align_y = 0.5, |
| 411 | .osd_bar_w = 75.0, | 412 | .osd_bar_w = 75.0, |
| 412 | .osd_bar_h = 3.125, | 413 | .osd_bar_h = 3.125, |
| 413 | .osd_bar_border_size = 0.5, | 414 | .osd_bar_outline_size = 0.5, |
| 414 | .osd_scale = 1, | 415 | .osd_scale = 1, |
| 415 | .osd_scale_by_window = true, | 416 | .osd_scale_by_window = true, |
| 416 | }, | 417 | }, |
| @@ -143,7 +143,7 @@ struct mp_osd_render_opts { · 142 unmodified lines | |||
| 143 | float osd_bar_align_y; | 143 | float osd_bar_align_y; |
| 144 | float osd_bar_w; | 144 | float osd_bar_w; |
| 145 | float osd_bar_h; | 145 | float osd_bar_h; |
| 146 | float osd_bar_border_size; | 146 | float osd_bar_outline_size; |
| 147 | float osd_scale; | 147 | float osd_scale; |
| 148 | bool osd_scale_by_window; | 148 | bool osd_scale_by_window; |
| 149 | struct osd_style_opts *osd_style; | 149 | struct osd_style_opts *osd_style; |
| @@ -514,7 +514,7 @@ local function update() · 513 unmodified lines | |||
| 514 | local clipping_coordinates = '0,' .. coordinate_top .. ',' .. | 514 | local clipping_coordinates = '0,' .. coordinate_top .. ',' .. |
| 515 | screenx .. ',' .. screeny | 515 | screenx .. ',' .. screeny |
| 516 | local ass = assdraw.ass_new() | 516 | local ass = assdraw.ass_new() |
| 517 | local has_shadow = mp.get_property('osd-back-color'):sub(2, 3) == '00' | 517 | local has_shadow = mp.get_property('osd-border-style'):find('box$') == nil |
| 518 | local style = '{\\r' .. | 518 | local style = '{\\r' .. |
| 519 | '\\1a&H00&\\3a&H00&\\1c&Heeeeee&\\3c&H111111&' .. | 519 | '\\1a&H00&\\3a&H00&\\1c&Heeeeee&\\3c&H111111&' .. |
| 520 | (has_shadow and '\\4a&H99&\\4c&H000000&' or '') .. | 520 | (has_shadow and '\\4a&H99&\\4c&H000000&' or '') .. |
| @@ -62,15 +62,10 @@ void mp_ass_set_style(ASS_Style *style, double res_y, · 61 unmodified lines | |||
| 62 | style->FontSize = opts->font_size * scale; | 62 | style->FontSize = opts->font_size * scale; |
| 63 | style->PrimaryColour = MP_ASS_COLOR(opts->color); | 63 | style->PrimaryColour = MP_ASS_COLOR(opts->color); |
| 64 | style->SecondaryColour = style->PrimaryColour; | 64 | style->SecondaryColour = style->PrimaryColour; |
| 65 | style->OutlineColour = MP_ASS_COLOR(opts->border_color); | 65 | style->OutlineColour = MP_ASS_COLOR(opts->outline_color); |
| 66 | if (opts->back_color.a) { | 66 | style->BackColour = MP_ASS_COLOR(opts->back_color); |
| 67 | style->BackColour = MP_ASS_COLOR(opts->back_color); | 67 | style->BorderStyle = opts->border_style; |
| 68 | style->BorderStyle = 4; // opaque box | 68 | style->Outline = opts->outline_size * scale; |
| 69 | } else { | ||
| 70 | style->BackColour = MP_ASS_COLOR(opts->shadow_color); | ||
| 71 | style->BorderStyle = 1; // outline | ||
| 72 | } | ||
| 73 | style->Outline = opts->border_size * scale; | ||
| 74 | style->Shadow = opts->shadow_offset * scale; | 69 | style->Shadow = opts->shadow_offset * scale; |
| 75 | style->Spacing = opts->spacing * scale; | 70 | style->Spacing = opts->spacing * scale; |
| 76 | style->MarginL = opts->margin_x * scale; | 71 | style->MarginL = opts->margin_x * scale; |
| @@ -48,10 +48,14 @@ static const m_option_t style_opts[] = { · 47 unmodified lines | |||
| 48 | {"font", OPT_STRING(font)}, | 48 | {"font", OPT_STRING(font)}, |
| 49 | {"font-size", OPT_FLOAT(font_size), M_RANGE(1, 9000)}, | 49 | {"font-size", OPT_FLOAT(font_size), M_RANGE(1, 9000)}, |
| 50 | {"color", OPT_COLOR(color)}, | 50 | {"color", OPT_COLOR(color)}, |
| 51 | {"border-color", OPT_COLOR(border_color)}, | 51 | {"outline-color", OPT_COLOR(outline_color)}, |
| 52 | {"shadow-color", OPT_COLOR(shadow_color)}, | ||
| 53 | {"back-color", OPT_COLOR(back_color)}, | 52 | {"back-color", OPT_COLOR(back_color)}, |
| 54 | {"border-size", OPT_FLOAT(border_size)}, | 53 | {"outline-size", OPT_FLOAT(outline_size)}, |
| 54 | {"border-color", OPT_ALIAS("outline-color"), .alias_use_prefix = true}, | ||
| 55 | {"shadow-color", OPT_ALIAS("back-color"), .alias_use_prefix = true}, | ||
| 56 | {"border-style", OPT_CHOICE(border_style, | ||
| 57 | {"outline-and-shadow", 1}, {"opaque-box", 3}, {"background-box", 4})}, | ||
| 58 | {"border-size", OPT_ALIAS("outline-size"), .alias_use_prefix = true}, | ||
| 55 | {"shadow-offset", OPT_FLOAT(shadow_offset)}, | 59 | {"shadow-offset", OPT_FLOAT(shadow_offset)}, |
| 56 | {"spacing", OPT_FLOAT(spacing), M_RANGE(-10, 10)}, | 60 | {"spacing", OPT_FLOAT(spacing), M_RANGE(-10, 10)}, |
| 57 | {"margin-x", OPT_INT(margin_x), M_RANGE(0, 300)}, | 61 | {"margin-x", OPT_INT(margin_x), M_RANGE(0, 300)}, |
| @@ -79,9 +83,10 @@ const struct m_sub_options osd_style_conf = { · 21 unmodified lines | |||
| 79 | .font = "sans-serif", | 83 | .font = "sans-serif", |
| 80 | .font_size = 55, | 84 | .font_size = 55, |
| 81 | .color = {255, 255, 255, 255}, | 85 | .color = {255, 255, 255, 255}, |
| 82 | .border_color = {0, 0, 0, 255}, | 86 | .outline_color = {0, 0, 0, 255}, |
| 83 | .shadow_color = {240, 240, 240, 128}, | 87 | .back_color = {240, 240, 240, 128}, |
| 84 | .border_size = 3, | 88 | .border_style = 1, |
| 89 | .outline_size = 3, | ||
| 85 | .shadow_offset = 0, | 90 | .shadow_offset = 0, |
| 86 | .margin_x = 25, | 91 | .margin_x = 25, |
| 87 | .margin_y = 22, | 92 | .margin_y = 22, |
| @@ -98,9 +103,10 @@ const struct m_sub_options sub_style_conf = { · 10 unmodified lines | |||
| 98 | .font = "sans-serif", | 103 | .font = "sans-serif", |
| 99 | .font_size = 55, | 104 | .font_size = 55, |
| 100 | .color = {255, 255, 255, 255}, | 105 | .color = {255, 255, 255, 255}, |
| 101 | .border_color = {0, 0, 0, 255}, | 106 | .outline_color = {0, 0, 0, 255}, |
| 102 | .shadow_color = {240, 240, 240, 128}, | 107 | .back_color = {240, 240, 240, 128}, |
| 103 | .border_size = 3, | 108 | .border_style = 1, |
| 109 | .outline_size = 3, | ||
| 104 | .shadow_offset = 0, | 110 | .shadow_offset = 0, |
| 105 | .margin_x = 25, | 111 | .margin_x = 25, |
| 106 | .margin_y = 22, | 112 | .margin_y = 22, |
| @@ -145,10 +145,10 @@ struct osd_style_opts { · 144 unmodified lines | |||
| 145 | char *font; | 145 | char *font; |
| 146 | float font_size; | 146 | float font_size; |
| 147 | struct m_color color; | 147 | struct m_color color; |
| 148 | struct m_color border_color; | 148 | struct m_color outline_color; |
| 149 | struct m_color shadow_color; | ||
| 150 | struct m_color back_color; | 149 | struct m_color back_color; |
| 151 | float border_size; | 150 | int border_style; |
| 151 | float outline_size; | ||
| 152 | float shadow_offset; | 152 | float shadow_offset; |
| 153 | float spacing; | 153 | float spacing; |
| 154 | int margin_x; | 154 | int margin_x; |
| @@ -375,18 +375,15 @@ static void get_osd_bar_box(struct osd_state *osd, struct osd_object *obj, · 374 unmodified lines | |||
| 375 | 375 | ||
| 376 | mp_ass_set_style(style, track->PlayResY, opts->osd_style); | 376 | mp_ass_set_style(style, track->PlayResY, opts->osd_style); |
| 377 | 377 | ||
| 378 | if (osd->opts->osd_style->back_color.a) { | 378 | // override the default osd opaque-box into plain outline. Otherwise |
| 379 | // override the default osd opaque-box into plain outline. Otherwise | 379 | // the opaque box is not aligned with the bar (even without shadow), |
| 380 | // the opaque box is not aligned with the bar (even without shadow), | 380 | // and each bar ass event gets its own opaque box - breaking the bar. |
| 381 | // and each bar ass event gets its own opaque box - breaking the bar. | 381 | style->BorderStyle = 1; // outline |
| 382 | style->BackColour = MP_ASS_COLOR(opts->osd_style->shadow_color); | ||
| 383 | style->BorderStyle = 1; // outline | ||
| 384 | } | ||
| 385 | 382 | ||
| 386 | *o_w = track->PlayResX * (opts->osd_bar_w / 100.0); | 383 | *o_w = track->PlayResX * (opts->osd_bar_w / 100.0); |
| 387 | *o_h = track->PlayResY * (opts->osd_bar_h / 100.0); | 384 | *o_h = track->PlayResY * (opts->osd_bar_h / 100.0); |
| 388 | 385 | ||
| 389 | style->Outline = opts->osd_bar_border_size; | 386 | style->Outline = opts->osd_bar_outline_size; |
| 390 | // Rendering with shadow is broken (because there's more than one shape) | 387 | // Rendering with shadow is broken (because there's more than one shape) |
| 391 | style->Shadow = 0; | 388 | style->Shadow = 0; |
| 392 | 389 | ||
| @@ -428,7 +425,7 @@ static void update_progbar(struct osd_state *osd, struct osd_object *obj) · 35 unmodified lines | |||
| 428 | 425 | ||
| 429 | struct ass_draw *d = &(struct ass_draw) { .scale = 4 }; | 426 | struct ass_draw *d = &(struct ass_draw) { .scale = 4 }; |
| 430 | 427 | ||
| 431 | if (osd->opts->osd_style->back_color.a) { | 428 | if (osd->opts->osd_style->back_color.a && osd->opts->osd_style->border_style != 1) { |
| 432 | // the bar style always ignores the --osd-back-color config - it messes | 429 | // the bar style always ignores the --osd-back-color config - it messes |
| 433 | // up the bar. draw an artificial box at the original back color. | 430 | // up the bar. draw an artificial box at the original back color. |
| 434 | struct m_color bc = osd->opts->osd_style->back_color; | 431 | struct m_color bc = osd->opts->osd_style->back_color; |