History

options: move OSD bar opts to a separate struct

Move them to a suboption so the suboption prefix can be used.

nanahi committed 2 years ago

Commit 8612f801 parent e056ad35 files · +54 −34Browse files

Unified · Split

5 files
  1. options/options.c +1 −17
  2. options/options.h +1 −8
  3. sub/osd.c +31 −0
  4. sub/osd.h +12 −0
  5. sub/osd_libass.c +9 −9
options/options.c+1−17
@@ -390,17 +390,8 @@ const struct m_sub_options mp_subtitle_shared_sub_opts = { · 389 unmodified lines
390 390
391const struct m_sub_options mp_osd_render_sub_opts = {391const struct m_sub_options mp_osd_render_sub_opts = {
392 .opts = (const struct m_option[]){392 .opts = (const struct m_option[]){
393 {"osd-bar-align-x", OPT_FLOAT(osd_bar_align_x), M_RANGE(-1.0, +1.0)},
394 {"osd-bar-align-y", OPT_FLOAT(osd_bar_align_y), M_RANGE(-1.0, +1.0)},
395 {"osd-bar-w", OPT_FLOAT(osd_bar_w), M_RANGE(1, 100)},
396 {"osd-bar-h", OPT_FLOAT(osd_bar_h), M_RANGE(0.1, 50)},
397 {"osd-bar-outline-size", OPT_FLOAT(osd_bar_outline_size), M_RANGE(0, 1000.0)},
398 {"osd-bar-border-size", OPT_ALIAS("osd-bar-outline-size")},
399 {"osd-bar-marker-scale", OPT_FLOAT(osd_bar_marker_scale), M_RANGE(0, 100.0)},
400 {"osd-bar-marker-min-size", OPT_FLOAT(osd_bar_marker_min_size), M_RANGE(0, 1000.0)},
401 {"osd-bar-marker-style", OPT_CHOICE(osd_bar_marker_style,
402 {"none", 0}, {"triangle", 1}, {"line", 2})},
403 {"osd", OPT_SUBSTRUCT(osd_style, osd_style_conf)},393 {"osd", OPT_SUBSTRUCT(osd_style, osd_style_conf)},
394 {"osd-bar", OPT_SUBSTRUCT(osd_bar_style, osd_bar_style_conf)},
404 {"osd-scale", OPT_FLOAT(osd_scale), M_RANGE(0, 100)},395 {"osd-scale", OPT_FLOAT(osd_scale), M_RANGE(0, 100)},
405 {"osd-scale-by-window", OPT_BOOL(osd_scale_by_window)},396 {"osd-scale-by-window", OPT_BOOL(osd_scale_by_window)},
406 {"force-rgba-osd-rendering", OPT_BOOL(force_rgba_osd)},397 {"force-rgba-osd-rendering", OPT_BOOL(force_rgba_osd)},
@@ -408,13 +399,6 @@ const struct m_sub_options mp_osd_render_sub_opts = { · 1 unmodified line
408 },399 },
409 .size = sizeof(OPT_BASE_STRUCT),400 .size = sizeof(OPT_BASE_STRUCT),
410 .defaults = &(OPT_BASE_STRUCT){401 .defaults = &(OPT_BASE_STRUCT){
411 .osd_bar_align_y = 0.5,
412 .osd_bar_w = 75.0,
413 .osd_bar_h = 3.125,
414 .osd_bar_outline_size = 0.5,
415 .osd_bar_marker_scale = 1.3,
416 .osd_bar_marker_min_size = 1.6,
417 .osd_bar_marker_style = 1,
418 .osd_scale = 1,402 .osd_scale = 1,
419 .osd_scale_by_window = true,403 .osd_scale_by_window = true,
420 },404 },
options/options.h+1−8
@@ -135,17 +135,10 @@ struct mp_subtitle_shared_opts { · 134 unmodified lines
135};135};
136 136
137struct mp_osd_render_opts {137struct mp_osd_render_opts {
138 float osd_bar_align_x;
139 float osd_bar_align_y;
140 float osd_bar_w;
141 float osd_bar_h;
142 float osd_bar_outline_size;
143 float osd_bar_marker_scale;
144 float osd_bar_marker_min_size;
145 int osd_bar_marker_style;
146 float osd_scale;138 float osd_scale;
147 bool osd_scale_by_window;139 bool osd_scale_by_window;
148 struct osd_style_opts *osd_style;140 struct osd_style_opts *osd_style;
141 struct osd_bar_style_opts *osd_bar_style;
149 bool force_rgba_osd;142 bool force_rgba_osd;
150};143};
151 144
sub/osd.c+31−0
@@ -116,6 +116,37 @@ const struct m_sub_options sub_style_conf = { · 115 unmodified lines
116 .change_flags = UPDATE_OSD,116 .change_flags = UPDATE_OSD,
117};117};
118 118
119#undef OPT_BASE_STRUCT
120#define OPT_BASE_STRUCT struct osd_bar_style_opts
121static const m_option_t bar_style_opts[] = {
122 {"align-x", OPT_FLOAT(align_x), M_RANGE(-1.0, +1.0)},
123 {"align-y", OPT_FLOAT(align_y), M_RANGE(-1.0, +1.0)},
124 {"w", OPT_FLOAT(w), M_RANGE(1, 100)},
125 {"h", OPT_FLOAT(h), M_RANGE(0.1, 50)},
126 {"outline-size", OPT_FLOAT(outline_size), M_RANGE(0, 1000.0)},
127 {"border-size", OPT_ALIAS("osd-bar-outline-size")},
128 {"marker-scale", OPT_FLOAT(marker_scale), M_RANGE(0, 100.0)},
129 {"marker-min-size", OPT_FLOAT(marker_min_size), M_RANGE(0, 1000.0)},
130 {"marker-style", OPT_CHOICE(marker_style,
131 {"none", 0}, {"triangle", 1}, {"line", 2})},
132 {0}
133};
134
135const struct m_sub_options osd_bar_style_conf = {
136 .opts = bar_style_opts,
137 .size = sizeof(struct osd_bar_style_opts),
138 .defaults = &(const struct osd_bar_style_opts){
139 .align_y = 0.5,
140 .w = 75.0,
141 .h = 3.125,
142 .outline_size = 0.5,
143 .marker_scale = 1.3,
144 .marker_min_size = 1.6,
145 .marker_style = 1,
146 },
147 .change_flags = UPDATE_OSD,
148};
149
119bool osd_res_equals(struct mp_osd_res a, struct mp_osd_res b)150bool osd_res_equals(struct mp_osd_res a, struct mp_osd_res b)
120{151{
121 return a.w == b.w && a.h == b.h && a.ml == b.ml && a.mt == b.mt152 return a.w == b.w && a.h == b.h && a.ml == b.ml && a.mt == b.mt
sub/osd.h+12−0
@@ -163,8 +163,20 @@ struct osd_style_opts { · 162 unmodified lines
163 char *fonts_dir;163 char *fonts_dir;
164};164};
165 165
166struct osd_bar_style_opts {
167 float align_x;
168 float align_y;
169 float w;
170 float h;
171 float outline_size;
172 float marker_scale;
173 float marker_min_size;
174 int marker_style;
175};
176
166extern const struct m_sub_options osd_style_conf;177extern const struct m_sub_options osd_style_conf;
167extern const struct m_sub_options sub_style_conf;178extern const struct m_sub_options sub_style_conf;
179extern const struct m_sub_options osd_bar_style_conf;
168 180
169struct osd_state;181struct osd_state;
170struct osd_object;182struct osd_object;
sub/osd_libass.c+9−9
@@ -380,10 +380,10 @@ static void get_osd_bar_box(struct osd_state *osd, struct osd_object *obj, · 379 unmodified lines
380 // and each bar ass event gets its own opaque box - breaking the bar.380 // and each bar ass event gets its own opaque box - breaking the bar.
381 style->BorderStyle = 1; // outline381 style->BorderStyle = 1; // outline
382 382
383 *o_w = track->PlayResX * (opts->osd_bar_w / 100.0);383 *o_w = track->PlayResX * (opts->osd_bar_style->w / 100.0);
384 *o_h = track->PlayResY * (opts->osd_bar_h / 100.0);384 *o_h = track->PlayResY * (opts->osd_bar_style->h / 100.0);
385 385
386 style->Outline = opts->osd_bar_outline_size;386 style->Outline = opts->osd_bar_style->outline_size;
387 // 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)
388 style->Shadow = 0;388 style->Shadow = 0;
389 style->Blur = 0;389 style->Blur = 0;
@@ -392,8 +392,8 @@ static void get_osd_bar_box(struct osd_state *osd, struct osd_object *obj, · 2 unmodified lines
392 392
393 *o_border = style->Outline;393 *o_border = style->Outline;
394 394
395 *o_x = get_align(opts->osd_bar_align_x, track->PlayResX, *o_w, *o_border);395 *o_x = get_align(opts->osd_bar_style->align_x, track->PlayResX, *o_w, *o_border);
396 *o_y = get_align(opts->osd_bar_align_y, track->PlayResY, *o_h, *o_border);396 *o_y = get_align(opts->osd_bar_style->align_y, track->PlayResY, *o_h, *o_border);
397}397}
398 398
399static void update_progbar(struct osd_state *osd, struct osd_object *obj)399static 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) · 70 unmodified lines
470 ass_draw_rect_ccw(d, 0, 0, width, height);470 ass_draw_rect_ccw(d, 0, 0, width, height);
471 471
472 // chapter marks472 // chapter marks
473 if (osd->opts->osd_bar_marker_style) {473 if (osd->opts->osd_bar_style->marker_style) {
474 for (int n = 0; n < obj->progbar_state.num_stops; n++) {474 for (int n = 0; n < obj->progbar_state.num_stops; n++) {
475 float s = obj->progbar_state.stops[n] * width;475 float s = obj->progbar_state.stops[n] * width;
476 float size = MPMAX(border * osd->opts->osd_bar_marker_scale,476 float size = MPMAX(border * osd->opts->osd_bar_style->marker_scale,
477 osd->opts->osd_bar_marker_min_size);477 osd->opts->osd_bar_style->marker_min_size);
478 478
479 if (osd->opts->osd_bar_marker_style == 2 &&479 if (osd->opts->osd_bar_style->marker_style == 2 &&
480 s > size / 2 && s < width - size / 2)480 s > size / 2 && s < width - size / 2)
481 { // line481 { // line
482 ass_draw_rect_cw(d, s - size / 2, 0, s + size / 2, height);482 ass_draw_rect_cw(d, s - size / 2, 0, s + size / 2, height);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t