[Mplayer-cvslog] CVS: main/libvo vo_gl.c,1.39,1.40

Reimar Döffinger CVS syncmail at mplayerhq.hu
Thu Apr 8 23:50:31 CEST 2004


CVS change done by Reimar Döffinger CVS

Update of /cvsroot/mplayer/main/libvo
In directory mail:/var2/tmp/cvs-serv28330/libvo

Modified Files:
	vo_gl.c 
Log Message:
vo_gl supporting more color formats for testing


Index: vo_gl.c
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/vo_gl.c,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -r1.39 -r1.40
--- vo_gl.c	22 Feb 2004 15:30:01 -0000	1.39
+++ vo_gl.c	8 Apr 2004 21:50:29 -0000	1.40
@@ -47,6 +47,9 @@
 static uint32_t image_width;
 static uint32_t image_height;
 static uint32_t image_bytes;
+static int many_fmts;
+static GLenum gl_format;
+static GLenum gl_type;
 
 static int int_pause;
 
@@ -67,6 +70,68 @@
   glLoadIdentity();
 }
 
+static int find_gl_format (uint32_t format)
+{
+  switch (format) {
+    case IMGFMT_RGB24:
+      gl_format = GL_RGB;
+      gl_type = GL_UNSIGNED_BYTE;
+      break;
+    case IMGFMT_RGB32:
+      gl_format = GL_RGBA;
+      gl_type = GL_UNSIGNED_BYTE;
+      break;
+    case IMGFMT_Y800:
+    case IMGFMT_Y8:
+      gl_format = GL_LUMINANCE;
+      gl_type = GL_UNSIGNED_BYTE;
+      break;
+#ifdef GL_VERSION_1_2
+    case IMGFMT_RGB8:
+      gl_format = GL_RGB;
+      gl_type = GL_UNSIGNED_BYTE_3_3_2;
+      break;
+    case IMGFMT_RGB15:
+      gl_format = GL_RGBA;
+      gl_type = GL_UNSIGNED_SHORT_5_5_5_1;
+      break;
+    case IMGFMT_RGB16:
+      gl_format = GL_RGB;
+      gl_type = GL_UNSIGNED_SHORT_5_6_5;
+      break;
+    case IMGFMT_BGR8:
+      // special case as red and blue have a differen number of bits.
+      // GL_BGR and GL_UNSIGNED_BYTE_3_3_2 isn't supported at least
+      // by nVidia drivers, and in addition would give more bits to
+      // blue than to red, which isn't wanted
+      gl_format = GL_RGB;
+      gl_type = GL_UNSIGNED_BYTE_2_3_3_REV;
+      break;
+    case IMGFMT_BGR15:
+      gl_format = GL_BGRA;
+      gl_type = GL_UNSIGNED_SHORT_5_5_5_1;
+      break;
+    case IMGFMT_BGR16:
+      gl_format = GL_RGB;
+      gl_type = GL_UNSIGNED_SHORT_5_6_5_REV;
+      break;
+    case IMGFMT_BGR24:
+      gl_format = GL_BGR;
+      gl_type = GL_UNSIGNED_BYTE;
+      break;
+    case IMGFMT_BGR32:
+      gl_format = GL_BGRA;
+      gl_type = GL_UNSIGNED_BYTE;
+      break;
+#endif
+    default:
+      gl_format = GL_RGBA;
+      gl_type = GL_UNSIGNED_BYTE;
+      return 0;
+  }
+  return 1;
+}
+
 /* connect to server, create and map window,
  * allocate colors and (shared) memory
  */
@@ -83,6 +148,7 @@
 
 	image_height = height;
 	image_width = width;
+	find_gl_format (format);
     vo_dwidth = d_width;
     vo_dheight = d_height;
 
@@ -266,8 +332,8 @@
 		       i,  // y offset
 		       image_width,    // width
 		       (i+slice_height<=image_height)?slice_height:image_height-i,              // height
-		       (image_bytes==4)?GL_RGBA:GL_RGB,        // format
-		       GL_UNSIGNED_BYTE, // type
+		       gl_format,
+		       gl_type,
 		       ImageData+i*image_bytes*image_width );        // *pixels
     }
 
@@ -279,6 +345,8 @@
 {
     if ((format == IMGFMT_RGB24) || (format == IMGFMT_RGB32))
         return VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW;
+    if (many_fmts && find_gl_format(format))
+        return VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW;
     return 0;
 }
 
@@ -293,15 +361,20 @@
 
 static uint32_t preinit(const char *arg)
 {
+    many_fmts = 0;
+    slice_height = 4;
     if(arg) 
     {
+	    if (strncmp (arg, "manyfmts", 8) == 0) {
+		    mp_msg (MSGT_VO, MSGL_WARN, "[gl] make sure you have OpenGL >= 1.2 and used corresponding headers for compiling!");
+		    many_fmts = 1;
+		    arg = &arg[8];
+	    }
+	    if (arg[0] != 0) {
 	    slice_height = atoi(arg);
 	    if (slice_height <= 0)
 		    slice_height = 65536;
-    }
-    else
-    {
-	    slice_height = 4;
+	    }
     }
     mp_msg(MSGT_VO, MSGL_INFO, "[vo_gl] Using %d as slice_height (0 means image_height).\n", slice_height);
 




More information about the MPlayer-cvslog mailing list