[MPlayer-dev-eng] [PATCH] ffw-av - interactive fastforward/slow with audio speed adjust (1st draft)

attila attila at kinali.ch
Wed Jul 21 14:25:25 CEST 2004


Hi,

On Tue, Jul 20, 2004 at 06:45:10PM +0200, Shachar Raindel wrote:
> Can you point to where the patch is - I have a similar patched version
> sitting on my HD, and maybe this patch could give me some insights to
> improve it and make it clean enough to be applied. BTW, is there any
> documentation about the A-V syncro. stuff in mplayer, or is it only
> the source and my wild guesses about what it should do?

Here it comes.
The original Mail is from the 10th september 2003, plese
refere too it for further details.

BTW: Please learn to quote

			Attila Kinali

-------------- next part --------------
mplayer_ffw-av.patch - interactive fastforward and slowforward

patch author: Steven Mueller <diffusor at ugcs.caltech.edu>
Last Modified: September 09, 2003 13:22 Tuesday -0700

Licencse:
This modification to mplayer is released under the same terms as
mplayer's license, of course.  See main/LICENSE in the mplayer cvs
tree.


Index: mplayer.c
===================================================================
RCS file: /cvsroot/mplayer/main/mplayer.c,v
retrieving revision 1.725
diff -u -r1.725 mplayer.c
--- mplayer.c	29 Aug 2003 21:41:03 -0000	1.725
+++ mplayer.c	9 Sep 2003 20:01:14 -0000
@@ -703,6 +703,29 @@
 #include <SDL.h>
 #endif
 
