diff --git a/libmpcodecs/vf_ass.c b/libmpcodecs/vf_ass.c index 937912313b..77248b49c0 100644 --- a/libmpcodecs/vf_ass.c +++ b/libmpcodecs/vf_ass.c @@ -35,6 +35,7 @@ #include "mp_image.h" #include "vf.h" #include "sub/sub.h" +#include "sub/dec_sub.h" #include "libvo/fastmemcpy.h" diff --git a/libvo/bitmap_packer.c b/libvo/bitmap_packer.c index 9d3df70c34..603a6ce410 100644 --- a/libvo/bitmap_packer.c +++ b/libvo/bitmap_packer.c @@ -28,7 +28,6 @@ #include "bitmap_packer.h" #include "mp_msg.h" #include "mpcommon.h" -#include "sub/ass_mp.h" #include "sub/dec_sub.h" #include "fastmemcpy.h" diff --git a/libvo/vo_corevideo.m b/libvo/vo_corevideo.m index 37a16fec5e..e5c74f6cc8 100644 --- a/libvo/vo_corevideo.m +++ b/libvo/vo_corevideo.m @@ -333,7 +333,7 @@ static int control(struct vo *vo, uint32_t request, void *data) return mpgl_osd_query_format(p->osd, *(int *)data) ? VO_TRUE : VO_NOTIMPL; case VOCTRL_GET_EOSD_RES: { - mp_eosd_res_t *r = data; + struct mp_eosd_res *r = data; r->w = vo->dwidth; r->h = vo->dheight; r->mt = r->mb = r->ml = r->mr = 0; diff --git a/libvo/vo_gl.c b/libvo/vo_gl.c index 7ad5fe31e3..d41adad6bc 100644 --- a/libvo/vo_gl.c +++ b/libvo/vo_gl.c @@ -42,7 +42,6 @@ #include "gl_osd.h" #include "aspect.h" #include "fastmemcpy.h" -#include "sub/ass_mp.h" //for gl_priv.use_yuv #define MASK_ALL_YUV (~(1 << YUV_CONVERSION_NONE)) @@ -1096,7 +1095,7 @@ static int control(struct vo *vo, uint32_t request, void *data) case VOCTRL_QUERY_EOSD_FORMAT: return mpgl_osd_query_format(p->osd, *(int *)data) ? VO_TRUE : VO_NOTIMPL; case VOCTRL_GET_EOSD_RES: { - mp_eosd_res_t *r = data; + struct mp_eosd_res *r = data; r->w = vo->dwidth; r->h = vo->dheight; r->mt = r->mb = r->ml = r->mr = 0; diff --git a/libvo/vo_gl3.c b/libvo/vo_gl3.c index 66324281ba..f3c1767b78 100644 --- a/libvo/vo_gl3.c +++ b/libvo/vo_gl3.c @@ -54,7 +54,6 @@ #include "filter_kernels.h" #include "aspect.h" #include "fastmemcpy.h" -#include "sub/ass_mp.h" static const char vo_gl3_shaders[] = // Generated from libvo/vo_gl3_shaders.glsl @@ -1689,7 +1688,7 @@ static int control(struct vo *vo, uint32_t request, void *data) draw_eosd(p, data); return VO_TRUE; case VOCTRL_GET_EOSD_RES: { - mp_eosd_res_t *r = data; + struct mp_eosd_res *r = data; r->w = vo->dwidth; r->h = vo->dheight; r->ml = r->mr = p->border_x; diff --git a/libvo/vo_vdpau.c b/libvo/vo_vdpau.c index 1e587810ac..34aa9824dc 100644 --- a/libvo/vo_vdpau.c +++ b/libvo/vo_vdpau.c @@ -51,7 +51,6 @@ #include "libmpcodecs/vfcap.h" #include "libmpcodecs/mp_image.h" #include "osdep/timer.h" -#include "sub/ass_mp.h" #include "bitmap_packer.h" #define WRAP_ADD(x, a, m) ((a) < 0 \ @@ -984,7 +983,7 @@ static void draw_eosd(struct vo *vo, int index) } } -static void generate_eosd(struct vo *vo, mp_eosd_images_t *imgs) +static void generate_eosd(struct vo *vo, struct sub_bitmaps *imgs) { struct vdpctx *vc = vo->priv; struct vdp_functions *vdp = vc->vdp; @@ -1617,7 +1616,7 @@ static int control(struct vo *vo, uint32_t request, void *data) if (!data) return VO_FALSE; if (status_ok(vo)) { - mp_eosd_images_t *imgs = data; + struct sub_bitmaps *imgs = data; generate_eosd(vo, imgs); draw_eosd(vo, imgs->render_index); } diff --git a/sub/dec_sub.h b/sub/dec_sub.h index 442cd870d8..9cfe8d964c 100644 --- a/sub/dec_sub.h +++ b/sub/dec_sub.h @@ -4,61 +4,11 @@ #include #include +#include "sub.h" + struct sh_sub; -struct osd_state; struct ass_track; - -enum sub_bitmap_format { - SUBBITMAP_EMPTY = 0,// no bitmaps; always has num_parts==0 - SUBBITMAP_LIBASS, // A8, with a per-surface blend color (libass.color) - SUBBITMAP_RGBA, // B8G8R8A8, can be scaled - SUBBITMAP_OLD, // I8A8 (monochrome), premultiplied alpha - SUBBITMAP_OLD_PLANAR, // like previous, but bitmap points to old_osd_planar - - SUBBITMAP_COUNT -}; - -// For SUBBITMAP_OLD_PANAR -struct old_osd_planar { - unsigned char *bitmap; - unsigned char *alpha; -}; - -typedef struct mp_eosd_res { - int w, h; // screen dimensions, including black borders - int mt, mb, ml, mr; // borders (top, bottom, left, right) -} mp_eosd_res_t; - -struct sub_bitmap { - void *bitmap; - int stride; - int w, h; - int x, y; - // Note: not clipped, going outside the screen area is allowed - int dw, dh; - - union { - struct { - uint32_t color; - } libass; - }; -}; - -typedef struct sub_bitmaps { - int render_index; // for VO cache state (limited by MAX_OSD_PARTS) - - enum sub_bitmap_format format; - bool scaled; // if false, dw==w && dh==h - - struct sub_bitmap *parts; - int num_parts; - - // Provided for VOs with old code - struct ass_image *imgs; - - // Incremented on each change - int bitmap_id, bitmap_pos_id; -} mp_eosd_images_t; +struct MPOpts *opts; struct sub_render_params { double pts; diff --git a/sub/osd_libass.c b/sub/osd_libass.c index 811bc009f3..f3296c6091 100644 --- a/sub/osd_libass.c +++ b/sub/osd_libass.c @@ -196,7 +196,7 @@ static void update_progbar(struct osd_state *osd, struct osd_object *obj) // Assume the OSD bar takes 2/3 of the OSD width at PlayResY=288 and // FontSize=22 with an OSD aspect ratio of 16:9. Rescale as needed. // xxx can fail when unknown fonts are involved - double asp = (double)osd->w / osd->h; + double asp = (double)osd->res.w / osd->res.h; double scale = (asp / 1.77777) * (obj->osd_track->PlayResY / 288.0); style->ScaleX = style->ScaleY = scale; style->FontSize = 22.0; @@ -285,7 +285,7 @@ void osd_object_get_bitmaps(struct osd_state *osd, struct osd_object *obj, if (!obj->osd_track) return; - ass_set_frame_size(osd->osd_render, osd->w, osd->h); + ass_set_frame_size(osd->osd_render, osd->res.w, osd->res.h); mp_ass_render_frame(osd->osd_render, obj->osd_track, 0, &obj->parts_cache, out_imgs); talloc_steal(obj, obj->parts_cache); diff --git a/sub/sd_ass.c b/sub/sd_ass.c index fca47c557b..44c91c6fdc 100644 --- a/sub/sd_ass.c +++ b/sub/sd_ass.c @@ -28,6 +28,7 @@ #include "mp_msg.h" #include "libmpdemux/stheader.h" #include "sub.h" +#include "dec_sub.h" #include "ass_mp.h" #include "sd.h" #include "subassconvert.h" diff --git a/sub/sd_lavc.c b/sub/sd_lavc.c index 7f327957dd..a10ac5e18e 100644 --- a/sub/sd_lavc.c +++ b/sub/sd_lavc.c @@ -25,6 +25,7 @@ #include "sd.h" #include "spudec.h" // Current code still pushes subs directly to global spudec +#include "dec_sub.h" #include "sub.h" struct sd_lavc_priv { diff --git a/sub/sub.c b/sub/sub.c index 600ef6fae1..b2d9eb82fc 100644 --- a/sub/sub.c +++ b/sub/sub.c @@ -35,7 +35,7 @@ #include "mp_msg.h" #include "libvo/video_out.h" #include "sub.h" -#include "sub/ass_mp.h" +#include "dec_sub.h" #include "img_convert.h" #include "spudec.h" @@ -92,9 +92,11 @@ static struct osd_state *global_osd; static void osd_update_ext(struct osd_state *osd, struct mp_eosd_res res) { - if (osd->w != res.w || osd->h != res.h) { - osd->w = res.w; - osd->h = res.h; + struct mp_eosd_res old = osd->res; + if (old.w != res.w || old.h != res.h || old.ml != res.ml || old.mt != res.mt + || old.mr != res.mr || old.mb != res.mb) + { + osd->res = res; for (int n = 0; n < MAX_OSD_PARTS; n++) osd->objs[n]->force_redraw = true; } @@ -171,7 +173,7 @@ static bool render_object(struct osd_state *osd, struct osd_object *obj, if (obj->type == OSDTYPE_SPU) { *out_imgs = (struct sub_bitmaps) {0}; if (spu_visible(osd, obj)) - spudec_get_bitmap(vo_spudec, osd->w, osd->h, out_imgs); + spudec_get_bitmap(vo_spudec, osd->res.w, osd->res.h, out_imgs); // Normal change-detection (sub. dec. calls vo_osd_changed(OSDTYPE_SPU)) if (obj->force_redraw) { out_imgs->bitmap_id++; @@ -269,7 +271,7 @@ bool osd_draw_sub(struct osd_state *osd, struct sub_bitmaps *out_imgs, void draw_osd_with_eosd(struct vo *vo, struct osd_state *osd) { - mp_eosd_res_t dim = {0}; + struct mp_eosd_res dim = {0}; if (vo_control(vo, VOCTRL_GET_EOSD_RES, &dim) != VO_TRUE) return; diff --git a/sub/sub.h b/sub/sub.h index ed3010c1af..6a83036460 100644 --- a/sub/sub.h +++ b/sub/sub.h @@ -20,11 +20,64 @@ #define MPLAYER_SUB_H #include +#include #include "subreader.h" -#include "dec_sub.h" struct vo; +struct sub_render_params; + +enum sub_bitmap_format { + SUBBITMAP_EMPTY = 0,// no bitmaps; always has num_parts==0 + SUBBITMAP_LIBASS, // A8, with a per-surface blend color (libass.color) + SUBBITMAP_RGBA, // B8G8R8A8, can be scaled + SUBBITMAP_OLD, // I8A8 (monochrome), premultiplied alpha + SUBBITMAP_OLD_PLANAR, // like previous, but bitmap points to old_osd_planar + + SUBBITMAP_COUNT +}; + +// For SUBBITMAP_OLD_PANAR +struct old_osd_planar { + unsigned char *bitmap; + unsigned char *alpha; +}; + +struct sub_bitmap { + void *bitmap; + int stride; + int w, h; + int x, y; + // Note: not clipped, going outside the screen area is allowed + int dw, dh; + + union { + struct { + uint32_t color; + } libass; + }; +}; + +struct sub_bitmaps { + int render_index; // for VO cache state (limited by MAX_OSD_PARTS) + + enum sub_bitmap_format format; + bool scaled; // if false, dw==w && dh==h + + struct sub_bitmap *parts; + int num_parts; + + // Provided for VOs with old code + struct ass_image *imgs; + + // Incremented on each change + int bitmap_id, bitmap_pos_id; +}; + +struct mp_eosd_res { + int w, h; // screen dimensions, including black borders + int mt, mb, ml, mr; // borders (top, bottom, left, right) +}; enum mp_osdtype { OSDTYPE_SUB, @@ -71,7 +124,7 @@ struct osd_state { bool render_subs_in_filter; - int w, h; + struct mp_eosd_res res; char *osd_text; // OSDTYPE_OSD int progbar_type, progbar_value; // OSDTYPE_PROGBAR