2009-02-08 03:27:30 +00:00
|
|
|
/*
|
|
|
|
* This file is part of MPlayer.
|
|
|
|
*
|
|
|
|
* MPlayer is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* MPlayer is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with MPlayer; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
2001-03-24 04:36:17 +00:00
|
|
|
|
2002-04-06 19:09:06 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2002-08-14 21:28:18 +00:00
|
|
|
#include <string.h>
|
2002-04-06 19:09:06 +00:00
|
|
|
|
2012-07-30 19:13:03 +00:00
|
|
|
#include <libavutil/mem.h>
|
|
|
|
#include <libavutil/common.h>
|
|
|
|
|
2002-01-11 16:06:45 +00:00
|
|
|
#include "config.h"
|
2002-11-06 23:54:29 +00:00
|
|
|
|
2006-11-25 13:03:51 +00:00
|
|
|
#include "stream/stream.h"
|
2006-11-25 11:20:02 +00:00
|
|
|
|
2007-09-10 11:10:50 +00:00
|
|
|
#include "osdep/timer.h"
|
2007-07-29 17:57:39 +00:00
|
|
|
|
2008-06-23 22:53:58 +00:00
|
|
|
#include "talloc.h"
|
2007-05-20 16:10:45 +00:00
|
|
|
#include "mplayer.h"
|
2002-04-15 19:17:12 +00:00
|
|
|
#include "mp_msg.h"
|
2011-01-26 17:40:52 +00:00
|
|
|
#include "libvo/video_out.h"
|
2001-03-27 00:32:24 +00:00
|
|
|
#include "sub.h"
|
2012-08-07 00:12:15 +00:00
|
|
|
#include "sub/ass_mp.h"
|
2004-10-28 01:15:53 +00:00
|
|
|
#include "spudec.h"
|
2001-03-27 00:32:24 +00:00
|
|
|
|
2003-09-21 13:20:06 +00:00
|
|
|
|
2008-05-01 06:12:38 +00:00
|
|
|
char * const sub_osd_names[]={
|
2009-07-06 22:15:02 +00:00
|
|
|
_("Seekbar"),
|
|
|
|
_("Play"),
|
|
|
|
_("Pause"),
|
|
|
|
_("Stop"),
|
|
|
|
_("Rewind"),
|
|
|
|
_("Forward"),
|
|
|
|
_("Clock"),
|
|
|
|
_("Contrast"),
|
|
|
|
_("Saturation"),
|
|
|
|
_("Volume"),
|
|
|
|
_("Brightness"),
|
|
|
|
_("Hue"),
|
|
|
|
_("Balance")
|
2001-10-27 14:30:43 +00:00
|
|
|
};
|
2008-05-01 06:12:38 +00:00
|
|
|
char * const sub_osd_names_short[] ={ "", "|>", "||", "[]", "<<" , ">>", "", "", "", "", "", "", "" };
|
2001-10-27 14:30:43 +00:00
|
|
|
|
2001-05-14 22:08:12 +00:00
|
|
|
int sub_unicode=0;
|
2001-08-13 11:08:18 +00:00
|
|
|
int sub_utf8=0;
|
2002-02-20 22:43:34 +00:00
|
|
|
int sub_pos=100;
|
2002-12-27 21:41:40 +00:00
|
|
|
int sub_width_p=100;
|
2005-10-23 15:35:28 +00:00
|
|
|
int sub_alignment=2; /* 0=top, 1=center, 2=bottom */
|
2002-10-06 17:40:51 +00:00
|
|
|
int sub_visibility=1;
|
2002-12-28 15:03:23 +00:00
|
|
|
int sub_bg_color=0; /* subtitles background color */
|
|
|
|
int sub_bg_alpha=0;
|
2003-06-09 00:24:49 +00:00
|
|
|
int sub_justify=0;
|
2001-03-24 04:36:17 +00:00
|
|
|
|
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.
2012-03-22 05:26:37 +00:00
|
|
|
int vo_osd_progbar_type=-1;
|
|
|
|
int vo_osd_progbar_value=100; // 0..256
|
|
|
|
subtitle* vo_sub=NULL;
|
|
|
|
char *subtitle_font_encoding = NULL;
|
|
|
|
float text_font_scale_factor = 3.5;
|
|
|
|
float osd_font_scale_factor = 4.0;
|
|
|
|
float subtitle_font_radius = 2.0;
|
|
|
|
float subtitle_font_thickness = 2.0;
|
|
|
|
// 0 = no autoscale
|
|
|
|
// 1 = video height
|
|
|
|
// 2 = video width
|
|
|
|
// 3 = diagonal
|
|
|
|
int subtitle_autoscale = 3;
|
|
|
|
|
|
|
|
char *font_name = NULL;
|
|
|
|
char *sub_font_name = NULL;
|
|
|
|
float font_factor = 0.75;
|
|
|
|
float sub_delay = 0;
|
|
|
|
float sub_fps = 0;
|
2002-04-17 20:46:12 +00:00
|
|
|
|
2002-08-28 20:45:42 +00:00
|
|
|
// allocates/enlarges the alpha/bitmap buffer
|
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.
2012-03-22 05:26:37 +00:00
|
|
|
void osd_alloc_buf(mp_osd_obj_t* obj)
|
2002-08-28 20:45:42 +00:00
|
|
|
{
|
|
|
|
int len;
|
|
|
|
if (obj->bbox.x2 < obj->bbox.x1) obj->bbox.x2 = obj->bbox.x1;
|
|
|
|
if (obj->bbox.y2 < obj->bbox.y1) obj->bbox.y2 = obj->bbox.y1;
|
|
|
|
obj->stride = ((obj->bbox.x2-obj->bbox.x1)+7)&(~7);
|
|
|
|
len = obj->stride*(obj->bbox.y2-obj->bbox.y1);
|
|
|
|
if (obj->allocated<len) {
|
|
|
|
obj->allocated = len;
|
2012-08-04 20:18:58 +00:00
|
|
|
av_free(obj->bitmap_buffer);
|
|
|
|
av_free(obj->alpha_buffer);
|
2012-07-30 19:13:03 +00:00
|
|
|
obj->bitmap_buffer = av_malloc(len);
|
|
|
|
obj->alpha_buffer = av_malloc(len);
|
2002-08-28 20:45:42 +00:00
|
|
|
}
|
2002-12-28 15:03:23 +00:00
|
|
|
memset(obj->bitmap_buffer, sub_bg_color, len);
|
|
|
|
memset(obj->alpha_buffer, sub_bg_alpha, len);
|
2002-08-28 20:45:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// renders the buffer
|
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.
2012-03-22 05:26:37 +00:00
|
|
|
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)
|
2008-04-04 03:36:36 +00:00
|
|
|
{
|
2002-08-28 20:45:42 +00:00
|
|
|
if (obj->allocated > 0) {
|
2008-04-04 03:36:36 +00:00
|
|
|
draw_alpha(ctx,
|
|
|
|
obj->bbox.x1,obj->bbox.y1,
|
2002-08-28 20:45:42 +00:00
|
|
|
obj->bbox.x2-obj->bbox.x1,
|
|
|
|
obj->bbox.y2-obj->bbox.y1,
|
|
|
|
obj->bitmap_buffer,
|
|
|
|
obj->alpha_buffer,
|
|
|
|
obj->stride);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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.
2012-03-22 05:26:37 +00:00
|
|
|
inline static void vo_update_spudec_sub(struct osd_state *osd, mp_osd_obj_t* obj)
|
2002-05-25 17:40:40 +00:00
|
|
|
{
|
|
|
|
unsigned int bbox[4];
|
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.
2012-03-22 05:26:37 +00:00
|
|
|
spudec_calc_bbox(vo_spudec, osd->w, osd->h, bbox);
|
2002-05-25 17:40:40 +00:00
|
|
|
obj->bbox.x1 = bbox[0];
|
|
|
|
obj->bbox.x2 = bbox[1];
|
|
|
|
obj->bbox.y1 = bbox[2];
|
|
|
|
obj->bbox.y2 = bbox[3];
|
|
|
|
obj->flags |= OSDFLAG_BBOX;
|
|
|
|
}
|
|
|
|
|
2008-04-04 03:36:36 +00:00
|
|
|
inline static void vo_draw_spudec_sub(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)
|
2002-05-25 17:40:40 +00:00
|
|
|
{
|
2008-04-04 03:36:36 +00:00
|
|
|
spudec_draw_scaled(vo_spudec, obj->dxs, obj->dys, draw_alpha, ctx);
|
2002-05-25 17:40:40 +00:00
|
|
|
}
|
2001-03-24 04:36:17 +00:00
|
|
|
|
2001-11-20 18:36:50 +00:00
|
|
|
void *vo_spudec=NULL;
|
2002-01-10 17:21:00 +00:00
|
|
|
void *vo_vobsub=NULL;
|
2001-11-20 18:36:50 +00:00
|
|
|
|
2001-06-02 16:02:38 +00:00
|
|
|
static int draw_alpha_init_flag=0;
|
2001-03-25 04:28:40 +00:00
|
|
|
|
2008-12-03 23:01:03 +00:00
|
|
|
void vo_draw_alpha_init(void);
|
2001-06-12 14:03:18 +00:00
|
|
|
|
2002-08-22 13:58:38 +00:00
|
|
|
mp_osd_obj_t* vo_osd_list=NULL;
|
2001-03-27 00:32:24 +00:00
|
|
|
|
2006-07-08 15:26:36 +00:00
|
|
|
static mp_osd_obj_t* new_osd_obj(int type){
|
2002-04-15 19:17:12 +00:00
|
|
|
mp_osd_obj_t* osd=malloc(sizeof(mp_osd_obj_t));
|
|
|
|
memset(osd,0,sizeof(mp_osd_obj_t));
|
|
|
|
osd->next=vo_osd_list;
|
|
|
|
vo_osd_list=osd;
|
|
|
|
osd->type=type;
|
2002-08-28 20:45:42 +00:00
|
|
|
osd->alpha_buffer = NULL;
|
|
|
|
osd->bitmap_buffer = NULL;
|
|
|
|
osd->allocated = -1;
|
2002-04-15 19:17:12 +00:00
|
|
|
return osd;
|
|
|
|
}
|
2002-01-10 17:21:00 +00:00
|
|
|
|
2008-06-23 22:53:58 +00:00
|
|
|
void osd_free(struct osd_state *osd)
|
|
|
|
{
|
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.
2012-03-22 05:26:37 +00:00
|
|
|
osd_destroy_backend(osd);
|
2002-04-15 19:17:12 +00:00
|
|
|
mp_osd_obj_t* obj=vo_osd_list;
|
|
|
|
while(obj){
|
|
|
|
mp_osd_obj_t* next=obj->next;
|
2012-08-04 20:18:58 +00:00
|
|
|
av_free(obj->alpha_buffer);
|
|
|
|
av_free(obj->bitmap_buffer);
|
2002-04-15 19:17:12 +00:00
|
|
|
free(obj);
|
|
|
|
obj=next;
|
2002-01-10 17:21:00 +00:00
|
|
|
}
|
2002-04-15 19:17:12 +00:00
|
|
|
vo_osd_list=NULL;
|
2008-06-23 22:53:58 +00:00
|
|
|
talloc_free(osd);
|
2002-04-15 19:17:12 +00:00
|
|
|
}
|
2002-01-10 17:21:00 +00:00
|
|
|
|
2010-04-25 19:57:49 +00:00
|
|
|
static int osd_update_ext(struct osd_state *osd, int dxs, int dys,
|
|
|
|
int left_border, int top_border, int right_border,
|
|
|
|
int bottom_border, int orig_w, int orig_h)
|
2008-06-23 22:53:58 +00:00
|
|
|
{
|
2002-04-15 19:17:12 +00:00
|
|
|
mp_osd_obj_t* obj=vo_osd_list;
|
|
|
|
int chg=0;
|
2002-08-28 20:45:42 +00:00
|
|
|
|
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.
2012-03-22 05:26:37 +00:00
|
|
|
osd->w = dxs;
|
|
|
|
osd->h = dys;
|
2005-04-10 11:54:31 +00:00
|
|
|
|
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.
2012-03-22 05:26:37 +00:00
|
|
|
osd_font_load(osd);
|
2002-08-28 20:45:42 +00:00
|
|
|
|
2002-04-15 19:17:12 +00:00
|
|
|
while(obj){
|
|
|
|
if(dxs!=obj->dxs || dys!=obj->dys || obj->flags&OSDFLAG_FORCE_UPDATE){
|
|
|
|
int vis=obj->flags&OSDFLAG_VISIBLE;
|
2002-04-15 20:51:34 +00:00
|
|
|
obj->flags&=~OSDFLAG_BBOX;
|
2002-04-15 19:17:12 +00:00
|
|
|
switch(obj->type){
|
|
|
|
case OSDTYPE_SUBTITLE:
|
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.
2012-03-22 05:26:37 +00:00
|
|
|
vo_update_text_sub(osd, obj);
|
2002-04-15 19:17:12 +00:00
|
|
|
break;
|
|
|
|
case OSDTYPE_PROGBAR:
|
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.
2012-03-22 05:26:37 +00:00
|
|
|
vo_update_text_progbar(osd, obj);
|
2002-04-15 19:17:12 +00:00
|
|
|
break;
|
|
|
|
case OSDTYPE_SPU:
|
2002-10-06 17:40:51 +00:00
|
|
|
if(sub_visibility && vo_spudec && spudec_visible(vo_spudec)){
|
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.
2012-03-22 05:26:37 +00:00
|
|
|
vo_update_spudec_sub(osd, obj);
|
2002-04-15 19:17:12 +00:00
|
|
|
obj->flags|=OSDFLAG_VISIBLE|OSDFLAG_CHANGED;
|
2002-05-25 17:40:40 +00:00
|
|
|
}
|
2002-04-15 19:17:12 +00:00
|
|
|
else
|
|
|
|
obj->flags&=~OSDFLAG_VISIBLE;
|
|
|
|
break;
|
|
|
|
case OSDTYPE_OSD:
|
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.
2012-03-22 05:26:37 +00:00
|
|
|
if(osd->osd_text[0]){
|
|
|
|
vo_update_text_osd(osd, obj);
|
2002-04-15 19:17:12 +00:00
|
|
|
obj->flags|=OSDFLAG_VISIBLE|OSDFLAG_CHANGED;
|
2002-04-15 20:51:34 +00:00
|
|
|
} else
|
2002-04-15 19:17:12 +00:00
|
|
|
obj->flags&=~OSDFLAG_VISIBLE;
|
|
|
|
break;
|
|
|
|
}
|
2002-04-15 20:51:34 +00:00
|
|
|
// check bbox:
|
|
|
|
if(!(obj->flags&OSDFLAG_BBOX)){
|
|
|
|
// we don't know, so assume the whole screen changed :(
|
|
|
|
obj->bbox.x1=obj->bbox.y1=0;
|
|
|
|
obj->bbox.x2=dxs;
|
|
|
|
obj->bbox.y2=dys;
|
|
|
|
obj->flags|=OSDFLAG_BBOX;
|
2002-04-17 20:46:12 +00:00
|
|
|
} else {
|
|
|
|
// check bbox, reduce it if it's out of bounds (corners):
|
|
|
|
if(obj->bbox.x1<0) obj->bbox.x1=0;
|
|
|
|
if(obj->bbox.y1<0) obj->bbox.y1=0;
|
|
|
|
if(obj->bbox.x2>dxs) obj->bbox.x2=dxs;
|
|
|
|
if(obj->bbox.y2>dys) obj->bbox.y2=dys;
|
|
|
|
if(obj->flags&OSDFLAG_VISIBLE)
|
|
|
|
// debug:
|
|
|
|
mp_msg(MSGT_OSD,MSGL_DBG2,"OSD update: %d;%d %dx%d \n",
|
2002-04-15 20:51:34 +00:00
|
|
|
obj->bbox.x1,obj->bbox.y1,obj->bbox.x2-obj->bbox.x1,
|
|
|
|
obj->bbox.y2-obj->bbox.y1);
|
|
|
|
}
|
2002-04-15 19:17:12 +00:00
|
|
|
// check if visibility changed:
|
|
|
|
if(vis != (obj->flags&OSDFLAG_VISIBLE) ) obj->flags|=OSDFLAG_CHANGED;
|
2002-04-15 20:51:34 +00:00
|
|
|
// remove the cause of automatic update:
|
2002-04-15 19:17:12 +00:00
|
|
|
obj->dxs=dxs; obj->dys=dys;
|
|
|
|
obj->flags&=~OSDFLAG_FORCE_UPDATE;
|
|
|
|
}
|
|
|
|
if(obj->flags&OSDFLAG_CHANGED){
|
|
|
|
chg|=1<<obj->type;
|
|
|
|
mp_msg(MSGT_OSD,MSGL_DBG2,"OSD chg: %d V: %s pb:%d \n",obj->type,(obj->flags&OSDFLAG_VISIBLE)?"yes":"no",vo_osd_progbar_type);
|
|
|
|
}
|
|
|
|
obj=obj->next;
|
|
|
|
}
|
|
|
|
return chg;
|
|
|
|
}
|
2001-03-27 00:32:24 +00:00
|
|
|
|
2009-01-15 03:07:09 +00:00
|
|
|
int osd_update(struct osd_state *osd, int dxs, int dys)
|
|
|
|
{
|
|
|
|
return osd_update_ext(osd, dxs, dys, 0, 0, 0, 0, dxs, dys);
|
2009-01-10 13:47:41 +00:00
|
|
|
}
|
|
|
|
|
2012-08-07 17:21:46 +00:00
|
|
|
struct osd_state *osd_create(struct MPOpts *opts, struct ass_library *asslib)
|
2008-06-23 22:53:58 +00:00
|
|
|
{
|
2008-06-24 05:29:36 +00:00
|
|
|
struct osd_state *osd = talloc_zero(NULL, struct osd_state);
|
2008-06-23 22:53:58 +00:00
|
|
|
*osd = (struct osd_state){
|
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.
2012-03-22 05:26:37 +00:00
|
|
|
.opts = opts,
|
2012-08-07 17:21:46 +00:00
|
|
|
.ass_library = asslib,
|
2008-06-23 22:53:58 +00:00
|
|
|
};
|
2001-06-02 16:02:38 +00:00
|
|
|
if(!draw_alpha_init_flag){
|
|
|
|
draw_alpha_init_flag=1;
|
|
|
|
vo_draw_alpha_init();
|
|
|
|
}
|
2011-01-20 23:45:28 +00:00
|
|
|
// temp hack, should be moved to mplayer later
|
2002-04-15 19:17:12 +00:00
|
|
|
new_osd_obj(OSDTYPE_OSD);
|
|
|
|
new_osd_obj(OSDTYPE_SUBTITLE);
|
|
|
|
new_osd_obj(OSDTYPE_PROGBAR);
|
|
|
|
new_osd_obj(OSDTYPE_SPU);
|
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.
2012-03-22 05:26:37 +00:00
|
|
|
osd_font_invalidate();
|
2012-08-01 16:23:28 +00:00
|
|
|
osd->osd_text = talloc_strdup(osd, "");
|
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.
2012-03-22 05:26:37 +00:00
|
|
|
osd_init_backend(osd);
|
2008-06-23 22:53:58 +00:00
|
|
|
return osd;
|
2002-04-15 19:17:12 +00:00
|
|
|
}
|
2001-06-02 16:02:38 +00:00
|
|
|
|
2012-08-01 16:23:28 +00:00
|
|
|
void osd_set_text(struct osd_state *osd, const char *text)
|
|
|
|
{
|
2011-08-08 08:07:17 +00:00
|
|
|
if (!text)
|
|
|
|
text = "";
|
2012-08-01 16:23:28 +00:00
|
|
|
if (strcmp(osd->osd_text, text) == 0)
|
|
|
|
return;
|
|
|
|
talloc_free(osd->osd_text);
|
2011-08-08 08:07:17 +00:00
|
|
|
osd->osd_text = talloc_strdup(osd, text);
|
2012-08-01 16:23:28 +00:00
|
|
|
vo_osd_changed(OSDTYPE_OSD);
|
2011-08-08 08:07:17 +00:00
|
|
|
}
|
|
|
|
|
2009-01-15 03:07:09 +00:00
|
|
|
void osd_draw_text_ext(struct osd_state *osd, int dxs, int dys,
|
|
|
|
int left_border, int top_border, int right_border,
|
|
|
|
int bottom_border, int orig_w, int orig_h,
|
|
|
|
void (*draw_alpha)(void *ctx, int x0, int y0, int w,
|
|
|
|
int h, unsigned char* src,
|
|
|
|
unsigned char *srca,
|
|
|
|
int stride),
|
2008-06-23 22:53:58 +00:00
|
|
|
void *ctx)
|
2008-04-04 03:36:36 +00:00
|
|
|
{
|
2002-04-15 22:08:50 +00:00
|
|
|
mp_osd_obj_t* obj=vo_osd_list;
|
2009-01-15 03:07:09 +00:00
|
|
|
osd_update_ext(osd, dxs, dys, left_border, top_border, right_border,
|
|
|
|
bottom_border, orig_w, orig_h);
|
2002-04-15 19:17:12 +00:00
|
|
|
while(obj){
|
2002-04-15 22:08:50 +00:00
|
|
|
if(obj->flags&OSDFLAG_VISIBLE){
|
2002-04-15 19:17:12 +00:00
|
|
|
switch(obj->type){
|
|
|
|
case OSDTYPE_SPU:
|
2008-04-04 03:36:36 +00:00
|
|
|
vo_draw_spudec_sub(obj, draw_alpha, ctx); // FIXME
|
2002-04-15 19:17:12 +00:00
|
|
|
break;
|
|
|
|
case OSDTYPE_OSD:
|
|
|
|
case OSDTYPE_SUBTITLE:
|
|
|
|
case OSDTYPE_PROGBAR:
|
2008-04-04 03:36:36 +00:00
|
|
|
vo_draw_text_from_buffer(obj, draw_alpha, ctx);
|
2002-04-15 19:17:12 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
obj->old_bbox=obj->bbox;
|
2002-04-15 22:08:50 +00:00
|
|
|
obj->flags|=OSDFLAG_OLD_BBOX;
|
|
|
|
}
|
|
|
|
obj->flags&=~OSDFLAG_CHANGED;
|
|
|
|
obj=obj->next;
|
2001-03-27 00:32:24 +00:00
|
|
|
}
|
|
|
|
}
|
2002-04-15 19:17:12 +00:00
|
|
|
|
2009-01-15 03:07:09 +00:00
|
|
|
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,
|
|
|
|
int stride),
|
|
|
|
void *ctx)
|
|
|
|
{
|
|
|
|
osd_draw_text_ext(osd, dxs, dys, 0, 0, 0, 0, dxs, dys, draw_alpha, ctx);
|
2009-01-10 13:47:41 +00:00
|
|
|
}
|
|
|
|
|
2012-08-01 16:23:28 +00:00
|
|
|
void vo_osd_changed(int new_value)
|
2002-02-22 15:25:11 +00:00
|
|
|
{
|
2002-04-15 19:17:12 +00:00
|
|
|
mp_osd_obj_t* obj=vo_osd_list;
|
|
|
|
|
|
|
|
while(obj){
|
|
|
|
if(obj->type==new_value) obj->flags|=OSDFLAG_FORCE_UPDATE;
|
|
|
|
obj=obj->next;
|
|
|
|
}
|
2012-08-01 16:23:28 +00:00
|
|
|
}
|
2002-04-15 19:17:12 +00:00
|
|
|
|
2012-08-06 23:58:43 +00:00
|
|
|
void vo_osd_reset_changed(void)
|
|
|
|
{
|
|
|
|
mp_osd_obj_t* obj = vo_osd_list;
|
|
|
|
while (obj) {
|
|
|
|
obj->flags = obj->flags & ~OSDFLAG_FORCE_UPDATE;
|
|
|
|
obj = obj->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-01 16:23:28 +00:00
|
|
|
bool vo_osd_has_changed(struct osd_state *osd)
|
|
|
|
{
|
|
|
|
mp_osd_obj_t* obj = vo_osd_list;
|
|
|
|
while (obj) {
|
|
|
|
if (obj->flags & OSDFLAG_FORCE_UPDATE)
|
|
|
|
return true;
|
|
|
|
obj = obj->next;
|
|
|
|
}
|
|
|
|
return false;
|
2002-02-22 15:25:11 +00:00
|
|
|
}
|
2002-04-15 19:17:12 +00:00
|
|
|
|
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.
2012-03-22 05:26:37 +00:00
|
|
|
void vo_osd_resized()
|
|
|
|
{
|
|
|
|
// font needs to be adjusted
|
|
|
|
osd_font_invalidate();
|
|
|
|
// OSD needs to be drawn fresh for new size
|
|
|
|
vo_osd_changed(OSDTYPE_OSD);
|
|
|
|
vo_osd_changed(OSDTYPE_SUBTITLE);
|
|
|
|
}
|
2002-04-16 00:35:01 +00:00
|
|
|
|
|
|
|
// return TRUE if we have osd in the specified rectangular area:
|
|
|
|
int vo_osd_check_range_update(int x1,int y1,int x2,int y2){
|
|
|
|
mp_osd_obj_t* obj=vo_osd_list;
|
|
|
|
while(obj){
|
|
|
|
if(obj->flags&OSDFLAG_VISIBLE){
|
|
|
|
if( (obj->bbox.x1<=x2 && obj->bbox.x2>=x1) &&
|
2006-11-29 11:57:16 +00:00
|
|
|
(obj->bbox.y1<=y2 && obj->bbox.y2>=y1) &&
|
2006-12-03 09:59:55 +00:00
|
|
|
obj->bbox.y2 > obj->bbox.y1 && obj->bbox.x2 > obj->bbox.x1
|
2006-11-29 11:57:16 +00:00
|
|
|
) return 1;
|
2002-04-16 00:35:01 +00:00
|
|
|
}
|
|
|
|
obj=obj->next;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|