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
60 60
61struct mp_draw_sub_cache61struct mp_draw_sub_cache
62{62{
63 struct mpv_global *global;
64
63 // Possibly cached parts. Also implies what's in the video_overlay.65 // Possibly cached parts. Also implies what's in the video_overlay.
64 struct part parts[MAX_OSD_PARTS];66 struct part parts[MAX_OSD_PARTS];
65 int64_t change_id;67 int64_t change_id;
@@ -490,9 +492,16 @@ static void clear_rgba_overlay(struct mp_draw_sub_cache *p) · 424 unmodified lines
490 p->any_osd = false;492 p->any_osd = false;
491}493}
492 494
495static 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
493static void init_general(struct mp_draw_sub_cache *p)502static void init_general(struct mp_draw_sub_cache *p)
494{503{
495 p->sub_scale = mp_sws_alloc(p);504 p->sub_scale = alloc_scaler(p);
496 505
497 p->s_w = MP_ALIGN_UP(p->rgba_overlay->w, SLICE_W) / SLICE_W;506 p->s_w = MP_ALIGN_UP(p->rgba_overlay->w, SLICE_W) / SLICE_W;
498 507
@@ -664,7 +673,7 @@ static bool reinit_to_video(struct mp_draw_sub_cache *p) · 165 unmodified lines
664 if (p->scale_in_tiles)673 if (p->scale_in_tiles)
665 p->video_overlay->params.chroma_location = MP_CHROMA_CENTER;674 p->video_overlay->params.chroma_location = MP_CHROMA_CENTER;
666 675
667 p->rgba_to_overlay = mp_sws_alloc(p);676 p->rgba_to_overlay = alloc_scaler(p);
668 p->rgba_to_overlay->allow_zimg = true;677 p->rgba_to_overlay->allow_zimg = true;
669 if (!mp_sws_supports_formats(p->rgba_to_overlay,678 if (!mp_sws_supports_formats(p->rgba_to_overlay,
670 p->video_overlay->imgfmt, p->rgba_overlay->imgfmt))679 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
729 0, p->calpha_overlay, NULL))738 0, p->calpha_overlay, NULL))
730 return false;739 return false;
731 740
732 p->alpha_to_calpha = mp_sws_alloc(p);741 p->alpha_to_calpha = alloc_scaler(p);
733 if (!mp_sws_supports_formats(p->alpha_to_calpha,742 if (!mp_sws_supports_formats(p->alpha_to_calpha,
734 calpha_fmt, calpha_fmt))743 calpha_fmt, calpha_fmt))
735 return false;744 return false;
@@ -737,8 +746,8 @@ static bool reinit_to_video(struct mp_draw_sub_cache *p) · 1 unmodified line
737 }746 }
738 747
739 if (need_premul) {748 if (need_premul) {
740 p->premul = mp_sws_alloc(p);749 p->premul = alloc_scaler(p);
741 p->unpremul = mp_sws_alloc(p);750 p->unpremul = alloc_scaler(p);
742 p->premul_tmp = mp_image_alloc(params->imgfmt, params->w, params->h);751 p->premul_tmp = mp_image_alloc(params->imgfmt, params->w, params->h);
743 talloc_steal(p, p->premul_tmp);752 talloc_steal(p, p->premul_tmp);
744 if (!p->premul_tmp)753 if (!p->premul_tmp)
@@ -794,10 +803,10 @@ static bool check_reinit(struct mp_draw_sub_cache *p, · 49 unmodified lines
794{803{
795 if (!mp_image_params_equal(&p->params, params) || !p->rgba_overlay) {804 if (!mp_image_params_equal(&p->params, params) || !p->rgba_overlay) {
796 talloc_free_children(p);805 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};
798 if (!(to_video ? reinit_to_video(p) : reinit_to_overlay(p))) {807 if (!(to_video ? reinit_to_video(p) : reinit_to_overlay(p))) {
799 talloc_free_children(p);808 talloc_free_children(p);
800 *p = (struct mp_draw_sub_cache){0};809 *p = (struct mp_draw_sub_cache){.global = p->global};
801 return false;810 return false;
802 }811 }
803 }812 }
@@ -819,9 +828,11 @@ char *mp_draw_sub_get_dbg_info(struct mp_draw_sub_cache *p) · 15 unmodified lines
819 mp_imgfmt_to_name(p->calpha_tmp ? p->calpha_tmp->imgfmt : 0));828 mp_imgfmt_to_name(p->calpha_tmp ? p->calpha_tmp->imgfmt : 0));
820}829}
821 830
822struct mp_draw_sub_cache *mp_draw_sub_alloc(void *ta_parent)831struct mp_draw_sub_cache *mp_draw_sub_alloc(void *ta_parent, struct mpv_global *g)
823{832{
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;
825}836}
826 837
827bool mp_draw_sub_bitmaps(struct mp_draw_sub_cache *p, struct mp_image *dst,838bool 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
5 5
6struct mp_rect;6struct mp_rect;
7struct mp_image;7struct mp_image;
8struct mpv_global;
8struct mp_draw_sub_cache;9struct mp_draw_sub_cache;
9 10
10struct mp_draw_sub_cache *mp_draw_sub_alloc(void *ta_parent);11struct mp_draw_sub_cache *mp_draw_sub_alloc(void *ta_parent, struct mpv_global *g);
11 12
12// Render the sub-bitmaps in sbs_list to dst. sbs_list must have been rendered13// Render the sub-bitmaps in sbs_list to dst. sbs_list must have been rendered
13// for an OSD resolution equivalent to dst's size (UB if not).14// 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
196void osd_set_render_subs_in_filter(struct osd_state *osd, bool s)196void osd_set_render_subs_in_filter(struct osd_state *osd, bool s)
197{197{
198 pthread_mutex_lock(&osd->lock);198 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 }
200 pthread_mutex_unlock(&osd->lock);208 pthread_mutex_unlock(&osd->lock);
201}209}
202 210
@@ -426,7 +434,7 @@ void osd_draw_on_image_p(struct osd_state *osd, struct mp_osd_res res, · 223 unmodified lines
426 pthread_mutex_lock(&osd->lock);434 pthread_mutex_lock(&osd->lock);
427 435
428 if (!osd->draw_cache)436 if (!osd->draw_cache)
429 osd->draw_cache = mp_draw_sub_alloc(osd);437 osd->draw_cache = mp_draw_sub_alloc(osd, osd->global);
430 438
431 stats_time_start(osd->stats, "draw-bmp");439 stats_time_start(osd->stats, "draw-bmp");
432 440
test/repack.c+3−3
@@ -333,7 +333,7 @@ static void check_float_repack(int imgfmt, enum mp_csp csp, · 332 unmodified lines
333 talloc_free(from_f);333 talloc_free(from_f);
334}334}
335 335
336static bool try_draw_bmp(FILE *f, int imgfmt)336static bool try_draw_bmp(struct mpv_global *g, FILE *f, int imgfmt)
337{337{
338 bool ok = false;338 bool ok = false;
339 339
@@ -365,7 +365,7 @@ static bool try_draw_bmp(FILE *f, int imgfmt) · 25 unmodified lines
365 .num_items = 1,365 .num_items = 1,
366 };366 };
367 367
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);
369 if (mp_draw_sub_bitmaps(c, dst, &sbs_list)) {369 if (mp_draw_sub_bitmaps(c, dst, &sbs_list)) {
370 char *info = mp_draw_sub_get_dbg_info(c);370 char *info = mp_draw_sub_get_dbg_info(c);
371 fprintf(f, "%s\n", info);371 fprintf(f, "%s\n", info);
@@ -419,7 +419,7 @@ static void run(struct test_ctx *ctx) · 47 unmodified lines
419 int imgfmt = imgfmts[n];419 int imgfmt = imgfmts[n];
420 420
421 fprintf(f, "%-12s= ", mp_imgfmt_to_name(imgfmt));421 fprintf(f, "%-12s= ", mp_imgfmt_to_name(imgfmt));
422 try_draw_bmp(f, imgfmt);422 try_draw_bmp(ctx->global, f, imgfmt);
423 }423 }
424 424
425 fclose(f);425 fclose(f);
video/out/vo_vaapi.c+1−1
@@ -639,7 +639,7 @@ static void draw_osd(struct vo *vo) · 638 unmodified lines
639 p->osd_part.active = false;639 p->osd_part.active = false;
640 640
641 if (!p->osd_cache)641 if (!p->osd_cache)
642 p->osd_cache = mp_draw_sub_alloc(p);642 p->osd_cache = mp_draw_sub_alloc(p, vo->global);
643 643
644 struct sub_bitmap_list *sbs = osd_render(vo->osd, *res, pts, 0,644 struct sub_bitmap_list *sbs = osd_render(vo->osd, *res, pts, 0,
645 mp_draw_sub_formats);645 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