History

draw_bmp: use command line options for any used scalers

wm4 committed 6 years ago

Commit baabd5f1 parent 6d8b3f95 files · +36 −16Browse files

Unified · Split

5 files
  1. sub/draw_bmp.c +20 −9
  2. sub/draw_bmp.h +2 −1
  3. sub/osd.c +10 −2
  4. test/repack.c +3 −3
  5. video/out/vo_vaapi.c +1 −1
sub/draw_bmp.c+20−9
@@ -60,6 +60,8 @@ struct slice { · 59 unmodified lines
6060
6161 struct mp_draw_sub_cache
6262 {
63+ struct mpv_global *global;
64+
6365 // Possibly cached parts. Also implies what's in the video_overlay.
6466 struct part parts[MAX_OSD_PARTS];
6567 int64_t change_id;
@@ -490,9 +492,16 @@ static void clear_rgba_overlay(struct mp_draw_sub_cache *p) · 424 unmodified lines
490492 p->any_osd = false;
491493 }
492494
495+static struct mp_sws_context *alloc_scaler(struct mp_draw_sub_cache *p)
496+{
497+ struct mp_sws_context *s = mp_sws_alloc(p);
498+ mp_sws_enable_cmdline_opts(s, p->global);
499+ return s;
500+}
501+
493502 static void init_general(struct mp_draw_sub_cache *p)
494503 {
495− p->sub_scale = mp_sws_alloc(p);
504+ p->sub_scale = alloc_scaler(p);
496505
497506 p->s_w = MP_ALIGN_UP(p->rgba_overlay->w, SLICE_W) / SLICE_W;
498507
@@ -664,7 +673,7 @@ static bool reinit_to_video(struct mp_draw_sub_cache *p) · 165 unmodified lines
664673 if (p->scale_in_tiles)
665674 p->video_overlay->params.chroma_location = MP_CHROMA_CENTER;
666675
667− p->rgba_to_overlay = mp_sws_alloc(p);
676+ p->rgba_to_overlay = alloc_scaler(p);
668677 p->rgba_to_overlay->allow_zimg = true;
669678 if (!mp_sws_supports_formats(p->rgba_to_overlay,
670679 p->video_overlay->imgfmt, p->rgba_overlay->imgfmt))
@@ -729,7 +738,7 @@ static bool reinit_to_video(struct mp_draw_sub_cache *p) · 58 unmodified lines
729738 0, p->calpha_overlay, NULL))
730739 return false;
731740
732− p->alpha_to_calpha = mp_sws_alloc(p);
741+ p->alpha_to_calpha = alloc_scaler(p);
733742 if (!mp_sws_supports_formats(p->alpha_to_calpha,
734743 calpha_fmt, calpha_fmt))
735744 return false;
@@ -737,8 +746,8 @@ static bool reinit_to_video(struct mp_draw_sub_cache *p) · 1 unmodified line
737746 }
738747
739748 if (need_premul) {
740− p->premul = mp_sws_alloc(p);
741− p->unpremul = mp_sws_alloc(p);
749+ p->premul = alloc_scaler(p);
750+ p->unpremul = alloc_scaler(p);
742751 p->premul_tmp = mp_image_alloc(params->imgfmt, params->w, params->h);
743752 talloc_steal(p, p->premul_tmp);
744753 if (!p->premul_tmp)
@@ -794,10 +803,10 @@ static bool check_reinit(struct mp_draw_sub_cache *p, · 49 unmodified lines
794803 {
795804 if (!mp_image_params_equal(&p->params, params) || !p->rgba_overlay) {
796805 talloc_free_children(p);
797− *p = (struct mp_draw_sub_cache){.params = *params};
806+ *p = (struct mp_draw_sub_cache){.global = p->global, .params = *params};
798807 if (!(to_video ? reinit_to_video(p) : reinit_to_overlay(p))) {
799808 talloc_free_children(p);
800− *p = (struct mp_draw_sub_cache){0};
809+ *p = (struct mp_draw_sub_cache){.global = p->global};
801810 return false;
802811 }
803812 }
@@ -819,9 +828,11 @@ char *mp_draw_sub_get_dbg_info(struct mp_draw_sub_cache *p) · 15 unmodified lines
819828 mp_imgfmt_to_name(p->calpha_tmp ? p->calpha_tmp->imgfmt : 0));
820829 }
821830
822−struct mp_draw_sub_cache *mp_draw_sub_alloc(void *ta_parent)
831+struct mp_draw_sub_cache *mp_draw_sub_alloc(void *ta_parent, struct mpv_global *g)
823832 {
824− return talloc_zero(ta_parent, struct mp_draw_sub_cache);
833+ struct mp_draw_sub_cache *c = talloc_zero(ta_parent, struct mp_draw_sub_cache);
834+ c->global = g;
835+ return c;
825836 }
826837
827838 bool mp_draw_sub_bitmaps(struct mp_draw_sub_cache *p, struct mp_image *dst,
sub/draw_bmp.h+2−1
@@ -5,9 +5,10 @@ · 4 unmodified lines
55
66 struct mp_rect;
77 struct mp_image;
8+struct mpv_global;
89 struct mp_draw_sub_cache;
910
10−struct mp_draw_sub_cache *mp_draw_sub_alloc(void *ta_parent);
11+struct mp_draw_sub_cache *mp_draw_sub_alloc(void *ta_parent, struct mpv_global *g);
1112
1213 // Render the sub-bitmaps in sbs_list to dst. sbs_list must have been rendered
1314 // for an OSD resolution equivalent to dst's size (UB if not).
sub/osd.c+10−2
@@ -196,7 +196,15 @@ bool osd_get_render_subs_in_filter(struct osd_state *osd) · 195 unmodified lines
196196 void osd_set_render_subs_in_filter(struct osd_state *osd, bool s)
197197 {
198198 pthread_mutex_lock(&osd->lock);
199− osd->render_subs_in_filter = s;
199+ if (osd->render_subs_in_filter != s) {
200+ osd->render_subs_in_filter = s;
201+
202+ int change_id = 0;
203+ for (int n = 0; n < MAX_OSD_PARTS; n++)
204+ change_id = MPMAX(change_id, osd->objs[n]->vo_change_id);
205+ for (int n = 0; n < MAX_OSD_PARTS; n++)
206+ osd->objs[n]->vo_change_id = change_id + 1;
207+ }
200208 pthread_mutex_unlock(&osd->lock);
201209 }
202210
@@ -426,7 +434,7 @@ void osd_draw_on_image_p(struct osd_state *osd, struct mp_osd_res res, · 223 unmodified lines
426434 pthread_mutex_lock(&osd->lock);
427435
428436 if (!osd->draw_cache)
429− osd->draw_cache = mp_draw_sub_alloc(osd);
437+ osd->draw_cache = mp_draw_sub_alloc(osd, osd->global);
430438
431439 stats_time_start(osd->stats, "draw-bmp");
432440
test/repack.c+3−3
@@ -333,7 +333,7 @@ static void check_float_repack(int imgfmt, enum mp_csp csp, · 332 unmodified lines
333333 talloc_free(from_f);
334334 }
335335
336−static bool try_draw_bmp(FILE *f, int imgfmt)
336+static bool try_draw_bmp(struct mpv_global *g, FILE *f, int imgfmt)
337337 {
338338 bool ok = false;
339339
@@ -365,7 +365,7 @@ static bool try_draw_bmp(FILE *f, int imgfmt) · 25 unmodified lines
365365 .num_items = 1,
366366 };
367367
368− struct mp_draw_sub_cache *c = mp_draw_sub_alloc(NULL);
368+ struct mp_draw_sub_cache *c = mp_draw_sub_alloc(NULL, g);
369369 if (mp_draw_sub_bitmaps(c, dst, &sbs_list)) {
370370 char *info = mp_draw_sub_get_dbg_info(c);
371371 fprintf(f, "%s\n", info);
@@ -419,7 +419,7 @@ static void run(struct test_ctx *ctx) · 47 unmodified lines
419419 int imgfmt = imgfmts[n];
420420
421421 fprintf(f, "%-12s= ", mp_imgfmt_to_name(imgfmt));
422− try_draw_bmp(f, imgfmt);
422+ try_draw_bmp(ctx->global, f, imgfmt);
423423 }
424424
425425 fclose(f);
video/out/vo_vaapi.c+1−1
@@ -639,7 +639,7 @@ static void draw_osd(struct vo *vo) · 638 unmodified lines
639639 p->osd_part.active = false;
640640
641641 if (!p->osd_cache)
642− p->osd_cache = mp_draw_sub_alloc(p);
642+ p->osd_cache = mp_draw_sub_alloc(p, vo->global);
643643
644644 struct sub_bitmap_list *sbs = osd_render(vo->osd, *res, pts, 0,
645645 mp_draw_sub_formats);

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