[MPlayer-dev-eng] gl & distorted fisheye for dome projection

Reimar Doeffinger Reimar.Doeffinger at stud.uni-karlsruhe.de
Wed Jul 5 13:48:57 CEST 2006


Hello again,
On Wed, Jul 05, 2006 at 12:08:46AM +0200, Johannes Gajdosik wrote:
> > I'd recommend http://developer.nvidia.com/object/nvshaderperf_home.html.
> 
> Thanks, but the link seems to be broken.

Weird, works for me.

> I tried the patch. I had to fix glFmt2bpp in the following way,

Right.

> It worked, but again I got the pixelization (block) effect.
> I suppose that the texture is internally represented with only
> 3 bytes per pixel, instead of 6 bytes per pixel.

Yep, that format is supported by none of the current cards. But they
support 16 and 32 bit float. Though not sure from which version on
exactly, so it might be a good idea to keep that other version anyway.
Still, see if this works.

Greetings,
Reimar Doeffinger
-------------- next part --------------
Index: libvo/vo_gl.c
===================================================================
--- libvo/vo_gl.c	(revision 18910)
+++ libvo/vo_gl.c	(working copy)
@@ -187,7 +187,7 @@
     else {
       int width, height, maxval;
       ActiveTexture(GL_TEXTURE3);
-      if (glCreatePPMTex(GL_TEXTURE_2D, 3,
+      if (glCreatePPMTex(GL_TEXTURE_2D, 0,
                      custom_tlin?GL_LINEAR:GL_NEAREST,
                      f, &width, &height, &maxval))
         ProgramEnvParameter4f(GL_FRAGMENT_PROGRAM, 1,
Index: libvo/gl_common.c
===================================================================
--- libvo/gl_common.c	(revision 18910)
+++ libvo/gl_common.c	(working copy)
@@ -370,7 +370,7 @@
 /**
  * \brief creates a texture from a PPM file
  * \param target texture taget, usually GL_TEXTURE_2D
- * \param fmt internal texture format
+ * \param fmt internal texture format, 0 for default
  * \param filter filter used for scaling, e.g. GL_LINEAR
  * \param f file to read PPM from
  * \param width [out] width of texture
@@ -381,7 +381,7 @@
  */
 int glCreatePPMTex(GLenum target, GLenum fmt, GLint filter,
                    FILE *f, int *width, int *height, int *maxval) {
-  unsigned w, h, m, val;
+  unsigned w, h, m, val, bpp;
   char *data;
   ppm_skip(f);
   if (fgetc(f) != 'P' || fgetc(f) != '6')
@@ -400,11 +400,15 @@
     return 0;
   if (w > MAXDIM || h > MAXDIM)
     return 0;
-  data = malloc(w * h * 3);
-  if (fread(data, w * 3, h, f) != h)
+  bpp = (m > 255) ? 6 : 3;
+  data = malloc(w * h * bpp);
+  if (fread(data, w * bpp, h, f) != h)
     return 0;
+  if (!fmt)
+    fmt = (m > 255) ? GL_RGB32F : 3;
   glCreateClearTex(target, fmt, filter, w, h, 0);
-  glUploadTex(target, GL_RGB, GL_UNSIGNED_BYTE, data, w * 3, 0, 0, w, h, 0);
+  glUploadTex(target, GL_RGB, (m > 255) ? GL_UNSIGNED_SHORT : GL_UNSIGNED_BYTE,
+              data, w * bpp, 0, 0, w, h, 0);
   free(data);
   if (width) *width = w;
   if (height) *height = h;
@@ -422,6 +426,7 @@
  * Does not handle all possible variants, just those used by MPlayer
  */
 int glFmt2bpp(GLenum format, GLenum type) {
+  int component_size = 0;
   switch (type) {
     case GL_UNSIGNED_BYTE_3_3_2:
     case GL_UNSIGNED_BYTE_2_3_3_REV:
@@ -431,19 +436,23 @@
     case GL_UNSIGNED_SHORT_5_6_5:
     case GL_UNSIGNED_SHORT_5_6_5_REV:
       return 2;
+    case GL_UNSIGNED_BYTE:
+      component_size = 1;
+      break;
+    case GL_UNSIGNED_SHORT:
+      component_size = 2;
+      break;
   }
-  if (type != GL_UNSIGNED_BYTE)
-    return 0; //not implemented
   switch (format) {
     case GL_LUMINANCE:
     case GL_ALPHA:
-      return 1;
+      return component_size;
     case GL_RGB:
     case GL_BGR:
-      return 3;
+      return 3 * component_size;
     case GL_RGBA:
     case GL_BGRA:
-      return 4;
+      return 4 * component_size;
   }
   return 0; // unknown
 }
Index: libvo/gl_common.h
===================================================================
--- libvo/gl_common.h	(revision 18910)
+++ libvo/gl_common.h	(working copy)
@@ -180,6 +180,11 @@
 #ifndef GL_UNSIGNED_SHORT_1_5_5_5_REV
 #define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366
 #endif
+#ifndef GL_RGB32F
+#define GL_RGB32F 0x8815
+#endif
+#ifndef GL_RGB16F 0x881B
+#endif
 #ifndef GL_FRAGMENT_PROGRAM
 #define GL_FRAGMENT_PROGRAM 0x8804
 #endif


More information about the MPlayer-dev-eng mailing list