[Mplayer-cvslog] CVS: main/libvo2 draw.c,1.2,1.3 libvo2.h,1.2,1.3
Arpi of Ize
arpi at mplayer.dev.hu
Tue Jul 31 02:24:31 CEST 2001
Update of /cvsroot/mplayer/main/libvo2
In directory mplayer:/var/tmp.root/cvs-serv4283
Modified Files:
draw.c libvo2.h
Log Message:
changed buffering method
Index: draw.c
===================================================================
RCS file: /cvsroot/mplayer/main/libvo2/draw.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- draw.c 30 Jul 2001 02:00:54 -0000 1.2
+++ draw.c 31 Jul 2001 00:24:28 -0000 1.3
@@ -3,6 +3,104 @@
#include "libvo2.h"
+// type:
+// 1 = single, temporary buffer (yuv->rgb, or indirect render)
+// 2 = single, static buffer (direct rendering for buggy vfw codecs)
+// 3 = P+P+B buffering (for mpeg 1/2/4)
+// doublebuf:
+// 0 = auto (not specified by the user)
+// 1 = no doublebuffering
+// 2 = double buffering
+// 3 = triple buffering
+void vo2_choose_buffering(vo2_handle_t *vo,int type,int doublebuf){
+ int speed=vo->functions->control(vo,VO2CTRL_QUERY_SURFACE_FAST,0);
+ int direct=vo->functions->control(vo,VO2CTRL_QUERY_SURFACE_DIRECT,0);
+ int max=vo->functions->control(vo,VO2CTRL_GET_MAX_SURFACES,0);
+ int bufs=0; // buffers in driver
+ int vo2_bufs=0; // buffers in vo2
+
+ switch(type){
+ case 1:
+ // full update of buffer for each frames
+ // USED BY: divx4linux, and codecs with YV12->RGB conversion
+ if(doublebuf==1 || direct==0){
+ // user disabled double buffering or driver does memcpy:
+ bufs=1;
+ break;
+ }
+ if(doublebuf>1 && max==1) {
+ // user wants doublebuf, but driver has only 1 direct surface:
+ vo2_bufs=1; // vo2 does double buffering (allocates surface)
+ bufs=1;
+ break;
+ }
+ // try double buffering...
+ bufs=(doublebuf>1) ? doublebuf : 3;
+ if(max>0 && bufs>max) bufs=max;
+ break;
+ case 2:
+ // partial update of buffer. buffer address shouldn't change.
+ // used by VfW divx codecs.
+ if(doublebuf>1 && direct!=0){
+ // user wants double buffering & not indirect -> use internal buffer
+ bufs=1;
+ vo2_bufs=1; // vo2 does double buffering (allocates surface)
+ break;
+ }
+ // direct rendering!
+ bufs=1;
+ break;
+ case 3:
+ // mixed mode: 2 static and 1 temporary frames (for MPEG codecs)
+ if(speed==1 && max>=3){
+ // buffers are in fast memory. keep P frames in driver.
+ if(direct==0){
+ // we have enough indirect buffers
+ bufs=3;
+ break;
+ }
+ // I think we never reach this point:
+ // fast & direct at the same time... but who knows :)
+ // (maybe some overlay driver with shared/AGP memory?)
+ if(max>4){
+ // direct, triple buffering is possible
+ if(doublebuf==0 || doublebuf>=3){
+ bufs=5;
+ break;
+ }
+ }
+ if(max>3){
+ // direct, double buffering is possible
+ if(doublebuf==0 || doublebuf>=2){
+ bufs=4;
+ break;
+ }
+ }
+ bufs=3; // no doublebuffering :(
+ break;
+ }
+ // ok. no enough fast buffers.
+ // try mixed mode: P in system, B in video ram ?
+ vo2_bufs=2; // two P buffers
+ if(doublebuf==1 || direct==0){
+ // user doesn't want double buffering or indirect
+ bufs=1; break;
+ }
+ // double buffering (if possible)
+ if(max==0){
+ // user forces double buffering, but we don't know how many
+ // buffers we have (hope user knows)
+ bufs=(doublebuf>1) ? doublebuf : 1;
+ break;
+ }
+ bufs=(max>3)?3:max;
+ break;
+ }
+
+ printf("choose_buffering: system: %d video: %d\n",vo2_bufs,bufs);
+
+}
+
// field: 0=frame 1=top_field 2=bottom_field
void vo2_draw_slice_start(vo2_handle_t *vo,int field){
// setup surface
Index: libvo2.h
===================================================================
RCS file: /cvsroot/mplayer/main/libvo2/libvo2.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- libvo2.h 30 Jul 2001 02:00:54 -0000 1.2
+++ libvo2.h 31 Jul 2001 00:24:28 -0000 1.3
@@ -1,4 +1,30 @@
+#define VO2_FALSE 0
+#define VO2_TRUE 1
+#define VO2_NA -1
+#define VO2_UNKNOWN -2
+
+// return true if surface is in fast system ram, false if slow (video?) memory
+// USED for storing mpeg2 I/P frames only if it's fast enough
+#define VO2CTRL_QUERY_SURFACE_FAST 0x101
+
+// return true if surface is direct rendered, false if indirect (copied first)
+// Note: it's usually same as VO2CTRL_GET_SURFACE_SPEED, except for some
+// special cases, when video card does the copy from video ram (opengl...)
+// USED for deciding external double buffering mode (using 2 surfaces)
+#define VO2CTRL_QUERY_SURFACE_DIRECT 0x102
+
+// Get the upper hardware/Driver limitation (used for double buffering)
+#define VO2CTRL_GET_MAX_SURFACES 0x103
+
+// Query support of a given video pixel format (use IMGFMT_ constants)
+#define VO2CTRL_QUERY_FORMAT 0x111
+
+// Query that software and/or hardware scaling is supported by driver
+#define VO2CTRL_QUERY_SWSCALE 0x121
+#define VO2CTRL_QUERY_HWSCALE 0x122
+
+
typedef struct vo2_info_s
{
/* driver name ("Matrox Millennium G200/G400" */
@@ -31,12 +57,11 @@
// start drawing (set video mode, allocate image buffers etc.)
// w,h: requested surface size (actual size may be larger!!!)
// format: IMGFMT_* requested surface pixel format
-// buffering: 0 - single temporary frame buffer (for draw_* stuff)
-// 1 - single static buffer (for win32 direct rendering)
-// 2 - 2 static + 1 temp buffer (for mpeg direct rendering)
+// buffers: requested number of surfaces (0=auto)
// flags: various things, like fullscreen, sw/hw zoom and vidmode change
-// return: 1=success 0=fail (fail if pixel format or buffering not supported)
- int (*start)(void *p, int w,int h,int format,int buffering,int flags);
+// return: 0=fail (fail if pixel format or buffering not supported)
+// n=number of surfaces allocated
+ int (*start)(void *p, int w,int h,int format,int surfaces,int flags);
// stop rendering, close device
int (*stop)(void *p);
More information about the MPlayer-cvslog
mailing list