summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libmpcodecs/dec_video.c5
-rw-r--r--libmpcodecs/dec_video.h5
-rw-r--r--libmpcodecs/vf.h3
-rw-r--r--libmpcodecs/vf_expand.c24
-rw-r--r--libmpcodecs/vf_vo.c2
-rw-r--r--libvo/old_vo_wrapper.c10
-rw-r--r--libvo/old_vo_wrapper.h4
-rw-r--r--libvo/sub.c43
-rw-r--r--libvo/sub.h27
-rw-r--r--libvo/video_out.c4
-rw-r--r--libvo/video_out.h5
-rw-r--r--libvo/vo_aa.c17
-rw-r--r--libvo/vo_xv.c4
-rw-r--r--mencoder.c12
-rw-r--r--mp_core.h1
-rw-r--r--mplayer.c31
16 files changed, 123 insertions, 74 deletions
diff --git a/libmpcodecs/dec_video.c b/libmpcodecs/dec_video.c
index 9293ee4b8d..9c9de3b51e 100644
--- a/libmpcodecs/dec_video.c
+++ b/libmpcodecs/dec_video.c
@@ -446,7 +446,8 @@ void *decode_video(sh_video_t *sh_video, unsigned char *start, int in_size,
return mpi;
}
-int filter_video(sh_video_t *sh_video, void *frame, double pts)
+int filter_video(sh_video_t *sh_video, void *frame, double pts,
+ struct osd_state *osd)
{
mp_image_t *mpi = frame;
unsigned int t2 = GetTimer();
@@ -454,7 +455,7 @@ int filter_video(sh_video_t *sh_video, void *frame, double pts)
// apply video filters and call the leaf vo/ve
int ret = vf->put_image(vf, mpi, pts);
if (ret > 0) {
- vf->control(vf, VFCTRL_DRAW_OSD, NULL);
+ vf->control(vf, VFCTRL_DRAW_OSD, osd);
#ifdef USE_ASS
vf->control(vf, VFCTRL_DRAW_EOSD, NULL);
#endif
diff --git a/libmpcodecs/dec_video.h b/libmpcodecs/dec_video.h
index 3cd8f832bf..271d08850e 100644
--- a/libmpcodecs/dec_video.h
+++ b/libmpcodecs/dec_video.h
@@ -3,6 +3,8 @@
#include "libmpdemux/stheader.h"
+struct osd_state;
+
// dec_video.c:
extern void vfm_help(void);
@@ -10,7 +12,8 @@ extern int init_best_video_codec(sh_video_t *sh_video,char** video_codec_list,ch
extern void uninit_video(sh_video_t *sh_video);
extern void *decode_video(sh_video_t *sh_video,unsigned char *start,int in_size,int drop_frame, double pts);
-extern int filter_video(sh_video_t *sh_video, void *frame, double pts);
+extern int filter_video(sh_video_t *sh_video, void *frame, double pts,
+ struct osd_state *osd);
extern int get_video_quality_max(sh_video_t *sh_video);
extern void set_video_quality(sh_video_t *sh_video,int quality);
diff --git a/libmpcodecs/vf.h b/libmpcodecs/vf.h
index 58cb74188a..504c616a73 100644
--- a/libmpcodecs/vf.h
+++ b/libmpcodecs/vf.h
@@ -88,6 +88,9 @@ typedef struct vf_seteq_s
#define VFCTRL_GET_PTS 17 /* Return last pts value that reached vf_vo*/
#define VFCTRL_SET_DEINTERLACE 18 /* Set deinterlacing status */
#define VFCTRL_GET_DEINTERLACE 19 /* Get deinterlacing status */
+/* Hack to make the OSD state object available to vf_expand which accesses
+ * the OSD state outside of normal OSD draw time. */
+#define VFCTRL_SET_OSD_OBJ 20
#include "vfcap.h"
diff --git a/libmpcodecs/vf_expand.c b/libmpcodecs/vf_expand.c
index 46ab7790cd..cdde44f82b 100644
--- a/libmpcodecs/vf_expand.c
+++ b/libmpcodecs/vf_expand.c
@@ -28,12 +28,13 @@
static struct vf_priv_s {
int exp_w,exp_h;
int exp_x,exp_y;
- int osd;
+ int osd_enabled;
double aspect;
int round;
unsigned char* fb_ptr;
int passthrough;
int first_slice;
+ struct osd_state *osd;
} const vf_priv_dflt = {
-1,-1,
-1,-1,
@@ -172,10 +173,10 @@ static void draw_osd(struct vf_instance* vf_,int w,int h){
remove_func_2(vf->priv->exp_x+w,vf->priv->exp_y,vf->priv->exp_w-w-vf->priv->exp_x,h);
} else {
// partial clear:
- vo_remove_text(vf->priv->exp_w,vf->priv->exp_h,remove_func);
+ osd_remove_text(vf->priv->osd, vf->priv->exp_w,vf->priv->exp_h,remove_func);
}
}
- osd_draw_text(vf->priv->exp_w,vf->priv->exp_h,draw_func, NULL);
+ osd_draw_text(vf->priv->osd, vf->priv->exp_w,vf->priv->exp_h,draw_func, NULL);
// save buffer pointer for double buffering detection - yes, i know it's
// ugly method, but note that codecs with DR support does the same...
if(vf->dmpi)
@@ -241,9 +242,9 @@ static int config(struct vf_instance* vf,
static void get_image(struct vf_instance* vf, mp_image_t *mpi){
// if(mpi->type==MP_IMGTYPE_IPB) return; // not yet working
#ifdef OSD_SUPPORT
- if(vf->priv->osd && (mpi->flags&MP_IMGFLAG_PRESERVE)){
+ if(vf->priv->osd_enabled && (mpi->flags&MP_IMGFLAG_PRESERVE)){
// check if we have to render osd!
- vo_update_osd(vf->priv->exp_w, vf->priv->exp_h);
+ osd_update(vf->priv->osd, vf->priv->exp_w, vf->priv->exp_h);
if(vo_osd_check_range_update(vf->priv->exp_x,vf->priv->exp_y,
vf->priv->exp_x+mpi->w,vf->priv->exp_y+mpi->h)) return;
}
@@ -368,7 +369,7 @@ static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){
if(!vf->dmpi) { mp_msg(MSGT_VFILTER, MSGL_WARN, MSGTR_MPCODECS_FunWhydowegetNULL); return 0; }
mpi->priv=NULL;
#ifdef OSD_SUPPORT
- if(vf->priv->osd) draw_osd(vf,mpi->w,mpi->h);
+ if(vf->priv->osd_enabled) draw_osd(vf,mpi->w,mpi->h);
#endif
// we've used DR, so we're ready...
if(!(mpi->flags&MP_IMGFLAG_PLANAR))
@@ -403,7 +404,7 @@ static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){
vf->dmpi->planes[1] = mpi->planes[1]; // passthrough rgb8 palette
}
#ifdef OSD_SUPPORT
- if(vf->priv->osd) draw_osd(vf,mpi->w,mpi->h);
+ if(vf->priv->osd_enabled) draw_osd(vf,mpi->w,mpi->h);
#endif
return vf_next_put_image(vf,vf->dmpi, pts);
}
@@ -413,8 +414,11 @@ static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){
static int control(struct vf_instance* vf, int request, void* data){
#ifdef OSD_SUPPORT
switch(request){
+ case VFCTRL_SET_OSD_OBJ:
+ vf->priv->osd = data;
+ break;
case VFCTRL_DRAW_OSD:
- if(vf->priv->osd) return CONTROL_TRUE;
+ if(vf->priv->osd_enabled) return CONTROL_TRUE;
}
#endif
return vf_next_control(vf,request,data);
@@ -437,7 +441,7 @@ static int open(vf_instance_t *vf, char* args){
vf->priv->exp_h,
vf->priv->exp_x,
vf->priv->exp_y,
- vf->priv->osd,
+ vf->priv->osd_enabled,
vf->priv->aspect,
vf->priv->round);
return 1;
@@ -449,7 +453,7 @@ static const m_option_t vf_opts_fields[] = {
{"h", ST_OFF(exp_h), CONF_TYPE_INT, 0, 0 ,0, NULL},
{"x", ST_OFF(exp_x), CONF_TYPE_INT, M_OPT_MIN, -1, 0, NULL},
{"y", ST_OFF(exp_y), CONF_TYPE_INT, M_OPT_MIN, -1, 0, NULL},
- {"osd", ST_OFF(osd), CONF_TYPE_FLAG, 0 , 0, 1, NULL},
+ {"osd", ST_OFF(osd_enabled), CONF_TYPE_FLAG, 0 , 0, 1, NULL},
{"aspect", ST_OFF(aspect), CONF_TYPE_DOUBLE, M_OPT_MIN, 0, 0, NULL},
{"round", ST_OFF(round), CONF_TYPE_INT, M_OPT_MIN, 1, 0, NULL},
{ NULL, NULL, 0, 0, 0, 0, NULL }
diff --git a/libmpcodecs/vf_vo.c b/libmpcodecs/vf_vo.c
index 9e1cba7076..ac249345ed 100644
--- a/libmpcodecs/vf_vo.c
+++ b/libmpcodecs/vf_vo.c
@@ -86,7 +86,7 @@ static int control(struct vf_instance* vf, int request, void* data)
}
case VFCTRL_DRAW_OSD:
if(!video_out->config_ok) return CONTROL_FALSE; // vo not configured?
- vo_draw_osd(video_out);
+ vo_draw_osd(video_out, data);
return CONTROL_TRUE;
case VFCTRL_FLIP_PAGE:
{
diff --git a/libvo/old_vo_wrapper.c b/libvo/old_vo_wrapper.c
index 825f6da0ee..57d1145f53 100644
--- a/libvo/old_vo_wrapper.c
+++ b/libvo/old_vo_wrapper.c
@@ -23,6 +23,7 @@
#include "sub.h"
struct vo *global_vo;
+struct osd_state *global_osd;
int old_vo_preinit(struct vo *vo, const char *arg)
{
@@ -59,8 +60,9 @@ int old_vo_draw_slice(struct vo *vo, uint8_t *src[], int stride[],
}
-void old_vo_draw_osd(struct vo *vo)
+void old_vo_draw_osd(struct vo *vo, struct osd_state *osd)
{
+ global_osd = osd;
vo->driver->old_functions->draw_osd();
}
@@ -94,6 +96,10 @@ static void draw_alpha_wrapper(void *ctx, int x0, int y0, int w, int h,
void vo_draw_text(int dxs,int dys,void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride))
{
- osd_draw_text(dxs, dys, draw_alpha_wrapper, draw_alpha);
+ osd_draw_text(global_osd, dxs, dys, draw_alpha_wrapper, draw_alpha);
}
+int vo_update_osd(int dxs, int dys)
+{
+ return osd_update(global_osd, dxs, dys);
+}
diff --git a/libvo/old_vo_wrapper.h b/libvo/old_vo_wrapper.h
index b81f065497..e7e98fdad6 100644
--- a/libvo/old_vo_wrapper.h
+++ b/libvo/old_vo_wrapper.h
@@ -5,6 +5,7 @@
#include "video_out.h"
extern struct vo *global_vo;
+extern struct osd_state *global_osd;
int old_vo_preinit(struct vo *vo, const char *);
int old_vo_config(struct vo *vo, uint32_t width, uint32_t height,
@@ -14,11 +15,12 @@ int old_vo_control(struct vo *vo, uint32_t request, void *data);
int old_vo_draw_frame(struct vo *vo, uint8_t *src[]);
int old_vo_draw_slice(struct vo *vo, uint8_t *src[], int stride[],
int w, int h, int x, int y);
-void old_vo_draw_osd(struct vo *vo);
+void old_vo_draw_osd(struct vo *vo, struct osd_state *osd);
void old_vo_flip_page(struct vo *vo);
void old_vo_check_events(struct vo *vo);
void old_vo_uninit(struct vo *vo);
void vo_draw_text(int dxs,int dys,void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride));
+int vo_update_osd(int dxs, int dys);
#endif
diff --git a/libvo/sub.c b/libvo/sub.c
index 7093a4e8f8..d3d52067d9 100644
--- a/libvo/sub.c
+++ b/libvo/sub.c
@@ -19,6 +19,7 @@
#include "osdep/timer.h"
#endif
+#include "talloc.h"
#include "mplayer.h"
#include "mp_msg.h"
#include "help_mp.h"
@@ -72,7 +73,6 @@ char * const sub_osd_names_short[] ={ "", "|>", "||", "[]", "<<" , ">>", "", "",
font_desc_t* vo_font=NULL;
font_desc_t* sub_font=NULL;
-unsigned char* vo_osd_text=NULL;
#ifdef HAVE_TV_TELETEXT
void* vo_osd_teletext_page=NULL;
int vo_osd_teletext_half = 0;
@@ -181,8 +181,10 @@ no_utf8:
return c;
}
-inline static void vo_update_text_osd(mp_osd_obj_t* obj,int dxs,int dys){
- const char *cp=vo_osd_text;
+inline static void vo_update_text_osd(struct osd_state *osd, mp_osd_obj_t* obj,
+ int dxs, int dys)
+{
+ const char *cp = osd->osd_text;
int x=20;
int h=0;
int font;
@@ -203,7 +205,7 @@ inline static void vo_update_text_osd(mp_osd_obj_t* obj,int dxs,int dys){
alloc_buf(obj);
- cp=vo_osd_text;
+ cp = osd->osd_text;
x = obj->x;
while (*cp){
uint16_t c=utf8_get_char(&cp);
@@ -1050,7 +1052,8 @@ static mp_osd_obj_t* new_osd_obj(int type){
return osd;
}
-void free_osd_list(void){
+void osd_free(struct osd_state *osd)
+{
mp_osd_obj_t* obj=vo_osd_list;
while(obj){
mp_osd_obj_t* next=obj->next;
@@ -1060,11 +1063,13 @@ void free_osd_list(void){
obj=next;
}
vo_osd_list=NULL;
+ talloc_free(osd);
}
#define FONT_LOAD_DEFER 6
-int vo_update_osd(int dxs,int dys){
+int osd_update(struct osd_state *osd, int dxs, int dys)
+{
mp_osd_obj_t* obj=vo_osd_list;
int chg=0;
#ifdef HAVE_FREETYPE
@@ -1142,8 +1147,8 @@ int vo_update_osd(int dxs,int dys){
obj->flags&=~OSDFLAG_VISIBLE;
break;
case OSDTYPE_OSD:
- if(vo_font && vo_osd_text && vo_osd_text[0]){
- vo_update_text_osd(obj,dxs,dys); // update bbox
+ if(vo_font && osd->osd_text[0]){
+ vo_update_text_osd(osd, obj, dxs, dys); // update bbox
obj->flags|=OSDFLAG_VISIBLE|OSDFLAG_CHANGED;
} else
obj->flags&=~OSDFLAG_VISIBLE;
@@ -1183,12 +1188,15 @@ int vo_update_osd(int dxs,int dys){
return chg;
}
-void vo_init_osd(void){
+struct osd_state *osd_create(void)
+{
+ struct osd_state *osd = talloc_ptrtype(NULL, osd);
+ *osd = (struct osd_state){
+ };
if(!draw_alpha_init_flag){
draw_alpha_init_flag=1;
vo_draw_alpha_init();
}
- if(vo_osd_list) free_osd_list();
// temp hack, should be moved to mplayer/mencoder later
new_osd_obj(OSDTYPE_OSD);
new_osd_obj(OSDTYPE_SUBTITLE);
@@ -1203,13 +1211,16 @@ void vo_init_osd(void){
#ifdef HAVE_FREETYPE
force_load_font = 1;
#endif
+ return osd;
}
int vo_osd_changed_flag=0;
-void vo_remove_text(int dxs,int dys,void (*remove)(int x0,int y0, int w,int h)){
+void osd_remove_text(struct osd_state *osd, int dxs, int dys,
+ void (*remove)(int x0, int y0, int w, int h))
+{
mp_osd_obj_t* obj=vo_osd_list;
- vo_update_osd(dxs,dys);
+ osd_update(osd, dxs, dys);
while(obj){
if(((obj->flags&OSDFLAG_CHANGED) || (obj->flags&OSDFLAG_VISIBLE)) &&
(obj->flags&OSDFLAG_OLD_BBOX)){
@@ -1225,10 +1236,14 @@ void vo_remove_text(int dxs,int dys,void (*remove)(int x0,int y0, int w,int h)){
}
}
-void osd_draw_text(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)
+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)
{
mp_osd_obj_t* obj=vo_osd_list;
- vo_update_osd(dxs,dys);
+ osd_update(osd, dxs, dys);
while(obj){
if(obj->flags&OSDFLAG_VISIBLE){
vo_osd_changed_flag=obj->flags&OSDFLAG_CHANGED; // temp hack
diff --git a/libvo/sub.h b/libvo/sub.h
index 50b55829ad..328af4d274 100644
--- a/libvo/sub.h
+++ b/libvo/sub.h
@@ -49,14 +49,15 @@ typedef struct mp_osd_obj_s {
unsigned char *bitmap_buffer;
} mp_osd_obj_t;
+struct osd_state {
+ unsigned char osd_text[64];
+};
#include "subreader.h"
extern sub_data* subdata; //currently used subtitles
extern subtitle* vo_sub;
-extern unsigned char* vo_osd_text;
-
extern void* vo_osd_teletext_page;
extern int vo_osd_teletext_half;
extern int vo_osd_teletext_mode;
@@ -108,14 +109,19 @@ extern float spu_gaussvar;
//extern void vo_draw_text_osd(int dxs,int dys,void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride));
//extern void vo_draw_text_progbar(int dxs,int dys,void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride));
//extern void vo_draw_text_sub(int dxs,int dys,void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride));
-extern void osd_draw_text(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);
-extern void vo_remove_text(int dxs,int dys,void (*remove)(int x0,int y0, int w,int h));
-
-void vo_init_osd(void);
-int vo_update_osd(int dxs,int dys);
+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);
+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);
+int osd_update(struct osd_state *osd, int dxs, int dys);
int vo_osd_changed(int new_value);
int vo_osd_check_range_update(int,int,int,int);
-void free_osd_list(void);
+void osd_free(struct osd_state *osd);
extern int vo_osd_changed_flag;
@@ -126,4 +132,9 @@ unsigned utf8_get_char(const char **str);
void osd_set_nav_box (uint16_t sx, uint16_t sy, uint16_t ex, uint16_t ey);
#endif
+
+#ifdef IS_OLD_VO
+#define vo_remove_text(...) osd_remove_text(global_osd, __VA_ARGS__)
+#endif
+
#endif /* MPLAYER_SUB_H */
diff --git a/libvo/video_out.c b/libvo/video_out.c
index 67a995c662..ba5051d4c4 100644
--- a/libvo/video_out.c
+++ b/libvo/video_out.c
@@ -256,11 +256,11 @@ int vo_draw_slice(struct vo *vo, uint8_t *src[], int stride[], int w, int h, int
return vo->driver->draw_slice(vo, src, stride, w, h, x, y);
}
-void vo_draw_osd(struct vo *vo)
+void vo_draw_osd(struct vo *vo, struct osd_state *osd)
{
if (!vo->config_ok)
return;
- vo->driver->draw_osd(vo);
+ vo->driver->draw_osd(vo, osd);
}
void vo_flip_page(struct vo *vo)
diff --git a/libvo/video_out.h b/libvo/video_out.h
index 174911c9d2..6a9908e19b 100644
--- a/libvo/video_out.h
+++ b/libvo/video_out.h
@@ -117,6 +117,7 @@ typedef struct vo_info_s
} vo_info_t;
struct vo;
+struct osd_state;
struct vo_driver {
// Driver uses new API
@@ -173,7 +174,7 @@ struct vo_driver {
/*
* Draws OSD to the screen buffer
*/
- void (*draw_osd)(struct vo *vo);
+ void (*draw_osd)(struct vo *vo, struct osd_state *osd);
/*
* Blit/Flip buffer to the screen. Must be called after each frame!
@@ -248,7 +249,7 @@ void list_video_out(void);
int vo_control(struct vo *vo, uint32_t request, void *data);
int vo_draw_frame(struct vo *vo, uint8_t *src[]);
int vo_draw_slice(struct vo *vo, uint8_t *src[], int stride[], int w, int h, int x, int y);
-void vo_draw_osd(struct vo *vo);
+void vo_draw_osd(struct vo *vo, struct osd_state *osd);
void vo_flip_page(struct vo *vo);
void vo_check_events(struct vo *vo);
void vo_destroy(struct vo *vo);
diff --git a/libvo/vo_aa.c b/libvo/vo_aa.c
index f297e01b71..ca547f0e87 100644
--- a/libvo/vo_aa.c
+++ b/libvo/vo_aa.c
@@ -86,6 +86,8 @@ static struct SwsContext *sws=NULL;
int aaopt_osdcolor = AA_SPECIAL;
int aaopt_subcolor = AA_SPECIAL;
+static unsigned char vo_osd_text[64];
+
void
resize(void){
/*
@@ -182,15 +184,10 @@ osdpercent(int duration, int deko, int min, int max, int val, const char * desc,
static void
printosdtext(void)
{
- if(osd_text_length > 0 && !vo_osd_text) {
- memset(c->textbuffer,' ',osd_text_length);
- memset(c->attrbuffer,0,osd_text_length);
- osd_text_length = 0;
- }
/*
* places the mplayer status osd
*/
- if (vo_osd_text && vo_osd_text[0] != 0) {
+ if (vo_osd_text[0] != 0) {
int len;
if(vo_osd_text[0] < 32) {
len = strlen(sub_osd_names_short[vo_osd_text[0]]) + strlen(vo_osd_text+1) + 2;
@@ -534,18 +531,18 @@ static void clear_alpha(int x0,int y0, int w,int h) {
static void
draw_osd(void){
- char * vo_osd_text_save;
+ char vo_osd_text_save;
int vo_osd_progbar_type_save;
printosdprogbar();
/* let vo_draw_text only write subtitle */
- vo_osd_text_save=vo_osd_text; /* we have to save the osd_text */
- vo_osd_text=NULL;
+ vo_osd_text_save = global_osd->osd_text[0];
+ global_osd->osd_text[0] = 0;
vo_osd_progbar_type_save=vo_osd_progbar_type;
vo_osd_progbar_type=-1;
vo_remove_text(aa_scrwidth(c), aa_scrheight(c),clear_alpha);
vo_draw_text(aa_scrwidth(c), aa_scrheight(c), draw_alpha);
- vo_osd_text=vo_osd_text_save;
+ global_osd->osd_text[0] = vo_osd_text_save;
vo_osd_progbar_type=vo_osd_progbar_type_save;
}
diff --git a/libvo/vo_xv.c b/libvo/vo_xv.c
index dca050975e..d63b2f732d 100644
--- a/libvo/vo_xv.c
+++ b/libvo/vo_xv.c
@@ -510,11 +510,11 @@ static void check_events(struct vo *vo)
}
}
-static void draw_osd(struct vo *vo)
+static void draw_osd(struct vo *vo, struct osd_state *osd)
{
struct xvctx *ctx = vo->priv;
- osd_draw_text(ctx->image_width -
+ osd_draw_text(osd, ctx->image_width -
ctx->image_width * vo->panscan_x / (vo->dwidth + vo->panscan_x),
ctx->image_height, ctx->draw_alpha_fnc, vo);
}
diff --git a/mencoder.c b/mencoder.c
index 6c157b7591..0ca429f9c2 100644
--- a/mencoder.c
+++ b/mencoder.c
@@ -94,6 +94,7 @@
#include "defaultopts.h"
MPOpts opts;
+struct osd_state *osd;
int vo_doublebuffering=0;
int vo_directrendering=0;
@@ -215,7 +216,7 @@ int vo_config(struct vo *vo, uint32_t width, uint32_t height,
int vo_control(struct vo *vo, uint32_t request, void *data) { abort(); }
int vo_draw_frame(struct vo *vo, uint8_t *src[]) { abort(); }
int vo_draw_slice(struct vo *vo, uint8_t *src[], int stride[], int w, int h, int x, int y) { abort(); }
-void vo_draw_osd(struct vo *vo) { abort(); }
+void vo_draw_osd(struct vo *vo, struct osd_state *osd) { abort(); }
void vo_flip_page(struct vo *vo) { abort(); }
void vo_check_events(struct vo *vo) { abort(); }
@@ -552,7 +553,7 @@ if (frameno_filename) {
}
#endif
- vo_init_osd();
+ osd = osd_create();
/* HACK, for some weird reason, push() has to be called twice,
otherwise options are not saved correctly */
@@ -1344,9 +1345,10 @@ case VCODEC_FRAMENO:
break;
default:
// decode_video will callback down to ve_*.c encoders, through the video filters
+ sh_video->vfilter->control(sh_video->vfilter, VFCTRL_SET_OSD_OBJ, osd);
{void *decoded_frame = decode_video(sh_video,frame_data.start,frame_data.in_size,
skip_flag>0 && (!sh_video->vfilter || ((vf_instance_t *)sh_video->vfilter)->control(sh_video->vfilter, VFCTRL_SKIP_NEXT_FRAME, 0) != CONTROL_TRUE), MP_NOPTS_VALUE);
- blit_frame = decoded_frame && filter_video(sh_video, decoded_frame, MP_NOPTS_VALUE);}
+ blit_frame = decoded_frame && filter_video(sh_video, decoded_frame, MP_NOPTS_VALUE, osd);}
if (sh_video->vf_initialized < 0) mencoder_exit(1, NULL);
@@ -1706,10 +1708,12 @@ static int slowseek(float end_pts, demux_stream_t *d_video, demux_stream_t *d_au
if (sh_video->pts >= end_pts) done = 1;
if (vfilter) {
+ sh_video->vfilter->control(sh_video->vfilter, VFCTRL_SET_OSD_OBJ,
+ osd);
int softskip = (vfilter->control(vfilter, VFCTRL_SKIP_NEXT_FRAME, 0) == CONTROL_TRUE);
void *decoded_frame = decode_video(sh_video, frame_data->start, frame_data->in_size, !softskip, MP_NOPTS_VALUE);
if (decoded_frame)
- filter_video(sh_video, decoded_frame, MP_NOPTS_VALUE);
+ filter_video(sh_video, decoded_frame, MP_NOPTS_VALUE, osd);
}
if (print_info) mp_msg(MSGT_MENCODER, MSGL_STATUS,
diff --git a/mp_core.h b/mp_core.h
index 4a667b56d7..bb2c6d9ca1 100644
--- a/mp_core.h
+++ b/mp_core.h
@@ -41,6 +41,7 @@ typedef struct MPContext {
struct vo_x11_state *x11_state;
struct mp_fifo *key_fifo;
struct input_ctx *input;
+ struct osd_state *osd;
int osd_show_percentage;
int osd_function;
const ao_functions_t *audio_out;
diff --git a/mplayer.c b/mplayer.c
index 5eed63293c..af782b2fac 100644
--- a/mplayer.c
+++ b/mplayer.c
@@ -676,7 +676,7 @@ void exit_player_with_rc(struct MPContext *mpctx, const char* how, int rc){
vo_font = NULL;
done_freetype();
#endif
- free_osd_list();
+ osd_free(mpctx->osd);
#ifdef USE_ASS
ass_library_done(ass_library);
@@ -1494,16 +1494,13 @@ void set_osd_bar(struct MPContext *mpctx, int type,const char* name,double min,d
static void update_osd_msg(struct MPContext *mpctx)
{
mp_osd_msg_t *msg;
- static char osd_text[64] = "";
- static char osd_text_timer[64];
-
- // we need some mem for vo_osd_text
- vo_osd_text = (unsigned char*)osd_text;
+ struct osd_state *osd = mpctx->osd;
+ char osd_text_timer[64];
// Look if we have a msg
if((msg = get_osd_msg(mpctx))) {
- if(strcmp(osd_text,msg->msg)) {
- strncpy((char*)osd_text, msg->msg, 63);
+ if (strcmp(osd->osd_text, msg->msg)) {
+ strncpy(osd->osd_text, msg->msg, 63);
if(mpctx->sh_video) vo_osd_changed(OSDTYPE_OSD); else
if(term_osd) mp_msg(MSGT_CPLAYER,MSGL_STATUS,"%s%s\n",term_osd_esc,msg->msg);
}
@@ -1542,16 +1539,16 @@ static void update_osd_msg(struct MPContext *mpctx)
if(mpctx->osd_show_percentage)
mpctx->osd_show_percentage--;
- if(strcmp(osd_text,osd_text_timer)) {
- strncpy(osd_text, osd_text_timer, 63);
+ if (strcmp(osd->osd_text, osd_text_timer)) {
+ strncpy(osd->osd_text, osd_text_timer, 63);
vo_osd_changed(OSDTYPE_OSD);
}
return;
}
// Clear the term osd line
- if(term_osd && osd_text[0]) {
- osd_text[0] = 0;
+ if (term_osd && osd->osd_text[0]) {
+ osd->osd_text[0] = 0;
printf("%s\n",term_osd_esc);
}
}
@@ -1753,7 +1750,8 @@ static int generate_video_frame(struct MPContext *mpctx)
update_teletext(sh_video, mpctx->demuxer, 0);
update_osd_msg(mpctx);
current_module = "filter video";
- if (filter_video(sh_video, decoded_frame, sh_video->pts))
+ if (filter_video(sh_video, decoded_frame, sh_video->pts,
+ mpctx->osd))
break;
} else if (drop_frame)
return -1;
@@ -2248,6 +2246,8 @@ static double update_video(struct MPContext *mpctx, int *blit_frame)
//-------------------- Decode a frame: -----------------------
double frame_time;
*blit_frame = 0; // Don't blit if we hit EOF
+ sh_video->vfilter->control(sh_video->vfilter, VFCTRL_SET_OSD_OBJ,
+ mpctx->osd); // hack for vf_expand
if (!opts->correct_pts) {
unsigned char* start=NULL;
void *decoded_frame = NULL;
@@ -2294,7 +2294,8 @@ static double update_video(struct MPContext *mpctx, int *blit_frame)
#endif
current_module = "filter_video";
*blit_frame = (decoded_frame && filter_video(sh_video, decoded_frame,
- sh_video->pts));
+ sh_video->pts,
+ mpctx->osd));
}
else {
int res = generate_video_frame(mpctx);
@@ -2832,7 +2833,7 @@ if(!codecs_file || !parse_codec_cfg(codecs_file)){
}
#endif
- vo_init_osd();
+ mpctx->osd = osd_create();
#ifdef USE_ASS
ass_library = ass_init();