[MPlayer-dev-eng] [PATCH] clean/update subtitles on seek

Reimar Döffinger Reimar.Doeffinger at stud.uni-karlsruhe.de
Thu Feb 8 13:19:30 CET 2007


Hello,
does attached patch look good to you? It works fine for me.

Greetings,
Reimar Döffinger
-------------- next part --------------
Index: mplayer.c
===================================================================
--- mplayer.c	(revision 22173)
+++ mplayer.c	(working copy)
@@ -418,6 +419,7 @@
 int use_filedir_conf;
 
 static unsigned int inited_flags=0;
+static void update_subtitles(int reset);
 #define INITED_VO 1
 #define INITED_AO 2
 #define INITED_GUI 4
@@ -2364,14 +2366,12 @@
 #ifdef USE_DVDREAD
             if (vo_spudec && stream->type == STREAMTYPE_DVD) {
                 d_dvdsub->id = dvdsub_id;
-                spudec_reset(vo_spudec);
             }
 #endif
 
 #ifdef USE_DVDNAV
             if (vo_spudec && stream->type == STREAMTYPE_DVDNAV) {
                 d_dvdsub->id = dvdsub_id;
-                spudec_reset(vo_spudec);
             }
 #endif
             if (stream->type != STREAMTYPE_DVD && stream->type != STREAMTYPE_DVDNAV) {
@@ -2397,17 +2397,14 @@
 #endif
             }
         }
-    } else { // off
-        vo_osd_changed(OSDTYPE_SUBTITLE);
-        if(vo_spudec) vo_osd_changed(OSDTYPE_SPU);
     }
 #ifdef USE_DVDREAD
     if (vo_spudec && (stream->type == STREAMTYPE_DVD || stream->type == STREAMTYPE_DVDNAV) && dvdsub_id < 0 && reset_spu) {
         dvdsub_id = -2;
         d_dvdsub->id = dvdsub_id;
-        spudec_reset(vo_spudec);
     }
 #endif
+    update_subtitles(1);
 
     return M_PROPERTY_OK;
 }
@@ -2894,16 +2891,28 @@
 	audio_out->get_delay();
 }
 
-static void update_subtitles(void)
+static void update_subtitles(int reset)
 {
     unsigned char *packet=NULL;
     int len;
     char type = d_dvdsub->sh ? ((sh_sub_t *)d_dvdsub->sh)->type : 'v';
+    static subtitle subs;
     if (type == 'a')
 #ifdef USE_ASS
       if (!ass_enabled)
 #endif
       type = 't';
+    if (reset) {
+	sub_clear_text(&subs, MP_NOPTS_VALUE);
+	if (vo_sub) {
+	    vo_sub = NULL;
+	    vo_osd_changed(OSDTYPE_SUBTITLE);
+	}
+	if (vo_spudec) {
+	    spudec_reset(vo_spudec);
+	    vo_osd_changed(OSDTYPE_SPU);
+	}
+    }
     // find sub
     if (subdata) {
 	double pts = sh_video->pts;
@@ -2964,7 +2973,6 @@
 	if (spudec_changed(vo_spudec))
 	    vo_osd_changed(OSDTYPE_SPU);
     } else if (dvdsub_id >= 0 && type == 't') {
-	static subtitle subs;
 	double curpts = sh_video->pts + sub_delay;
 	double endpts;
 	vo_sub = &subs;
@@ -3032,7 +3040,7 @@
 	current_module = "decode video";
 	decoded_frame = decode_video(sh_video, start, in_size, 0, pts);
 	if (decoded_frame) {
-	    update_subtitles();
+	    update_subtitles(0);
 	    update_osd_msg();
 	    current_module = "filter video";
 	    if (filter_video(sh_video, decoded_frame, sh_video->pts))
@@ -3462,7 +3492,7 @@
 		drop_frame = dropped_frames = 0;
 	    ++total_frame_cnt;
 	}
-	update_subtitles();
+	update_subtitles(0);
 	update_osd_msg();
 	current_module = "decode_video";
 	decoded_frame = decode_video(sh_video, start, in_size, drop_frame,
@@ -5629,7 +5659,7 @@
 	audio_time_usage=0; video_time_usage=0; vout_time_usage=0;
 	drop_frame_cnt=0;
 
-        if(vo_spudec) spudec_reset(vo_spudec);
+        update_subtitles(1);
       }
   }
 /*


More information about the MPlayer-dev-eng mailing list