| @@ -60,6 +60,8 @@ struct slice { · 59 unmodified lines |
| 60 | 60 | |
| 61 | 61 | struct mp_draw_sub_cache |
| 62 | 62 | { |
| 63 | + struct mpv_global *global; |
| 64 | + |
| 63 | 65 | // Possibly cached parts. Also implies what's in the video_overlay. |
| 64 | 66 | struct part parts[MAX_OSD_PARTS]; |
| 65 | 67 | int64_t change_id; |
| @@ -490,9 +492,16 @@ static void clear_rgba_overlay(struct mp_draw_sub_cache *p) · 424 unmodified lines |
| 490 | 492 | p->any_osd = false; |
| 491 | 493 | } |
| 492 | 494 | |
| 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 | + |
| 493 | 502 | static 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 | 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 | 673 | if (p->scale_in_tiles) |
| 665 | 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 | 677 | p->rgba_to_overlay->allow_zimg = true; |
| 669 | 678 | if (!mp_sws_supports_formats(p->rgba_to_overlay, |
| 670 | 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 | 738 | 0, p->calpha_overlay, NULL)) |
| 730 | 739 | return false; |
| 731 | 740 | |
| 732 | | − p->alpha_to_calpha = mp_sws_alloc(p); |
| 741 | + p->alpha_to_calpha = alloc_scaler(p); |
| 733 | 742 | if (!mp_sws_supports_formats(p->alpha_to_calpha, |
| 734 | 743 | calpha_fmt, calpha_fmt)) |
| 735 | 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 | 748 | 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); |
| 742 | 751 | p->premul_tmp = mp_image_alloc(params->imgfmt, params->w, params->h); |
| 743 | 752 | talloc_steal(p, p->premul_tmp); |
| 744 | 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 | 804 | if (!mp_image_params_equal(&p->params, params) || !p->rgba_overlay) { |
| 796 | 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 | 807 | if (!(to_video ? reinit_to_video(p) : reinit_to_overlay(p))) { |
| 799 | 808 | talloc_free_children(p); |
| 800 | | − *p = (struct mp_draw_sub_cache){0}; |
| 809 | + *p = (struct mp_draw_sub_cache){.global = p->global}; |
| 801 | 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 | 828 | mp_imgfmt_to_name(p->calpha_tmp ? p->calpha_tmp->imgfmt : 0)); |
| 820 | 829 | } |
| 821 | 830 | |
| 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) |
| 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 | |
| 827 | 838 | bool mp_draw_sub_bitmaps(struct mp_draw_sub_cache *p, struct mp_image *dst, |