summaryrefslogtreecommitdiffstats
path: root/sub/sub.h
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2012-09-28 21:38:52 +0200
committerwm4 <wm4@nowhere>2012-10-16 07:26:30 +0200
commit3365514951e9c07ec3a21bb3898e5796c214f8b7 (patch)
tree168eec4a47cbd32fa6e6485a884203e350ba8474 /sub/sub.h
parent3099498154a06c6df0c365de2cc0af09686cd6e1 (diff)
downloadmpv-3365514951e9c07ec3a21bb3898e5796c214f8b7.tar.bz2
mpv-3365514951e9c07ec3a21bb3898e5796c214f8b7.tar.xz
sub: allow rendering OSD in ASS image format directly, simplify
Before this commit, the OSD was drawn using libass, but the resulting bitmaps were converted to the internal mplayer OSD format. We want to get rid of the old OSD format, because it's monochrome, and can't even be rendered directly using modern video output methods (like with OpenGL/Direct3D/VDPAU). Change it so that VOs can get the ASS images directly, without additional conversions. (This also has the consequence that the OSD can render colors now.) Currently, this is vo_gl3 only. The other VOs still use the old method. Also, the old OSD format is still used for all VOs with DVD subtitles (spudec). Rewrite sub.c. Remove all the awkward flags and bounding boxes and change detection things. It turns out that much of that isn't needed. Move code related to converting subtitle images to img_convert.c. (It has to be noted that all of these conversions were already done before in some places, and that the new code actually makes less use of them.)
Diffstat (limited to 'sub/sub.h')
-rw-r--r--sub/sub.h83
1 files changed, 37 insertions, 46 deletions
diff --git a/sub/sub.h b/sub/sub.h
index 74d2b5a37a..1dee0c8a8f 100644
--- a/sub/sub.h
+++ b/sub/sub.h
@@ -26,48 +26,40 @@
struct vo;
-typedef struct mp_osd_bbox_s {
- int x1,y1,x2,y2;
-} mp_osd_bbox_t;
-
#define OSDTYPE_ASS 0
#define OSDTYPE_OSD 1
#define OSDTYPE_SUBTITLE 2
#define OSDTYPE_PROGBAR 3
#define OSDTYPE_SPU 4
-#define OSDFLAG_VISIBLE 1
-#define OSDFLAG_CHANGED 2
-#define OSDFLAG_BBOX 4
-#define OSDFLAG_OLD_BBOX 8
-#define OSDFLAG_FORCE_UPDATE 16
-
-#define MAX_UCS 1600
-#define MAX_UCSLINES 16
-
-typedef struct mp_osd_obj_s {
- struct mp_osd_obj_s* next;
- unsigned char type;
- unsigned short flags;
- int x,y;
- int dxs,dys;
- mp_osd_bbox_t bbox; // bounding box
- mp_osd_bbox_t old_bbox; // the renderer will save bbox here
- int stride;
-
- int allocated;
- unsigned char *alpha_buffer;
- unsigned char *bitmap_buffer;
+#define MAX_OSD_PARTS 5
+
+#define OSD_CONV_CACHE_MAX 2
+
+struct osd_object {
+ int type; // OSDTYPE_*
+ bool force_redraw;
+
+ // caches for OSD conversion (internal to render_object())
+ struct osd_conv_cache *cache[OSD_CONV_CACHE_MAX];
+
+ struct sub_bitmaps cached;
+ // VO cache state
+ int vo_bitmap_id;
+ int vo_bitmap_pos_id;
+
+ // Internally used by osd_libass.c
struct ass_track *osd_track;
-} mp_osd_obj_t;
+ struct sub_bitmap *parts_cache;
+};
struct osd_state {
+ struct osd_object *objs[MAX_OSD_PARTS];
+
struct ass_library *ass_library;
struct ass_renderer *ass_renderer;
struct sh_sub *sh_sub;
- int bitmap_id;
- int bitmap_pos_id;
double sub_pts;
double sub_offset;
struct mp_eosd_res dim;
@@ -76,16 +68,19 @@ struct osd_state {
bool unscaled;
bool support_rgba;
- struct ass_renderer *osd_render;
- struct ass_library *osd_ass_library;
- char *osd_text;
int w, h;
- struct sub_bitmaps eosd[MAX_OSD_PARTS];
+ char *osd_text; // OSDTYPE_OSD
- void *scratch;
+ // temporary for sub decoders
+ int bitmap_id;
+ int bitmap_pos_id;
struct MPOpts *opts;
+
+ // Internally used by osd_libass.c
+ struct ass_renderer *osd_render;
+ struct ass_library *osd_ass_library;
};
extern subtitle* vo_sub;
@@ -160,29 +155,25 @@ void osd_draw_text_ext(struct osd_state *osd, int dxs, int dys,
int stride),
void *ctx);
-void emulate_draw_osd(struct vo *vo, struct osd_state *osd);
+void draw_osd_with_eosd(struct vo *vo, struct osd_state *osd);
struct osd_state *osd_create(struct MPOpts *opts, struct ass_library *asslib);
void osd_set_text(struct osd_state *osd, const char *text);
-int osd_update(struct osd_state *osd, int dxs, int dys);
+void osd_update(struct osd_state *osd, int dxs, int dys);
void vo_osd_changed(int new_value);
void vo_osd_reset_changed(void);
bool vo_osd_has_changed(struct osd_state *osd);
void vo_osd_resized(void);
-int vo_osd_check_range_update(int,int,int,int);
void osd_free(struct osd_state *osd);
-// used only by osd_ft.c or osd_libass.c
-void osd_alloc_buf(mp_osd_obj_t* obj);
-void vo_draw_text_from_buffer(mp_osd_obj_t* obj,void (*draw_alpha)(void *ctx, int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride), void *ctx);
+bool sub_bitmaps_bb(struct sub_bitmaps *imgs, int *x1, int *y1,
+ int *x2, int *y2);
+
+// defined in osd_libass.c and osd_dummy.c
-// defined in osd_ft.c or osd_libass.c
-void vo_update_text_osd(struct osd_state *osd, mp_osd_obj_t *obj);
-void vo_update_text_progbar(struct osd_state *osd, mp_osd_obj_t *obj);
-void vo_update_text_sub(struct osd_state *osd, mp_osd_obj_t *obj);
+void osd_object_get_bitmaps(struct osd_state *osd, struct osd_object *obj,
+ struct sub_bitmaps *out_imgs);
void osd_get_function_sym(char *buffer, size_t buffer_size, int osd_function);
-void osd_font_invalidate(void);
-void osd_font_load(struct osd_state *osd);
void osd_init_backend(struct osd_state *osd);
void osd_destroy_backend(struct osd_state *osd);