changeset 25885:fa24feceb3f9

Allow for larger fragment programs.
author reimar
date Tue, 29 Jan 2008 18:00:20 +0000
parents f6697d25b040
children feb0f4e3c81f
files libvo/gl_common.c
diffstat 1 files changed, 10 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/libvo/gl_common.c	Tue Jan 29 16:22:34 2008 +0000
+++ b/libvo/gl_common.c	Tue Jan 29 18:00:20 2008 +0000
@@ -1151,6 +1151,8 @@
   return 1;
 }
 
+#define MAX_PROGSZ (1024*1024)
+
 /**
  * \brief setup a fragment program that will do YUV->RGB conversion
  * \param brightness brightness adjustment offset
@@ -1164,14 +1166,14 @@
                         float uvcos, float uvsin, float rgamma,
                         float ggamma, float bgamma, int type, int rect,
                         int texw, int texh) {
-  char yuv_prog[4000] =
+  static const char prog_hdr[] =
     "!!ARBfp1.0\n"
     "OPTION ARB_precision_hint_fastest;"
     // all scaler variables must go here so they aren't defined
     // multiple times when the same scaler is used more than once
     "TEMP coord, coord2, cdelta, parmx, parmy, a, b, yuv;";
-  int prog_remain = sizeof(yuv_prog) - strlen(yuv_prog);
-  char *prog_pos = &yuv_prog[strlen(yuv_prog)];
+  int prog_remain;
+  char *yuv_prog, *prog_pos;
   int cur_texu = 3;
   char lum_scale_texs[1];
   char chrom_scale_texs[1];
@@ -1198,6 +1200,10 @@
     mp_msg(MSGT_VO, MSGL_FATAL, "[gl] ProgramString function missing!\n");
     return;
   }
+  yuv_prog = malloc(MAX_PROGSZ);
+  strcpy(yuv_prog, prog_hdr);
+  prog_pos    = yuv_prog + sizeof(prog_hdr) - 1;
+  prog_remain = MAX_PROGSZ - sizeof(prog_hdr);
   add_scaler(YUV_LUM_SCALER(type), &prog_pos, &prog_remain, lum_scale_texs,
              '0', 'r', rect, texw, texh);
   add_scaler(YUV_CHROM_SCALER(type), &prog_pos, &prog_remain, chrom_scale_texs,
@@ -1230,6 +1236,7 @@
   }
   mp_msg(MSGT_VO, MSGL_V, "[gl] generated fragment program:\n%s\n", yuv_prog);
   loadGPUProgram(GL_FRAGMENT_PROGRAM, yuv_prog);
+  free(yuv_prog);
 }
 
 /**