From a232f564d3f271277135276281c03cca7807ef16 Mon Sep 17 00:00:00 2001 From: Uoti Urpala Date: Tue, 24 Jun 2008 01:53:58 +0300 Subject: Create a context struct for OSD state This commit creates the struct and passes it to some functions that needs to access OSD state but does not yet move much data from globals to it. vf_expand accesses the OSD state for rendering purposes outside of the normal OSD draw time. The way this currently works is suboptimal, but I did not attempt to clean it up now. To keep things working the same way vf_expand needs to know the address of the state object to be able to access the data even in the functions that should normally not need it. For that purpose this commit adds a VFCTRL to tell vf_expand the address of the object. --- mplayer.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) (limited to 'mplayer.c') 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(); -- cgit v1.2.3