changeset 8450:8cfc9309f0cc

notice vo driver about skipped/dropped frames patch by Alvaro Lopes <alvieboy@alvie.com>
author arpi
date Sat, 14 Dec 2002 17:12:40 +0000
parents ff22f772bd38
children fb88ccbc5ccc
files libvo/video_out.h libvo/vo_yuv4mpeg.c mplayer.c
diffstat 3 files changed, 67 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/libvo/video_out.h	Sat Dec 14 15:50:27 2002 +0000
+++ b/libvo/video_out.h	Sat Dec 14 17:12:40 2002 +0000
@@ -49,7 +49,10 @@
 /* equalizer controls */
 #define VOCTRL_SET_EQUALIZER 17
 #define VOCTRL_GET_EQUALIZER 18
-// ... 20
+//#define VOCTRL_GUI_NOWINDOW 19
+/* Frame duplication */
+#define VOCTRL_DUPLICATE_FRAME 20
+// ... 21
 
 
 #define VO_TRUE		1
--- a/libvo/vo_yuv4mpeg.c	Sat Dec 14 15:50:27 2002 +0000
+++ b/libvo/vo_yuv4mpeg.c	Sat Dec 14 17:12:40 2002 +0000
@@ -222,6 +222,56 @@
 		perror("yuv4mpeg: Error writing image to output!");
 }
 
+static int write_last_frame(void)
+{
+
+    uint8_t *upper_y, *upper_u, *upper_v, *rgb_buffer_lower;
+    int rgb_stride, uv_stride, field_height;
+    unsigned int i, low_ofs;
+
+    fprintf(yuv_out, "FRAME\n");
+
+    if (using_format != IMGFMT_YV12)
+    {
+	rgb_stride = image_width * 3;
+	uv_stride = image_width / 2;
+
+	if (Y4M_IS_INTERLACED)
+	{
+	    field_height = image_height / 2;
+
+	    upper_y = image;
+	    upper_u = upper_y + image_width * field_height;
+	    upper_v = upper_u + image_width * field_height / 4;
+	    low_ofs = image_width * field_height * 3 / 2;
+	    rgb_buffer_lower = rgb_buffer + rgb_stride * field_height;
+
+	    /* Write Y plane */
+	    for(i = 0; i < field_height; i++)
+	    {
+		vo_y4m_write(upper_y + image_width * i,           image_width);
+		vo_y4m_write(upper_y + image_width * i + low_ofs, image_width);
+	    }
+
+	    /* Write U and V plane */
+	    for(i = 0; i < field_height / 2; i++)
+	    {
+		vo_y4m_write(upper_u + uv_stride * i,           uv_stride);
+		vo_y4m_write(upper_u + uv_stride * i + low_ofs, uv_stride);
+	    }
+	    for(i = 0; i < field_height / 2; i++)
+	    {
+		vo_y4m_write(upper_v + uv_stride * i,           uv_stride);
+		vo_y4m_write(upper_v + uv_stride * i + low_ofs, uv_stride);
+	    }
+	    return VO_TRUE; /* Image written; We have to stop here */
+	}
+    }
+    /* Write progressive frame */
+    vo_y4m_write(image, write_bytes);
+    return VO_TRUE;
+}
+
 static void flip_page (void)
 {
 	uint8_t *upper_y, *upper_u, *upper_v, *rgb_buffer_lower;
@@ -455,6 +505,8 @@
   switch (request) {
   case VOCTRL_QUERY_FORMAT:
     return query_format(*((uint32_t*)data));
+  case VOCTRL_DUPLICATE_FRAME:
+    return write_last_frame();
   }
   return VO_NOTIMPL;
 }
--- a/mplayer.c	Sat Dec 14 15:50:27 2002 +0000
+++ b/mplayer.c	Sat Dec 14 17:12:40 2002 +0000
@@ -1725,7 +1725,8 @@
 	if(vo_config_count) video_out->check_events();
 
         current_module="flip_page";
-        if(blit_frame && !frame_time_remaining){
+        if (!frame_time_remaining) {
+         if(blit_frame){
 	   unsigned int t2=GetTimer();
 	   double tt;
 	   float j;
@@ -1744,8 +1745,15 @@
 	   t2=GetTimer()-t2;
 	   tt = t2*0.000001f;
 	   vout_time_usage+=tt;
-	}
-
+	 } else {
+             /*
+	     Well, no blitting is needed, but some devices (such as yuv4mpeg) must output frame
+             otherwise A/V desync will occur. -- Alvieboy
+	     */
+	    if (vo_config_count)
+		video_out->control(VOCTRL_DUPLICATE_FRAME, NULL);
+         }
+        }
 //====================== A-V TIMESTAMP CORRECTION: =========================
 
   current_module="av_sync";