[MPlayer-dev-eng] [PATCH] VFCTRL_PAUSE_UPDATE
Reimar Döffinger
Reimar.Doeffinger at stud.uni-karlsruhe.de
Thu Sep 15 18:56:05 CEST 2005
Hi,
On Thu, Sep 15, 2005 at 05:43:44PM +0200, Reimar Döffinger wrote:
> this is the part from the vf_overlay patch that adds the
> VFCTRL_PAUSE_UPDATE control that helps ensure a certain framerate.
> Please review and comment.
> I think it might make sense to update time_frame when it is called
> before sleeping. Do you agree? And if yes, how should this be done?
> Would GetRelativeTime be the right function?
Actually I'd like to suggest the attached patch instead. I didn't test
it though and vf_overlay must be changed a bit to work with it, but
I prefer not to pass the video_out struct through all those filters...
The name changed to VFCTRL_PERIODIC_UPDATE, feel free to suggest
something better.
Greetings,
Reimar Döffinger
-------------- next part --------------
Index: libmpcodecs/vf.h
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/vf.h,v
retrieving revision 1.28
diff -u -r1.28 vf.h
--- libmpcodecs/vf.h 11 Sep 2005 06:41:04 -0000 1.28
+++ libmpcodecs/vf.h 15 Sep 2005 16:55:46 -0000
@@ -75,6 +75,7 @@
#define VFCTRL_SKIP_NEXT_FRAME 12 /* For encoding - drop the next frame that passes thru */
#define VFCTRL_FLUSH_FRAMES 13 /* For encoding - flush delayed frames */
#define VFCTRL_SCREENSHOT 14 /* Make a screenshot */
+#define VFCTRL_PERIODIC_UPDATE 15 /* Called whenever MPlayer is idle */
#include "vfcap.h"
Index: mplayer.c
===================================================================
RCS file: /cvsroot/mplayer/main/mplayer.c,v
retrieving revision 1.871
diff -u -r1.871 mplayer.c
--- mplayer.c 15 Sep 2005 03:08:35 -0000 1.871
+++ mplayer.c 15 Sep 2005 16:55:59 -0000
@@ -977,6 +977,29 @@
return result;
}
+/**
+ * \brief send a VFCTRL_PERIODIC_UPDATE through the filter chain
+ * \param vf first video filter to receive the control
+ * \param vo needed to flip if requested
+ * \param time_avail time available, might decide not to send the
+ * control if this is too small
+ * \return 1 if the event was consumed or not sent, 0 otherwise
+ *
+ * When the filter chain returns CONTROL_TRUE, a flip_page
+ * will be performed, a value < 0 means it was not consumed,
+ * causing less events to be produced in the future
+ */
+static int periodic_update(vf_instance_t *vf, vo_functions_t *vo,
+ float time_avail) {
+ int res;
+ if (!vf) return 0;
+ if (time_avail < 0.01) return 1;
+ res = vf->control(vf, VFCTRL_PERIODIC_UPDATE, &time_avail);
+ if (res == CONTROL_OK && vo_config_count)
+ vo->flip_page();
+ return res >= 0;
+}
+
#ifdef USE_SUB
/**
* \brief Log the currently displayed subtitle to a file
@@ -2542,6 +2565,8 @@
// flag 256 means: libvo driver does its timing (dvb card)
if(time_frame>0.001 && !(vo_flags&256)){
+ periodic_update(sh_video->vfilter, video_out, time_frame);
+ time_frame-=GetRelativeTime();
#ifdef HAVE_RTC
if(rtc_fd>=0){
// -------- RTC -----------
@@ -2551,6 +2576,8 @@
if (read (rtc_fd, &rtc_ts, sizeof(rtc_ts)) <= 0)
mp_msg(MSGT_CPLAYER, MSGL_ERR, MSGTR_LinuxRTCReadError, strerror(errno));
time_frame-=GetRelativeTime();
+ periodic_update(sh_video->vfilter, video_out, time_frame);
+ time_frame-=GetRelativeTime();
}
} else
#endif
@@ -2560,6 +2587,8 @@
while(time_frame>0.005) {
usec_sleep(1000000*time_frame);
time_frame-=GetRelativeTime();
+ periodic_update(sh_video->vfilter, video_out, time_frame);
+ time_frame-=GetRelativeTime();
}
}
#else
@@ -2573,6 +2602,8 @@
else
usec_sleep(1000000*(time_frame-0.020));
time_frame-=GetRelativeTime();
+ periodic_update(sh_video->vfilter, video_out, time_frame);
+ time_frame-=GetRelativeTime();
}
if(softsleep){
current_module="sleep_soft";
@@ -2764,7 +2795,7 @@
if (audio_out && sh_audio)
audio_out->pause(); // pause audio, keep data if possible
- while( (cmd = mp_input_get_cmd(20,1,1)) == NULL) {
+ while( (cmd = mp_input_get_cmd(3,1,1)) == NULL) {
if(sh_video && video_out && vo_config_count) video_out->check_events();
#ifdef HAVE_NEW_GUI
if(use_gui){
@@ -2777,6 +2808,9 @@
if(vf_menu)
vf_menu_pause_update(vf_menu);
#endif
+ if (sh_video && periodic_update(sh_video->vfilter, video_out, 1))
+ usec_sleep(1000);
+ else
usec_sleep(20000);
}
if (cmd && cmd->id == MP_CMD_PAUSE) {
More information about the MPlayer-dev-eng
mailing list