diff options
author | wm4 <wm4@mplayer2.org> | 2012-03-22 06:26:37 +0100 |
---|---|---|
committer | wm4 <wm4@mplayer2.org> | 2012-07-28 23:36:07 +0200 |
commit | 74e7a1e937c10d9f4d8ce9b0ba4edee52044a757 (patch) | |
tree | c421c5b79b36ad4e29b3141b4b5753107b77a343 /sub/sub.h | |
parent | 7a06095dc3e5a3590f489aad3619dc6023a5b0f5 (diff) | |
download | mpv-74e7a1e937c10d9f4d8ce9b0ba4edee52044a757.tar.bz2 mpv-74e7a1e937c10d9f4d8ce9b0ba4edee52044a757.tar.xz |
osd: use libass for OSD rendering
The OSD will now be rendered with libass. The old rendering code, which
used freetype/fontconfig and did text layout manually, is disabled. To
re-enable the old code, use the --disable-libass-osd configure switch.
Some switches do nothing with the new code enabled, such as -subalign,
-sub-bg-alpha, -sub-bg-color, and many more. (The reason is mostly that
the code for rendering unstyled subtitles with libass doesn't make any
attempts to support them. Some of them could be supported in theory.)
Teletext rendering is not implemented in the new OSD rendering code. I
don't have any teletext sources for testing, and since teletext is
being phased out world-wide, the need for this is questionable.
Note that rendering is extremely inefficient, mostly because the libass
output is blended with the extremely strange mplayer OSD format. This
could be improved at a later point.
Remove most OSD rendering from vo_aa.c, because that was extremely
hacky, can't be made work with osd_libass, and didn't work anyway in
my tests.
Internally, some cleanup is done. Subtitle and OSD related variable
declarations were literally all over the place. Move them to sub.h and
sub.c, which were hoarding most of these declarations already. Make the
player core in mplayer.c free of concerns like bitmap font loading.
The old OSD rendering code has been moved to osd_ft.c. The font_load.c
and font_load_ft.c are only needed and compiled if the old OSD
rendering code is configured.
Diffstat (limited to 'sub/sub.h')
-rw-r--r-- | sub/sub.h | 40 |
1 files changed, 39 insertions, 1 deletions
@@ -66,19 +66,24 @@ typedef struct mp_osd_obj_s { int allocated; unsigned char *alpha_buffer; unsigned char *bitmap_buffer; + + struct ass_track *osd_track; } mp_osd_obj_t; struct osd_state { struct ass_library *ass_library; // flag to signal reinitialization due to ass-related option changes bool ass_force_reload; + int w, h; char *osd_text; + struct ass_renderer *osd_render; struct font_desc *sub_font; struct ass_track *ass_track; double pts; double sub_offset; bool ass_track_changed; bool vsfilter_aspect; + struct MPOpts *opts; }; #include "subreader.h" @@ -133,6 +138,22 @@ extern int spu_alignment; extern int spu_aamode; extern float spu_gaussvar; +extern char *subtitle_font_encoding; +extern float text_font_scale_factor; +extern float osd_font_scale_factor; +extern float subtitle_font_radius; +extern float subtitle_font_thickness; +extern int subtitle_autoscale; + +extern char *font_name; +extern char *sub_font_name; +extern float font_factor; +extern float sub_delay; +extern float sub_fps; + +extern int font_fontconfig; +extern int sub_justify; + void osd_draw_text(struct osd_state *osd, int dxs, int dys, void (*draw_alpha)(void *ctx, int x0, int y0, int w, int h, unsigned char* src, unsigned char *srca, @@ -149,10 +170,11 @@ void osd_draw_text_ext(struct osd_state *osd, int dxs, int dys, void osd_remove_text(struct osd_state *osd, int dxs, int dys, void (*remove)(int x0, int y0, int w, int h)); -struct osd_state *osd_create(void); +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); int vo_osd_changed(int new_value); +void vo_osd_resized(void); int vo_osd_check_range_update(int,int,int,int); void osd_free(struct osd_state *osd); @@ -170,4 +192,20 @@ void osd_set_nav_box (uint16_t sx, uint16_t sy, uint16_t ex, uint16_t ey); #define vo_remove_text(...) osd_remove_text(global_osd, __VA_ARGS__) #endif +// used only by osd_ft.c or osd_libass.c +void osd_alloc_buf(mp_osd_obj_t* obj); +void draw_alpha_buf(mp_osd_obj_t* obj, int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride); +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); + +// 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_teletext(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_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); + #endif /* MPLAYER_SUB_H */ |