[MPlayer-dev-eng] [PATCH] fix screen flicker in svgalib

Mikulas Patocka mikulas at artax.karlin.mff.cuni.cz
Thu Jul 5 01:16:07 CEST 2007


Hi

Using mplayer on svgalib with double buffering and without waitretrace 
causes OSD flicker with some combinations of CPU speed & movie frame 
rates.

The problem is that many videocards can't do immediate frame switch, they 
instead switch to a new frame on next screen retrace. If the CPU is fast 
enough to start rendering new frame before the retrace happens, flicker is 
seen.

Double-buffering is not enough, at least 3 pages are needed for 
flicker-free playback:
Page 1: page that is currently being displayed
Page 2: page that will be displayed on next retrace
Page 3: page where new frame is rendered

This patch changes vo_svga to use all available pages in a cycle, so if 
you have videoram for at least 3 pages, you get flicker-free playback and 
you don't have to waste CPU cycles on waitretrace.

Mikulas
-------------- next part --------------
--- vo_svga.c_	2007-07-05 01:05:21.000000000 +0200
+++ vo_svga.c	2007-07-05 01:07:04.000000000 +0200
@@ -110,9 +110,16 @@
 
 //return number of 1'st free page or -1 if no free one
 static inline int page_find_free(){
+static int last_page = 0;
 int i;
+  for(i=last_page+1;i<max_pages;i++)
+    if(PageStore[i].locks == PAGE_EMPTY) {
+      found:
+      last_page = i;
+      return i;
+    }
   for(i=0;i<max_pages;i++)
-    if(PageStore[i].locks == PAGE_EMPTY) return i;
+    if(PageStore[i].locks == PAGE_EMPTY) goto found;
   return -1;
 }
 


More information about the MPlayer-dev-eng mailing list