mirror of
https://github.com/mpv-player/mpv.git
synced 2025-12-28 05:33:14 +00:00
options: move OSD bar opts to a separate struct
Move them to a suboption so the suboption prefix can be used.
This commit is contained in:
@@ -390,17 +390,8 @@ const struct m_sub_options mp_subtitle_shared_sub_opts = {
|
|||||||
|
|
||||||
const struct m_sub_options mp_osd_render_sub_opts = {
|
const struct m_sub_options mp_osd_render_sub_opts = {
|
||||||
.opts = (const struct m_option[]){
|
.opts = (const struct m_option[]){
|
||||||
{"osd-bar-align-x", OPT_FLOAT(osd_bar_align_x), M_RANGE(-1.0, +1.0)},
|
|
||||||
{"osd-bar-align-y", OPT_FLOAT(osd_bar_align_y), M_RANGE(-1.0, +1.0)},
|
|
||||||
{"osd-bar-w", OPT_FLOAT(osd_bar_w), M_RANGE(1, 100)},
|
|
||||||
{"osd-bar-h", OPT_FLOAT(osd_bar_h), M_RANGE(0.1, 50)},
|
|
||||||
{"osd-bar-outline-size", OPT_FLOAT(osd_bar_outline_size), M_RANGE(0, 1000.0)},
|
|
||||||
{"osd-bar-border-size", OPT_ALIAS("osd-bar-outline-size")},
|
|
||||||
{"osd-bar-marker-scale", OPT_FLOAT(osd_bar_marker_scale), M_RANGE(0, 100.0)},
|
|
||||||
{"osd-bar-marker-min-size", OPT_FLOAT(osd_bar_marker_min_size), M_RANGE(0, 1000.0)},
|
|
||||||
{"osd-bar-marker-style", OPT_CHOICE(osd_bar_marker_style,
|
|
||||||
{"none", 0}, {"triangle", 1}, {"line", 2})},
|
|
||||||
{"osd", OPT_SUBSTRUCT(osd_style, osd_style_conf)},
|
{"osd", OPT_SUBSTRUCT(osd_style, osd_style_conf)},
|
||||||
|
{"osd-bar", OPT_SUBSTRUCT(osd_bar_style, osd_bar_style_conf)},
|
||||||
{"osd-scale", OPT_FLOAT(osd_scale), M_RANGE(0, 100)},
|
{"osd-scale", OPT_FLOAT(osd_scale), M_RANGE(0, 100)},
|
||||||
{"osd-scale-by-window", OPT_BOOL(osd_scale_by_window)},
|
{"osd-scale-by-window", OPT_BOOL(osd_scale_by_window)},
|
||||||
{"force-rgba-osd-rendering", OPT_BOOL(force_rgba_osd)},
|
{"force-rgba-osd-rendering", OPT_BOOL(force_rgba_osd)},
|
||||||
@@ -408,13 +399,6 @@ const struct m_sub_options mp_osd_render_sub_opts = {
|
|||||||
},
|
},
|
||||||
.size = sizeof(OPT_BASE_STRUCT),
|
.size = sizeof(OPT_BASE_STRUCT),
|
||||||
.defaults = &(OPT_BASE_STRUCT){
|
.defaults = &(OPT_BASE_STRUCT){
|
||||||
.osd_bar_align_y = 0.5,
|
|
||||||
.osd_bar_w = 75.0,
|
|
||||||
.osd_bar_h = 3.125,
|
|
||||||
.osd_bar_outline_size = 0.5,
|
|
||||||
.osd_bar_marker_scale = 1.3,
|
|
||||||
.osd_bar_marker_min_size = 1.6,
|
|
||||||
.osd_bar_marker_style = 1,
|
|
||||||
.osd_scale = 1,
|
.osd_scale = 1,
|
||||||
.osd_scale_by_window = true,
|
.osd_scale_by_window = true,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -135,17 +135,10 @@ struct mp_subtitle_shared_opts {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct mp_osd_render_opts {
|
struct mp_osd_render_opts {
|
||||||
float osd_bar_align_x;
|
|
||||||
float osd_bar_align_y;
|
|
||||||
float osd_bar_w;
|
|
||||||
float osd_bar_h;
|
|
||||||
float osd_bar_outline_size;
|
|
||||||
float osd_bar_marker_scale;
|
|
||||||
float osd_bar_marker_min_size;
|
|
||||||
int osd_bar_marker_style;
|
|
||||||
float osd_scale;
|
float osd_scale;
|
||||||
bool osd_scale_by_window;
|
bool osd_scale_by_window;
|
||||||
struct osd_style_opts *osd_style;
|
struct osd_style_opts *osd_style;
|
||||||
|
struct osd_bar_style_opts *osd_bar_style;
|
||||||
bool force_rgba_osd;
|
bool force_rgba_osd;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
31
sub/osd.c
31
sub/osd.c
@@ -116,6 +116,37 @@ const struct m_sub_options sub_style_conf = {
|
|||||||
.change_flags = UPDATE_OSD,
|
.change_flags = UPDATE_OSD,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#undef OPT_BASE_STRUCT
|
||||||
|
#define OPT_BASE_STRUCT struct osd_bar_style_opts
|
||||||
|
static const m_option_t bar_style_opts[] = {
|
||||||
|
{"align-x", OPT_FLOAT(align_x), M_RANGE(-1.0, +1.0)},
|
||||||
|
{"align-y", OPT_FLOAT(align_y), M_RANGE(-1.0, +1.0)},
|
||||||
|
{"w", OPT_FLOAT(w), M_RANGE(1, 100)},
|
||||||
|
{"h", OPT_FLOAT(h), M_RANGE(0.1, 50)},
|
||||||
|
{"outline-size", OPT_FLOAT(outline_size), M_RANGE(0, 1000.0)},
|
||||||
|
{"border-size", OPT_ALIAS("osd-bar-outline-size")},
|
||||||
|
{"marker-scale", OPT_FLOAT(marker_scale), M_RANGE(0, 100.0)},
|
||||||
|
{"marker-min-size", OPT_FLOAT(marker_min_size), M_RANGE(0, 1000.0)},
|
||||||
|
{"marker-style", OPT_CHOICE(marker_style,
|
||||||
|
{"none", 0}, {"triangle", 1}, {"line", 2})},
|
||||||
|
{0}
|
||||||
|
};
|
||||||
|
|
||||||
|
const struct m_sub_options osd_bar_style_conf = {
|
||||||
|
.opts = bar_style_opts,
|
||||||
|
.size = sizeof(struct osd_bar_style_opts),
|
||||||
|
.defaults = &(const struct osd_bar_style_opts){
|
||||||
|
.align_y = 0.5,
|
||||||
|
.w = 75.0,
|
||||||
|
.h = 3.125,
|
||||||
|
.outline_size = 0.5,
|
||||||
|
.marker_scale = 1.3,
|
||||||
|
.marker_min_size = 1.6,
|
||||||
|
.marker_style = 1,
|
||||||
|
},
|
||||||
|
.change_flags = UPDATE_OSD,
|
||||||
|
};
|
||||||
|
|
||||||
bool osd_res_equals(struct mp_osd_res a, struct mp_osd_res b)
|
bool osd_res_equals(struct mp_osd_res a, struct mp_osd_res b)
|
||||||
{
|
{
|
||||||
return a.w == b.w && a.h == b.h && a.ml == b.ml && a.mt == b.mt
|
return a.w == b.w && a.h == b.h && a.ml == b.ml && a.mt == b.mt
|
||||||
|
|||||||
12
sub/osd.h
12
sub/osd.h
@@ -163,8 +163,20 @@ struct osd_style_opts {
|
|||||||
char *fonts_dir;
|
char *fonts_dir;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct osd_bar_style_opts {
|
||||||
|
float align_x;
|
||||||
|
float align_y;
|
||||||
|
float w;
|
||||||
|
float h;
|
||||||
|
float outline_size;
|
||||||
|
float marker_scale;
|
||||||
|
float marker_min_size;
|
||||||
|
int marker_style;
|
||||||
|
};
|
||||||
|
|
||||||
extern const struct m_sub_options osd_style_conf;
|
extern const struct m_sub_options osd_style_conf;
|
||||||
extern const struct m_sub_options sub_style_conf;
|
extern const struct m_sub_options sub_style_conf;
|
||||||
|
extern const struct m_sub_options osd_bar_style_conf;
|
||||||
|
|
||||||
struct osd_state;
|
struct osd_state;
|
||||||
struct osd_object;
|
struct osd_object;
|
||||||
|
|||||||
@@ -380,10 +380,10 @@ static void get_osd_bar_box(struct osd_state *osd, struct osd_object *obj,
|
|||||||
// and each bar ass event gets its own opaque box - breaking the bar.
|
// and each bar ass event gets its own opaque box - breaking the bar.
|
||||||
style->BorderStyle = 1; // outline
|
style->BorderStyle = 1; // outline
|
||||||
|
|
||||||
*o_w = track->PlayResX * (opts->osd_bar_w / 100.0);
|
*o_w = track->PlayResX * (opts->osd_bar_style->w / 100.0);
|
||||||
*o_h = track->PlayResY * (opts->osd_bar_h / 100.0);
|
*o_h = track->PlayResY * (opts->osd_bar_style->h / 100.0);
|
||||||
|
|
||||||
style->Outline = opts->osd_bar_outline_size;
|
style->Outline = opts->osd_bar_style->outline_size;
|
||||||
// Rendering with shadow is broken (because there's more than one shape)
|
// Rendering with shadow is broken (because there's more than one shape)
|
||||||
style->Shadow = 0;
|
style->Shadow = 0;
|
||||||
style->Blur = 0;
|
style->Blur = 0;
|
||||||
@@ -392,8 +392,8 @@ static void get_osd_bar_box(struct osd_state *osd, struct osd_object *obj,
|
|||||||
|
|
||||||
*o_border = style->Outline;
|
*o_border = style->Outline;
|
||||||
|
|
||||||
*o_x = get_align(opts->osd_bar_align_x, track->PlayResX, *o_w, *o_border);
|
*o_x = get_align(opts->osd_bar_style->align_x, track->PlayResX, *o_w, *o_border);
|
||||||
*o_y = get_align(opts->osd_bar_align_y, track->PlayResY, *o_h, *o_border);
|
*o_y = get_align(opts->osd_bar_style->align_y, track->PlayResY, *o_h, *o_border);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void update_progbar(struct osd_state *osd, struct osd_object *obj)
|
static void update_progbar(struct osd_state *osd, struct osd_object *obj)
|
||||||
@@ -470,13 +470,13 @@ static void update_progbar(struct osd_state *osd, struct osd_object *obj)
|
|||||||
ass_draw_rect_ccw(d, 0, 0, width, height);
|
ass_draw_rect_ccw(d, 0, 0, width, height);
|
||||||
|
|
||||||
// chapter marks
|
// chapter marks
|
||||||
if (osd->opts->osd_bar_marker_style) {
|
if (osd->opts->osd_bar_style->marker_style) {
|
||||||
for (int n = 0; n < obj->progbar_state.num_stops; n++) {
|
for (int n = 0; n < obj->progbar_state.num_stops; n++) {
|
||||||
float s = obj->progbar_state.stops[n] * width;
|
float s = obj->progbar_state.stops[n] * width;
|
||||||
float size = MPMAX(border * osd->opts->osd_bar_marker_scale,
|
float size = MPMAX(border * osd->opts->osd_bar_style->marker_scale,
|
||||||
osd->opts->osd_bar_marker_min_size);
|
osd->opts->osd_bar_style->marker_min_size);
|
||||||
|
|
||||||
if (osd->opts->osd_bar_marker_style == 2 &&
|
if (osd->opts->osd_bar_style->marker_style == 2 &&
|
||||||
s > size / 2 && s < width - size / 2)
|
s > size / 2 && s < width - size / 2)
|
||||||
{ // line
|
{ // line
|
||||||
ass_draw_rect_cw(d, s - size / 2, 0, s + size / 2, height);
|
ass_draw_rect_cw(d, s - size / 2, 0, s + size / 2, height);
|
||||||
|
|||||||
Reference in New Issue
Block a user