[MPlayer-dev-eng] [PATCH] framedrop for correct-pts

Reimar Döffinger Reimar.Doeffinger at stud.uni-karlsruhe.de
Sun Feb 17 11:38:17 CET 2008


Hello,
while the semantics of the framedrop behaviour are not as clean with
-correct-pts, a solution that at least works is not difficult.
Since it is at least an improvement: ok to apply?

Greetings,
Reimar Döffinger
-------------- next part --------------
Index: mplayer.c
===================================================================
--- mplayer.c	(revision 26014)
+++ mplayer.c	(working copy)
@@ -1713,6 +1720,27 @@
 	audio_out->get_delay();
 }
 
+static int check_framedrop(double frame_time) {
+	// check for frame-drop:
+	current_module = "check_framedrop";
+	if (mpctx->sh_audio && !mpctx->d_audio->eof) {
+	    static int dropped_frames;
+	    float delay = playback_speed*mpctx->audio_out->get_delay();
+	    float d = delay-mpctx->delay;
+	    ++total_frame_cnt;
+	    // we should avoid dropping too many frames in sequence unless we
+	    // are too late. and we allow 100ms A-V delay here:
+	    if (d < -dropped_frames*frame_time-0.100 &&
+				mpctx->osd_function != OSD_PAUSE) {
+		++drop_frame_cnt;
+		++dropped_frames;
+		return frame_dropping;
+	    } else
+		dropped_frames = 0;
+	}
+	return 0;
+}
+
 static int generate_video_frame(sh_video_t *sh_video, demux_stream_t *d_video)
 {
     unsigned char *start;
@@ -1721,6 +1749,7 @@
     double pts;
 
     while (1) {
+	int drop_frame = check_framedrop(sh_video->frametime);
 	void *decoded_frame;
 	current_module = "decode video";
 	// XXX Time used in this call is not counted in any performance
@@ -1738,7 +1767,7 @@
 	if (in_size > max_framesize)
 	    max_framesize = in_size;
 	current_module = "decode video";
-	decoded_frame = decode_video(sh_video, start, in_size, 0, pts);
+	decoded_frame = decode_video(sh_video, start, in_size, drop_frame, pts);
 	if (decoded_frame) {
 	    update_subtitles(sh_video, mpctx->d_sub, 0);
 	    update_teletext(sh_video, mpctx->demuxer, 0);
@@ -2258,23 +2287,7 @@
 	    mpctx->delay -= frame_time;
 	// video_read_frame can change fps (e.g. for ASF video)
 	vo_fps = sh_video->fps;
-	// check for frame-drop:
-	current_module = "check_framedrop";
-	if (mpctx->sh_audio && !mpctx->d_audio->eof) {
-	    static int dropped_frames;
-	    float delay = playback_speed*mpctx->audio_out->get_delay();
-	    float d = delay-mpctx->delay;
-	    // we should avoid dropping too many frames in sequence unless we
-	    // are too late. and we allow 100ms A-V delay here:
-	    if (d < -dropped_frames*frame_time-0.100 &&
-				mpctx->osd_function != OSD_PAUSE) {
-		drop_frame = frame_dropping;
-		++drop_frame_cnt;
-		++dropped_frames;
-	    } else
-		drop_frame = dropped_frames = 0;
-	    ++total_frame_cnt;
-	}
+	drop_frame = check_framedrop(frame_time);
 	update_subtitles(sh_video, mpctx->d_sub, 0);
 	update_teletext(sh_video, mpctx->demuxer, 0);
 	update_osd_msg();


More information about the MPlayer-dev-eng mailing list