[MPlayer-cvslog] r29710 - in trunk: command.c mencoder.c mpcommon.c mpcommon.h mplayer.c

reimar subversion at mplayerhq.hu
Wed Sep 23 23:21:59 CEST 2009


Author: reimar
Date: Wed Sep 23 23:21:58 2009
New Revision: 29710

Log:
Make update_subtitles work without sh_video for text subtitles.
This fixes a crash with e.g. auto-enabled subtitles and -novideo due to
command.c calling update_subtitles even without video and is a step
toward subtitle support for audio-only files.

Modified:
   trunk/command.c
   trunk/mencoder.c
   trunk/mpcommon.c
   trunk/mpcommon.h
   trunk/mplayer.c

Modified: trunk/command.c
==============================================================================
--- trunk/command.c	Wed Sep 23 21:21:38 2009	(r29709)
+++ trunk/command.c	Wed Sep 23 23:21:58 2009	(r29710)
@@ -1314,6 +1314,7 @@ static int mp_property_sub(m_option_t * 
     demux_stream_t *const d_sub = mpctx->d_sub;
     const int global_sub_size = mpctx->global_sub_size;
     int source = -1, reset_spu = 0;
+    double pts = 0;
     char *sub_name;
 
     if (global_sub_size <= 0)
@@ -1500,7 +1501,11 @@ static int mp_property_sub(m_option_t * 
 	d_sub->id = dvdsub_id;
     }
 #endif
-    update_subtitles(mpctx->sh_video, d_sub, 1);
+    if (mpctx->sh_audio)
+        pts = mpctx->sh_audio->pts;
+    if (mpctx->sh_video)
+        pts = mpctx->sh_video->pts;
+    update_subtitles(mpctx->sh_video, pts, d_sub, 1);
 
     return M_PROPERTY_OK;
 }

Modified: trunk/mencoder.c
==============================================================================
--- trunk/mencoder.c	Wed Sep 23 21:21:38 2009	(r29709)
+++ trunk/mencoder.c	Wed Sep 23 23:21:58 2009	(r29710)
@@ -1454,7 +1454,7 @@ if(sh_audio && !demuxer2){
  }
  else
 #endif
-    update_subtitles(sh_video, d_dvdsub, 0);
+    update_subtitles(sh_video, sh_video->pts, d_dvdsub, 0);
 
  frame_data = (s_frame_data){ .start = NULL, .in_size = 0, .frame_time = 0., .already_read = 0 };
 

Modified: trunk/mpcommon.c
==============================================================================
--- trunk/mpcommon.c	Wed Sep 23 21:21:38 2009	(r29709)
+++ trunk/mpcommon.c	Wed Sep 23 23:21:58 2009	(r29710)
@@ -66,13 +66,12 @@ if (HAVE_CMOV)
 }
 
 
-void update_subtitles(sh_video_t *sh_video, demux_stream_t *d_dvdsub, int reset)
+void update_subtitles(sh_video_t *sh_video, double refpts, demux_stream_t *d_dvdsub, int reset)
 {
     unsigned char *packet=NULL;
     int len;
     char type = d_dvdsub->sh ? ((sh_sub_t *)d_dvdsub->sh)->type : 'v';
     static subtitle subs;
-    double refpts = sh_video->pts;
     if (reset) {
         sub_clear_text(&subs, MP_NOPTS_VALUE);
         if (vo_sub) {
@@ -86,7 +85,7 @@ void update_subtitles(sh_video_t *sh_vid
     }
     // find sub
     if (subdata) {
-        if (sub_fps==0) sub_fps = sh_video->fps;
+        if (sub_fps==0) sub_fps = sh_video ? sh_video->fps : 25;
         current_module = "find_sub";
         if (refpts > sub_last_pts || refpts < sub_last_pts-1.0) {
             find_sub(subdata, (refpts+sub_delay) *

Modified: trunk/mpcommon.h
==============================================================================
--- trunk/mpcommon.h	Wed Sep 23 21:21:38 2009	(r29709)
+++ trunk/mpcommon.h	Wed Sep 23 23:21:58 2009	(r29710)
@@ -10,7 +10,7 @@ extern struct ass_track_s *ass_track;
 extern subtitle *vo_sub_last;
 
 void print_version(const char* name);
-void update_subtitles(sh_video_t *sh_video, demux_stream_t *d_dvdsub, int reset);
+void update_subtitles(sh_video_t *sh_video, double pts, demux_stream_t *d_dvdsub, int reset);
 void update_teletext(sh_video_t *sh_video, demuxer_t *demuxer, int reset);
 int select_audio(demuxer_t* demuxer, int audio_id, char* audio_lang);
 

Modified: trunk/mplayer.c
==============================================================================
--- trunk/mplayer.c	Wed Sep 23 21:21:38 2009	(r29709)
+++ trunk/mplayer.c	Wed Sep 23 23:21:58 2009	(r29710)
@@ -1767,7 +1767,7 @@ static int generate_video_frame(sh_video
 	current_module = "decode video";
 	decoded_frame = decode_video(sh_video, start, in_size, drop_frame, pts);
 	if (decoded_frame) {
-	    update_subtitles(sh_video, mpctx->d_sub, 0);
+	    update_subtitles(sh_video, sh_video->pts, mpctx->d_sub, 0);
 	    update_teletext(sh_video, mpctx->demuxer, 0);
 	    update_osd_msg();
 	    current_module = "filter video";
@@ -2290,7 +2290,7 @@ static double update_video(int *blit_fra
 	// video_read_frame can change fps (e.g. for ASF video)
 	vo_fps = sh_video->fps;
 	drop_frame = check_framedrop(frame_time);
-	update_subtitles(sh_video, mpctx->d_sub, 0);
+	update_subtitles(sh_video, sh_video->pts, mpctx->d_sub, 0);
 	update_teletext(sh_video, mpctx->demuxer, 0);
 	update_osd_msg();
 	current_module = "decode_video";
@@ -2483,7 +2483,7 @@ static int seek(MPContext *mpctx, double
 	// (which is used by at least vobsub and edl code below) may
 	// be completely wrong (probably 0).
 	mpctx->sh_video->pts = mpctx->d_video->pts;
-	update_subtitles(mpctx->sh_video, mpctx->d_sub, 1);
+	update_subtitles(mpctx->sh_video, mpctx->sh_video->pts, mpctx->d_sub, 1);
 	update_teletext(mpctx->sh_video, mpctx->demuxer, 1);
     }
 


More information about the MPlayer-cvslog mailing list