osd: add option for "unscaled" OSD

This commit is contained in:
wm4 2013-12-10 19:58:57 +01:00
parent bf003033e3
commit 7c7d214775
6 changed files with 17 additions and 3 deletions

View File

@ -1558,6 +1558,12 @@ OPTIONS
``--osd-scale=<factor>``
OSD font size multiplicator, multiplied with ``--osd-font-size`` value.
``--osd-scale-by-window=yes|no``
Whether to scale the OSD with the window size (default: yes). If this is
disabled, ``--osd-font-size`` and other OSD options that use scaled pixels
are always in actual pixels. The effect is that changing the window size
won't change the OSD font size.
``--osd-shadow-color=<#RRGGBB>, --sub-text-shadow-color=<#RRGGBB>``
See ``--osd-color``. Color used for OSD/sub text shadow.

View File

@ -658,6 +658,7 @@ const m_option_t mp_opts[] = {
OPT_INTRANGE("osd-duration", osd_duration, 0, 0, 3600000),
OPT_FLAG("osd-fractions", osd_fractions, 0),
OPT_FLOATRANGE("osd-scale", osd_scale, 0, 0, 100),
OPT_FLAG("osd-scale-by-window", osd_scale_by_window, 0),
OPT_DOUBLE("sstep", step_sec, CONF_MIN, 0),
@ -797,6 +798,7 @@ const struct MPOpts mp_default_opts = {
.osd_bar_w = 75.0,
.osd_bar_h = 3.125,
.osd_scale = 1,
.osd_scale_by_window = 1,
.lua_load_osc = 1,
.loop_times = -1,
.ordered_chapters = 1,

View File

@ -189,6 +189,7 @@ typedef struct MPOpts {
float osd_bar_w;
float osd_bar_h;
float osd_scale;
int osd_scale_by_window;
struct osd_style_opts *osd_style;
struct osd_style_opts *sub_text_style;
float sub_scale;

View File

@ -39,7 +39,7 @@
// res_y should be track->PlayResY
// It determines scaling of font sizes and more.
void mp_ass_set_style(ASS_Style *style, int res_y,
void mp_ass_set_style(ASS_Style *style, double res_y,
const struct osd_style_opts *opts)
{
if (opts->font) {

View File

@ -44,7 +44,7 @@ struct MPOpts;
struct mp_osd_res;
struct osd_style_opts;
void mp_ass_set_style(ASS_Style *style, int res_y,
void mp_ass_set_style(ASS_Style *style, double res_y,
const struct osd_style_opts *opts);
void mp_ass_add_default_styles(ASS_Track *track, struct MPOpts *opts);

View File

@ -163,8 +163,13 @@ static void update_osd(struct osd_state *osd, struct osd_object *obj)
struct osd_style_opts font = *opts->osd_style;
font.font_size *= opts->osd_scale;
double playresy = obj->osd_track->PlayResY;
// Compensate for libass and mp_ass_set_style scaling the font etc.
if (!opts->osd_scale_by_window)
playresy *= 720.0 / obj->vo_res.h;
ASS_Style *style = obj->osd_track->styles + obj->osd_track->default_style;
mp_ass_set_style(style, obj->osd_track->PlayResY, &font);
mp_ass_set_style(style, playresy, &font);
char *text = mangle_ass(osd->osd_text);
add_osd_ass_event(obj->osd_track, text);