changeset 4754:ad892563d9c4

Added VOCTRL_PAUSE and VOCTRL_RESUME Fixed playback bug in vo_dxr3 which would cause syncloss when playing ntsc movies on pal and vice versa (this does not affect mpeg playback as we still don't know how to set the internal fps registers)
author mswitch
date Mon, 18 Feb 2002 17:34:20 +0000
parents f3562b5411f9
children 67c33b0fb847
files libvo/video_out.h libvo/vo_dxr3.c mplayer.c
diffstat 3 files changed, 43 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/libvo/video_out.h	Mon Feb 18 16:50:16 2002 +0000
+++ b/libvo/video_out.h	Mon Feb 18 17:34:20 2002 +0000
@@ -21,7 +21,7 @@
 #define VOCTRL_QUERY_VAA 1
 /* takes a pointer to uint32_t fourcc */
 #define VOCTRL_QUERY_FORMAT 2
-/* signal a device reset (seek/pause) */
+/* signal a device reset seek */
 #define VOCTRL_RESET 3
 /* true if vo driver can use GUI created windows */
 #define VOCTRL_GUISUPPORT 4
@@ -29,6 +29,10 @@
 #define VOCTRL_FULLSCREEN 5
 /* user wants to have screen shot. (currently without args)*/
 #define VOCTRL_SCREENSHOT 6
+/* signal a device pause */
+#define VOCTRL_PAUSE 7
+/* start/resume playback */
+#define VOCTRL_RESUME 8
 
 #define VO_TRUE		1
 #define VO_FALSE	0
--- a/libvo/vo_dxr3.c	Mon Feb 18 16:50:16 2002 +0000
+++ b/libvo/vo_dxr3.c	Mon Feb 18 17:34:20 2002 +0000
@@ -74,10 +74,9 @@
 static AVCodec *avc_codec = NULL;
 static AVCodecContext *avc_context = NULL;
 static AVPicture avc_picture;
-char *picture_buf = NULL;
-char *avc_outbuf = NULL;
 int avc_outbuf_size = 100000;
 #endif
+char *picture_buf = NULL;
 
 #ifdef HAVE_MMX
 #include "mmx.h"
@@ -104,6 +103,8 @@
 
 /* Static variable used in ioctl's */
 static int ioval = 0;
+static int ptsdiff = 0;
+static int writesize = 0;
 
 static vo_info_t vo_info = 
 {
@@ -117,6 +118,22 @@
 {
 	uint32_t flag = 0;
 	switch (request) {
+	case VOCTRL_RESUME:
+		if (!noprebuf) {
+			ioval = EM8300_PLAYMODE_PLAY;
+			if (ioctl(fd_control, EM8300_IOCTL_SET_PLAYMODE, &ioval) < 0) {
+				printf("VO: [dxr3] Unable to set playmode!\n");
+			}
+		}
+		return VO_TRUE;
+	case VOCTRL_PAUSE:
+		if (!noprebuf) {
+			ioval = EM8300_PLAYMODE_PAUSED;
+			if (ioctl(fd_control, EM8300_IOCTL_SET_PLAYMODE, &ioval) < 0) {
+				printf("VO: [dxr3] Unable to set playmode!\n");
+			}
+		}
+		return VO_TRUE;
 	case VOCTRL_RESET:
 		if (!noprebuf) {
 			close(fd_video);
@@ -156,7 +173,7 @@
 
 static uint32_t config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t fullscreen, char *title, uint32_t format,const vo_tune_info_t *info)
 {
-	int tmp1, tmp2;
+	int tmp1, tmp2, size;
 	em8300_register_t reg;
     
 	/* Softzoom turned on, downscale */
@@ -226,10 +243,11 @@
 	}
 	ioctl(fd_control, EM8300_IOCTL_SET_ASPECTRATIO, &ioval);
     
+	size = s_width * s_height;
+	picture_buf = malloc((size * 3) / 2);
+	
 	if (format != IMGFMT_MPEGPES) {
 #ifdef USE_LIBAVCODEC
-		int size;
-		
 		avc_codec = avcodec_find_encoder(CODEC_ID_MPEG1VIDEO);
 		if (!avc_codec) {
 			printf("VO: [dxr3] Unable to find mpeg1video codec\n");
@@ -243,11 +261,10 @@
 		ioctl(fd_control, EM8300_IOCTL_GET_VIDEOMODE, &ioval);
 		if (ioval == EM8300_VIDEOMODE_NTSC) {
 			avc_context->gop_size = 18;
-			avc_context->frame_rate = 29.97 * FRAME_RATE_BASE;
 		} else {
 			avc_context->gop_size = 15;
-			avc_context->frame_rate = 25 * FRAME_RATE_BASE;
 		}
+		avc_context->frame_rate = vo_fps * FRAME_RATE_BASE;
 		avc_context->bit_rate = 8e6;
 		avc_context->flags = CODEC_FLAG_HQ | CODEC_FLAG_QSCALE;
 		avc_context->quality = 2;
@@ -291,10 +308,7 @@
 		avc_picture.linesize[0] = s_width;
 		avc_picture.linesize[1] = s_width / 2;
 		avc_picture.linesize[2] = s_width / 2;
-		avc_outbuf = malloc(avc_outbuf_size);
-
-		size = s_width * s_height;
-		picture_buf = malloc((size * 3) / 2);
+		
 		avc_picture.data[0] = picture_buf;
 		avc_picture.data[1] = avc_picture.data[0] + size;
 		avc_picture.data[2] = avc_picture.data[1] + size / 4;
@@ -350,16 +364,16 @@
 			}
 			write(fd_spu, p->data, p->size);
 		} else {
-			write(fd_video, p->data, p->size);
+			writesize = p->size;
+			memcpy(picture_buf, p->data, p->size);
 		}
 		return 0;
 #ifdef USE_LIBAVCODEC
 	} else {
-		int size, srcStride = (img_format == IMGFMT_YUY2) ? (v_width * 2) : (v_width * 3);
+		int srcStride = (img_format == IMGFMT_YUY2) ? (v_width * 2) : (v_width * 3);
 		sws->swScale(sws, src, &srcStride, 0, v_height, avc_picture.data, avc_picture.linesize);
 		draw_osd();
-		size = avcodec_encode_video(avc_context, avc_outbuf, avc_outbuf_size, &avc_picture);
-		write(fd_video, avc_outbuf, size);
+		writesize = avcodec_encode_video(avc_context, picture_buf, avc_outbuf_size, &avc_picture);
 		return 0;
 #endif
 	}
@@ -370,13 +384,14 @@
 {
 #ifdef USE_LIBAVCODEC
 	if (img_format == IMGFMT_YV12) {
-		int out_size = avcodec_encode_video(avc_context, avc_outbuf, avc_outbuf_size, &avc_picture);
+		writesize = avcodec_encode_video(avc_context, picture_buf, avc_outbuf_size, &avc_picture);
 		if (!noprebuf) {
 			ioctl(fd_video, EM8300_IOCTL_VIDEO_SETPTS, &vo_pts);
 		}
-		write(fd_video, avc_outbuf, out_size);
 	}
 #endif
+	write(fd_video, picture_buf, writesize);
+	writesize = 0;
 }
 
 static uint32_t draw_slice(uint8_t *srcimg[], int stride[], int w, int h, int x0, int y0)
@@ -400,10 +415,10 @@
 	if (avc_context) {
 		avcodec_close(avc_context);
 	}
+#endif
 	if (picture_buf) {
 		free(picture_buf);
 	}
-#endif
 	if (fd_video) {
 		close(fd_video);
 	}
--- a/mplayer.c	Mon Feb 18 16:50:16 2002 +0000
+++ b/mplayer.c	Mon Feb 18 17:34:20 2002 +0000
@@ -1957,6 +1957,9 @@
 #ifdef HAVE_NEW_GUI
       if(use_gui) mplShMem->Playing=2;
 #endif
+      if (video_out && sh_video)
+	 video_out->control(VOCTRL_PAUSE, NULL);
+
       if (audio_out && sh_audio)
          audio_out->pause();	// pause audio, keep data if possible
 
@@ -2005,6 +2008,8 @@
          osd_function=OSD_PLAY;
       if (audio_out && sh_audio)
         audio_out->resume();	// resume audio
+      if (video_out && sh_video)
+        video_out->control(VOCTRL_RESUME, NULL);	// resume video
       (void)GetRelativeTime();	// keep TF around FT in next cycle
 #ifdef HAVE_NEW_GUI
       if(use_gui && !gui_pause_flag) mplShMem->Playing=1; // play from keyboard