[MPlayer-cvslog] r30993 - in trunk/libvo: gl_common.c gl_common.h

reimar subversion at mplayerhq.hu
Sat Apr 3 21:58:07 CEST 2010


Author: reimar
Date: Sat Apr  3 21:58:06 2010
New Revision: 30993

Log:
Implement OpenGL-based YUV to RGB version for Radeon 9200 class
cards on OS X.

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

Modified: trunk/libvo/gl_common.c
==============================================================================
--- trunk/libvo/gl_common.c	Sat Apr  3 16:40:08 2010	(r30992)
+++ trunk/libvo/gl_common.c	Sat Apr  3 21:58:06 2010	(r30993)
@@ -809,6 +809,37 @@ static void glSetupYUVCombinersATI(float
 }
 
 /**
+ * \brief Variant of glYUVSetupCombinersATI using the API
+ *        implemented by Apple.
+ */
+static void glSetupYUVTextFragment(float uvcos, float uvsin) {
+  static const char template[] =
+    "!!ATIfs1.0\n"
+    "StartConstants;\n"
+    "  CONSTANT c0 = {%f, %f, %f};\n"
+    "  CONSTANT c1 = {%f, %f, %f};\n"
+    "EndConstants;\n"
+    "StartOutputPass;\n"
+    "  SampleMap r0, t0.str;\n"
+    "  SampleMap r1, t1.str;\n"
+    "  SampleMap r2, t2.str;\n"
+    "  MUL r1, r1.bias, c0.bias;\n"
+    "  MAD r2.4x, r2.bias, c1.bias, r1;\n"
+    "  ADD r0, r0, r2;\n"
+    "EndPass;\n";
+  GLfloat ucoef[4];
+  GLfloat vcoef[4];
+  char buffer[512];
+
+  fillUVcoeff(ucoef, vcoef, uvcos, uvsin);
+  snprintf(buffer, sizeof(buffer), template,
+           ucoef[0], ucoef[1], ucoef[2],
+           vcoef[0], vcoef[1], vcoef[2]);
+  mp_msg(MSGT_VO, MSGL_DBG2, "[gl] generated fragment program:\n%s\n", buffer);
+  loadGPUProgram(GL_TEXT_FRAGMENT_SHADER_ATI, buffer);
+}
+
+/**
  * \brief helper function for gen_spline_lookup_tex
  * \param x subpixel-position ((0,1) range) to calculate weights for
  * \param dst where to store transformed weights, must provide space for 4 GLfloats
@@ -1346,6 +1377,9 @@ void glSetupYUVConversion(gl_conversion_
     case YUV_CONVERSION_COMBINERS_ATI:
       glSetupYUVCombinersATI(uvcos, uvsin);
       break;
+    case YUV_CONVERSION_TEXT_FRAGMENT:
+      glSetupYUVTextFragment(uvcos, uvsin);
+      break;
     case YUV_CONVERSION_FRAGMENT_LOOKUP:
     case YUV_CONVERSION_FRAGMENT_LOOKUP3D:
     case YUV_CONVERSION_FRAGMENT:
@@ -1383,6 +1417,14 @@ void glEnableYUVConversion(GLenum target
       mpglActiveTexture(GL_TEXTURE0);
       mpglEnable(GL_FRAGMENT_SHADER_ATI);
       break;
+    case YUV_CONVERSION_TEXT_FRAGMENT:
+      mpglActiveTexture(GL_TEXTURE1);
+      mpglEnable(target);
+      mpglActiveTexture(GL_TEXTURE2);
+      mpglEnable(target);
+      mpglActiveTexture(GL_TEXTURE0);
+      mpglEnable(GL_TEXT_FRAGMENT_SHADER_ATI);
+      break;
     case YUV_CONVERSION_FRAGMENT_LOOKUP3D:
     case YUV_CONVERSION_FRAGMENT_LOOKUP:
     case YUV_CONVERSION_FRAGMENT_POW:
@@ -1417,6 +1459,14 @@ void glDisableYUVConversion(GLenum targe
       mpglActiveTexture(GL_TEXTURE0);
       mpglDisable(GL_FRAGMENT_SHADER_ATI);
       break;
+    case YUV_CONVERSION_TEXT_FRAGMENT:
+      mpglActiveTexture(GL_TEXTURE1);
+      mpglDisable(target);
+      mpglActiveTexture(GL_TEXTURE2);
+      mpglDisable(target);
+      mpglActiveTexture(GL_TEXTURE0);
+      mpglDisable(GL_TEXT_FRAGMENT_SHADER_ATI);
+      break;
     case YUV_CONVERSION_FRAGMENT_LOOKUP3D:
     case YUV_CONVERSION_FRAGMENT_LOOKUP:
     case YUV_CONVERSION_FRAGMENT_POW:

Modified: trunk/libvo/gl_common.h
==============================================================================
--- trunk/libvo/gl_common.h	Sat Apr  3 16:40:08 2010	(r30992)
+++ trunk/libvo/gl_common.h	Sat Apr  3 21:58:06 2010	(r30993)
@@ -71,6 +71,9 @@
 #ifndef GL_GENERATE_MIPMAP
 #define GL_GENERATE_MIPMAP 0x8191
 #endif
+#ifndef GL_TEXT_FRAGMENT_SHADER_ATI
+#define GL_TEXT_FRAGMENT_SHADER_ATI 0x8200
+#endif
 #ifndef GL_REGISTER_COMBINERS_NV
 #define GL_REGISTER_COMBINERS_NV 0x8522
 #endif
@@ -303,6 +306,8 @@ int loadGPUProgram(GLenum target, char *
 #define YUV_CONVERSION_COMBINERS_ATI 5
 //! use a fragment program with 3D table lookup for YUV conversion
 #define YUV_CONVERSION_FRAGMENT_LOOKUP3D 6
+//! use ATI specific "text" register combiners ("fragment program")
+#define YUV_CONVERSION_TEXT_FRAGMENT 7
 //! use normal bilinear scaling for textures
 #define YUV_SCALER_BILIN 0
 //! use higher quality bicubic scaling for textures


More information about the MPlayer-cvslog mailing list