[MPlayer-dev-eng] [PATCH] Make vo_gl / fragment programs work with Mesa

Reimar Döffinger Reimar.Doeffinger at stud.uni-karlsruhe.de
Wed Feb 28 21:27:24 CET 2007


Hello,
On Wed, Feb 28, 2007 at 12:57:55PM +0100, Matthias Hopf wrote:
> > > No, probably not. The chips *should* be capable of that. I'll ask Keith
> > > later today.
> 
> Ok, now I know that the chips only support a maximum of 4 dependent
> texture lookups *in* *hardware*. That still could be enough, if I move
> the calculation of the cubic texture lookup offsets outside the fragment
> program. That should be doable, with two more interpolants.

I think that any such solution will mean much more instructions and
probably give speed problems for fullscreen videos.
How about attached patch instead? It adds an interpolator that is
cubic only in X-direction. Doesn't look too bad IMO.
It could be further simplified if texture swizzles were supported *g*

Greetings,
Reimar Döffinger
-------------- next part --------------
Index: libvo/gl_common.c
===================================================================
--- libvo/gl_common.c	(revision 22377)
+++ libvo/gl_common.c	(working copy)
@@ -708,6 +708,26 @@
   "MUL cdelta.yw, parmy.rrgg, {0, -1, 0, 1};"
   BICUB_FILT_MAIN("RECT");
 
+#define BICUB_X_FILT_MAIN(textype) \
+  "ADD coord, fragment.texcoord[%c].xyxy, cdelta.xyxw;" \
+  "ADD coord2, fragment.texcoord[%c].xyxy, cdelta.zyzw;" \
+  "TEX a.r, coord, texture[%c], "textype";" \
+  "TEX b.r, coord2, texture[%c], "textype";" \
+  /* x-interpolation */ \
+  "LRP yuv.%c, parmx.b, a.rrrr, b.rrrr;"
+
+static const char *bicub_x_filt_template_2D =
+  "MAD coord.x, fragment.texcoord[%c], {%f, %f}, {0.5, 0.5};"
+  "TEX parmx, coord, texture[%c], 1D;"
+  "MUL cdelta.xz, parmx.rrgg, {-%f, 0, %f, 0};"
+  BICUB_X_FILT_MAIN("2D");
+
+static const char *bicub_x_filt_template_RECT =
+  "ADD coord.x, fragment.texcoord[%c], {0.5, 0.5};"
+  "TEX parmx, coord, texture[%c], 1D;"
+  "MUL cdelta.xz, parmx.rrgg, {-1, 0, 1, 0};"
+  BICUB_X_FILT_MAIN("RECT");
+
 static const char *yuv_prog_template =
   "PARAM ycoef = {%.4f, %.4f, %.4f};"
   "PARAM ucoef = {%.4f, %.4f, %.4f};"
@@ -765,6 +785,7 @@
     case YUV_SCALER_BILIN:
       break;
     case YUV_SCALER_BICUB:
+    case YUV_SCALER_BICUB_X:
       texs[0] = (*texu)++;
       gen_spline_lookup_tex(GL_TEXTURE0 + texs[0]);
       texs[0] += '0';
@@ -960,6 +981,17 @@
                  texs[0], (float)1.0 / texh, (float)1.0 / texh,
                  in_tex, in_tex, in_tex, in_tex, in_tex, in_tex, out_comp);
       break;
+    case YUV_SCALER_BICUB_X:
+      if (rect)
+        snprintf(*prog_pos, *remain, bicub_x_filt_template_RECT,
+                 in_tex, texs[0],
+                 in_tex, in_tex, in_tex, in_tex, out_comp);
+      else
+        snprintf(*prog_pos, *remain, bicub_x_filt_template_2D,
+                 in_tex, (float)texw, (float)texh,
+                 texs[0], (float)1.0 / texw, (float)1.0 / texw,
+                 in_tex, in_tex, in_tex, in_tex, out_comp);
+      break;
   }
   *remain -= strlen(*prog_pos);
   *prog_pos += strlen(*prog_pos);
Index: libvo/gl_common.h
===================================================================
--- libvo/gl_common.h	(revision 22377)
+++ libvo/gl_common.h	(working copy)
@@ -239,6 +239,8 @@
 #define YUV_SCALER_BILIN 0
 //! use higher quality bicubic scaling for textures
 #define YUV_SCALER_BICUB 1
+//! use cubic scaling in X and normal linear scaling in Y direction
+#define YUV_SCALER_BICUB_X 2
 //! mask for conversion type
 #define YUV_CONVERSION_MASK 0xF
 //! mask for scaler type


More information about the MPlayer-dev-eng mailing list