+// reinit to get the audio scaled to a new playback_speed
+void reinit_audio_speed(sh_audio_t *sh_audio, ao_functions_t *audio_out, ao_data_t *ao_data)
+{
+    if(sh_audio) {
+	audio_out->reset(); // stop audio, throwing away buffered data
+	audio_out->uninit();
+	ao_data->samplerate=force_srate?force_srate:sh_audio->samplerate*playback_speed;
+	audio_out->init(ao_data->samplerate,
+		audio_output_channels?audio_output_channels:ao_data->channels,
+		audio_output_format?audio_output_format:ao_data->format,0);
+	//	  rel_seek_secs-= 0.01;  // causes bad behavior on media with keyframes
+	resync_audio_stream(sh_audio);
+    }
+}
+
+// return the closest acceptable speed to that requested
+float bound_play_speed(float requested_speed)
+{
+    if( requested_speed < 0.01 ) return 0.01;
+    else if( requested_speed > 100.0 ) return 100.0;
+    else return requested_speed;
+}
+
 
 int main(int argc,char* argv[]){
 
@@ -2312,7 +2335,7 @@
         else
           max_pts_correction=sh_video->frametime*0.10; // +-10% of time
 	if(!frame_time_remaining){ sh_audio->delay+=x; c_total+=x;} // correction
-        if(!quiet) mp_msg(MSGT_AVSYNC,MSGL_STATUS,"A:%6.1f V:%6.1f A-V:%7.3f ct:%7.3f  %3d/%3d  %2d%% %2d%% %4.1f%% %d %d %d%%\r",
+        if(!quiet) mp_msg(MSGT_AVSYNC,MSGL_STATUS,"A:%6.1f V:%6.1f A-V:%7.3f ct:%7.3f  %3d/%3d  %2d%% %2d%% %4.1f%% %d %d %d%% %6.2fx    \r",
 	  a_pts-audio_delay-delay,v_pts,AV_delay,c_total,
           (int)sh_video->num_frames,(int)sh_video->num_frames_decoded,
           (sh_video->timer>0.5)?(int)(100.0*video_time_usage*playback_speed/(double)sh_video->timer):0,
@@ -2321,6 +2344,7 @@
           ,drop_frame_cnt
 	  ,output_quality
 	  ,cache_fill_status
+	  ,playback_speed
         );
         fflush(stdout);
       }
@@ -2509,6 +2533,21 @@
       audio_delay += v;
       osd_show_av_delay = 9;
       if(sh_audio) sh_audio->delay+= v;
+    } break;
+    case MP_CMD_SPEED_INCR : {
+      float v = cmd->args[0].v.f;
+      playback_speed = bound_play_speed(playback_speed + v);
+      reinit_audio_speed(sh_audio, audio_out, &ao_data);
+    } break;
+    case MP_CMD_SPEED_MULT : {
+      float v = cmd->args[0].v.f;
+      playback_speed = bound_play_speed(playback_speed * v);
+      reinit_audio_speed(sh_audio, audio_out, &ao_data);
+    } break;
+    case MP_CMD_SPEED_SET : {
+      float v = cmd->args[0].v.f;
+      playback_speed = bound_play_speed(v);
+      reinit_audio_speed(sh_audio, audio_out, &ao_data);
     } break;
     case MP_CMD_PAUSE : {
       osd_function=OSD_PAUSE;
Index: etc/input.conf
===================================================================
RCS file: /cvsroot/mplayer/main/etc/input.conf,v
retrieving revision 1.10
diff -u -r1.10 input.conf
--- etc/input.conf	5 May 2003 03:13:43 -0000	1.10
+++ etc/input.conf	9 Sep 2003 20:01:17 -0000
@@ -15,6 +15,11 @@
 PGDWN seek -600
 - audio_delay 0.100
 + audio_delay -0.100
+[ speed_mult 0.9091	# scale playback speed
+] speed_mult 1.1
+{ speed_mult 0.5
+} speed_mult 2.0
+BS speed_set 1.0	# reset speed to normal
 q quit
 ESC quit
 ENTER pt_step 1 1
Index: input/input.c
===================================================================
RCS file: /cvsroot/mplayer/main/input/input.c,v
retrieving revision 1.84
diff -u -r1.84 input.c
--- input/input.c	2 Sep 2003 17:44:38 -0000	1.84
+++ input/input.c	9 Sep 2003 20:01:21 -0000
@@ -55,6 +55,9 @@
   { MP_CMD_EDL_MARK, "edl_mark", 0, { {-1,{0}} } },
 #endif
   { MP_CMD_AUDIO_DELAY, "audio_delay", 1, { {MP_CMD_ARG_FLOAT,{0}}, {-1,{0}} } },
+  { MP_CMD_SPEED_INCR, "speed_incr", 1, { {MP_CMD_ARG_FLOAT,{0}}, {-1,{0}} } },
+  { MP_CMD_SPEED_MULT, "speed_mult", 1, { {MP_CMD_ARG_FLOAT,{0}}, {-1,{0}} } },
+  { MP_CMD_SPEED_SET, "speed_set", 1, { {MP_CMD_ARG_FLOAT,{0}}, {-1,{0}} } },
   { MP_CMD_QUIT, "quit", 0, { {-1,{0}} } },
   { MP_CMD_PAUSE, "pause", 0, { {-1,{0}} } },
   { MP_CMD_GRAB_FRAMES, "grab_frames",0, { {-1,{0}} }  },
@@ -258,6 +261,11 @@
   { { KEY_PAGE_DOWN, 0 }, "seek -600" },
   { { '-', 0 }, "audio_delay 0.100" },
   { { '+', 0 }, "audio_delay -0.100" },
+  { { '[', 0 }, "speed_mult 0.9091" },
+  { { ']', 0 }, "speed_mult 1.1" },
+  { { '{', 0 }, "speed_mult 0.5" },
+  { { '}', 0 }, "speed_mult 2.0" },
+  { { KEY_BACKSPACE, 0 }, "speed_set 1.0" },
   { { 'q', 0 }, "quit" },
   { { KEY_ESC, 0 }, "quit" },
 #ifndef HAVE_NEW_GUI
Index: input/input.h
===================================================================
RCS file: /cvsroot/mplayer/main/input/input.h,v
retrieving revision 1.36
diff -u -r1.36 input.h
--- input/input.h	12 Aug 2003 13:22:35 -0000	1.36
+++ input/input.h	9 Sep 2003 20:01:21 -0000
@@ -50,6 +50,11 @@
 #define MP_CMD_TV_SET_HUE 46
 #define MP_CMD_TV_SET_SATURATION 47
 
+/* Speed mod commands */
+#define MP_CMD_SPEED_INCR 48
+#define MP_CMD_SPEED_MULT 49
+#define MP_CMD_SPEED_SET 50
+
 #define MP_CMD_GUI_EVENTS       5000
 #define MP_CMD_GUI_LOADFILE     5001
 #define MP_CMD_GUI_LOADSUBTITLE 5002
Index: libvo/wskeys.h
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/wskeys.h,v
retrieving revision 1.6
diff -u -r1.6 wskeys.h
--- libvo/wskeys.h	9 Apr 2003 17:05:35 -0000	1.6
+++ libvo/wskeys.h	9 Sep 2003 20:01:27 -0000
@@ -4,6 +4,8 @@
 
 #define wsosbrackets '['
 #define wscsbrackets ']'
+#define wsocbraces   '{'
+#define wsccbraces   '}'
 
 #define wsq 'q'
 #define wsa 'a'
Index: libvo/x11_common.c
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/x11_common.c,v
retrieving revision 1.155
diff -u -r1.155 x11_common.c
--- libvo/x11_common.c	2 Sep 2003 14:39:02 -0000	1.155
+++ libvo/x11_common.c	9 Sep 2003 20:01:32 -0000
@@ -492,6 +492,10 @@
    case wsDiv:       mplayer_put_key('/'); break;
    case wsLess:      mplayer_put_key('<'); break;
    case wsMore:      mplayer_put_key('>'); break;
+   case wsosbrackets: mplayer_put_key('['); break;
+   case wscsbrackets: mplayer_put_key(']'); break;
+   case wsocbraces:  mplayer_put_key('{'); break;
+   case wsccbraces:  mplayer_put_key('}'); break;
    case wsGray0:     mplayer_put_key(KEY_KP0); break;
    case wsGrayEnd:
    case wsGray1:     mplayer_put_key(KEY_KP1); break;


More information about the MPlayer-dev-eng mailing list