[MPlayer-cvslog] r36208 - in trunk/libvo: csputils.c gl_common.c

reimar subversion at mplayerhq.hu
Thu May 2 21:44:29 CEST 2013


Author: reimar
Date: Thu May  2 21:44:29 2013
New Revision: 36208

Log:
Avoid 3D texture with border.

It doesn't really improve quality and it is badly
supported, for example with ATI HD5000 cards it will
be very slow (software fallback?) if using the fglrx driver
or it is ignored if using Mesa (which results in e.g. very
bright parts becoming black).

Modified:
   trunk/libvo/csputils.c
   trunk/libvo/gl_common.c

Modified: trunk/libvo/csputils.c
==============================================================================
--- trunk/libvo/csputils.c	Thu May  2 00:45:26 2013	(r36207)
+++ trunk/libvo/csputils.c	Thu May  2 21:44:29 2013	(r36208)
@@ -137,18 +137,22 @@ void mp_get_yuv2rgb_coeffs(struct mp_csp
   }
 }
 
+static float int2pos(int i, int size) {
+  if (i == 0) return 0;
+  if (i == size - 1) return 1;
+  return (i + 0.5) / size;
+}
+
 //! size of gamma map use to avoid slow exp function in gen_yuv2rgb_map
 #define GMAP_SIZE (1024)
 /**
  * \brief generate a 3D YUV -> RGB map
  * \param params struct containing parameters like brightness, gamma, ...
- * \param map where to store map. Must provide space for (size + 2)^3 elements
- * \param size size of the map, excluding border
+ * \param map where to store map. Must provide space for size^3 elements
+ * \param size size of the map
  */
 void mp_gen_yuv2rgb_map(struct mp_csp_params *params, unsigned char *map, int size) {
   int i, j, k, l;
-  float step = 1.0 / size;
-  float y, u, v;
   float yuv2rgb[3][4];
   unsigned char gmaps[3][GMAP_SIZE];
   mp_gen_gamma_map(gmaps[0], GMAP_SIZE, params->rgamma);
@@ -158,20 +162,17 @@ void mp_gen_yuv2rgb_map(struct mp_csp_pa
   for (i = 0; i < 3; i++)
     for (j = 0; j < 4; j++)
       yuv2rgb[i][j] *= GMAP_SIZE - 1;
-  v = 0;
-  for (i = -1; i <= size; i++) {
-    u = 0;
-    for (j = -1; j <= size; j++) {
-      y = 0;
-      for (k = -1; k <= size; k++) {
+  for (i = 0; i < size; i++) {
+    float v = int2pos(i, size);
+    for (j = 0; j < size; j++) {
+      float u = int2pos(j, size);
+      for (k = 0; k < size; k++) {
+        float y = int2pos(k, size);
         for (l = 0; l < 3; l++) {
           float rgb = yuv2rgb[l][COL_Y] * y + yuv2rgb[l][COL_U] * u + yuv2rgb[l][COL_V] * v + yuv2rgb[l][COL_C];
           *map++ = gmaps[l][av_clip(rgb, 0, GMAP_SIZE - 1)];
         }
-        y += (k == -1 || k == size - 1) ? step / 2 : step;
       }
-      u += (j == -1 || j == size - 1) ? step / 2 : step;
     }
-    v += (i == -1 || i == size - 1) ? step / 2 : step;
   }
 }

Modified: trunk/libvo/gl_common.c
==============================================================================
--- trunk/libvo/gl_common.c	Thu May  2 00:45:26 2013	(r36207)
+++ trunk/libvo/gl_common.c	Thu May  2 21:44:29 2013	(r36208)
@@ -1239,7 +1239,7 @@ static void create_conv_textures(gl_conv
       break;
     case YUV_CONVERSION_FRAGMENT_LOOKUP3D:
       {
-        int sz = LOOKUP_3DRES + 2; // texture size including borders
+        int sz = LOOKUP_3DRES; // texture size
         if (!mpglTexImage3D) {
           mp_msg(MSGT_VO, MSGL_ERR, "[gl] Missing 3D texture function!\n");
           break;
@@ -1250,14 +1250,14 @@ static void create_conv_textures(gl_conv
         mp_gen_yuv2rgb_map(&params->csp_params, lookup_data, LOOKUP_3DRES);
         glAdjustAlignment(sz);
         mpglPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
-        mpglTexImage3D(GL_TEXTURE_3D, 0, 3, sz, sz, sz, 1,
+        mpglTexImage3D(GL_TEXTURE_3D, 0, 3, sz, sz, sz, 0,
                        GL_RGB, GL_UNSIGNED_BYTE, lookup_data);
         mpglTexParameterf(GL_TEXTURE_3D, GL_TEXTURE_PRIORITY, 1.0);
         mpglTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
         mpglTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-        mpglTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, GL_CLAMP);
-        mpglTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_T, GL_CLAMP);
-        mpglTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_R, GL_CLAMP);
+        mpglTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+        mpglTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+        mpglTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
         mpglActiveTexture(GL_TEXTURE0);
         texs[0] += '0';
       }


More information about the MPlayer-cvslog mailing list