[MPlayer-cvslog] r30149 - in trunk/libvo: gl_common.c gl_common.h vo_gl.c vo_gl2.c

reimar subversion at mplayerhq.hu
Thu Dec 31 19:07:37 CET 2009


Author: reimar
Date: Thu Dec 31 19:07:37 2009
New Revision: 30149

Log:
Put the colourspace-related variables into a separate struct to ease
extracting the code and sharing with other vos.

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

Modified: trunk/libvo/gl_common.c
==============================================================================
--- trunk/libvo/gl_common.c	Thu Dec 31 17:47:53 2009	(r30148)
+++ trunk/libvo/gl_common.c	Thu Dec 31 19:07:37 2009	(r30149)
@@ -1018,7 +1018,7 @@ static void gen_gamma_map(unsigned char 
 #define COL_V 2
 #define COL_C 3
 
-static void get_yuv2rgb_coeffs(gl_conversion_params_t *params, float yuv2rgb[3][4]) {
+static void get_yuv2rgb_coeffs(struct mp_csp_params *params, float yuv2rgb[3][4]) {
   float uvcos = params->saturation * cos(params->hue);
   float uvsin = params->saturation * sin(params->hue);
   int i;
@@ -1049,7 +1049,7 @@ static void get_yuv2rgb_coeffs(gl_conver
  * \param map where to store map. Must provide space for (size + 2)^3 elements
  * \param size size of the map, excluding border
  */
-static void gen_yuv2rgb_map(gl_conversion_params_t *params, unsigned char *map, int size) {
+static void 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;
@@ -1101,9 +1101,9 @@ static void create_conv_textures(gl_conv
       texs[0] = (*texu)++;
       ActiveTexture(GL_TEXTURE0 + texs[0]);
       lookup_data = malloc(4 * LOOKUP_RES);
-      gen_gamma_map(lookup_data, LOOKUP_RES, params->rgamma);
-      gen_gamma_map(&lookup_data[LOOKUP_RES], LOOKUP_RES, params->ggamma);
-      gen_gamma_map(&lookup_data[2 * LOOKUP_RES], LOOKUP_RES, params->bgamma);
+      gen_gamma_map(lookup_data, LOOKUP_RES, params->csp_params.rgamma);
+      gen_gamma_map(&lookup_data[LOOKUP_RES], LOOKUP_RES, params->csp_params.ggamma);
+      gen_gamma_map(&lookup_data[2 * LOOKUP_RES], LOOKUP_RES, params->csp_params.bgamma);
       glCreateClearTex(GL_TEXTURE_2D, GL_LUMINANCE8, GL_LUMINANCE, GL_UNSIGNED_BYTE, GL_LINEAR,
                        LOOKUP_RES, 4, 0);
       glUploadTex(GL_TEXTURE_2D, GL_LUMINANCE, GL_UNSIGNED_BYTE, lookup_data,
@@ -1121,7 +1121,7 @@ static void create_conv_textures(gl_conv
         texs[0] = (*texu)++;
         ActiveTexture(GL_TEXTURE0 + texs[0]);
         lookup_data = malloc(3 * sz * sz * sz);
-        gen_yuv2rgb_map(params, lookup_data, LOOKUP_3DRES);
+        gen_yuv2rgb_map(&params->csp_params, lookup_data, LOOKUP_3DRES);
         glAdjustAlignment(sz);
         PixelStorei(GL_UNPACK_ROW_LENGTH, 0);
         TexImage3D(GL_TEXTURE_3D, 0, 3, sz, sz, sz, 1,
@@ -1330,7 +1330,7 @@ static void glSetupYUVFragprog(gl_conver
              '1', 'g', rect, params->chrom_texw, params->chrom_texh, params->filter_strength);
   add_scaler(YUV_CHROM_SCALER(type), &prog_pos, &prog_remain, chrom_scale_texs,
              '2', 'b', rect, params->chrom_texw, params->chrom_texh, params->filter_strength);
-  get_yuv2rgb_coeffs(params, yuv2rgb);
+  get_yuv2rgb_coeffs(&params->csp_params, yuv2rgb);
   switch (YUV_CONVERSION(type)) {
     case YUV_CONVERSION_FRAGMENT:
       snprintf(prog_pos, prog_remain, yuv_prog_template,
@@ -1345,7 +1345,7 @@ static void glSetupYUVFragprog(gl_conver
                yuv2rgb[ROW_R][COL_U], yuv2rgb[ROW_G][COL_U], yuv2rgb[ROW_B][COL_U],
                yuv2rgb[ROW_R][COL_V], yuv2rgb[ROW_G][COL_V], yuv2rgb[ROW_B][COL_V],
                yuv2rgb[ROW_R][COL_C], yuv2rgb[ROW_G][COL_C], yuv2rgb[ROW_B][COL_C],
-               (float)1.0 / params->rgamma, (float)1.0 / params->bgamma, (float)1.0 / params->bgamma);
+               (float)1.0 / params->csp_params.rgamma, (float)1.0 / params->csp_params.bgamma, (float)1.0 / params->csp_params.bgamma);
       break;
     case YUV_CONVERSION_FRAGMENT_LOOKUP:
       snprintf(prog_pos, prog_remain, yuv_lookup_prog_template,
@@ -1397,8 +1397,8 @@ static void gen_gamma_map(unsigned char 
  * \ingroup glconversion
  */
 void glSetupYUVConversion(gl_conversion_params_t *params) {
-  float uvcos = params->saturation * cos(params->hue);
-  float uvsin = params->saturation * sin(params->hue);
+  float uvcos = params->csp_params.saturation * cos(params->csp_params.hue);
+  float uvsin = params->csp_params.saturation * sin(params->csp_params.hue);
   switch (YUV_CONVERSION(params->type)) {
     case YUV_CONVERSION_COMBINERS:
       glSetupYUVCombiners(uvcos, uvsin);

Modified: trunk/libvo/gl_common.h
==============================================================================
--- trunk/libvo/gl_common.h	Thu Dec 31 17:47:53 2009	(r30148)
+++ trunk/libvo/gl_common.h	Thu Dec 31 19:07:37 2009	(r30149)
@@ -327,9 +327,8 @@ int loadGPUProgram(GLenum target, char *
 //! extract chrominance scaler out of type
 #define YUV_CHROM_SCALER(t) ((t >> YUV_CHROM_SCALER_SHIFT) & YUV_SCALER_MASK)
 /** \} */
-typedef struct {
-  GLenum target;
-  int type;
+
+struct mp_csp_params {
   float brightness;
   float contrast;
   float hue;
@@ -337,6 +336,12 @@ typedef struct {
   float rgamma;
   float ggamma;
   float bgamma;
+};
+
+typedef struct {
+  GLenum target;
+  int type;
+  struct mp_csp_params csp_params;
   int texw;
   int texh;
   int chrom_texw;

Modified: trunk/libvo/vo_gl.c
==============================================================================
--- trunk/libvo/vo_gl.c	Thu Dec 31 17:47:53 2009	(r30148)
+++ trunk/libvo/vo_gl.c	Thu Dec 31 19:07:37 2009	(r30149)
@@ -216,7 +216,7 @@ static void update_yuvconv(void) {
   float ggamma = exp(log(8.0) * eq_ggamma / 100.0);
   float bgamma = exp(log(8.0) * eq_bgamma / 100.0);
   gl_conversion_params_t params = {gl_target, yuvconvtype,
-      bri, cont, hue, sat, rgamma, ggamma, bgamma,
+      {bri, cont, hue, sat, rgamma, ggamma, bgamma},
       texture_width, texture_height, 0, 0, filter_strength};
   mp_get_chroma_shift(image_format, &xs, &ys);
   params.chrom_texw = params.texw >> xs;

Modified: trunk/libvo/vo_gl2.c
==============================================================================
--- trunk/libvo/vo_gl2.c	Thu Dec 31 17:47:53 2009	(r30148)
+++ trunk/libvo/vo_gl2.c	Thu Dec 31 19:07:37 2009	(r30149)
@@ -571,7 +571,7 @@ static int initGl(uint32_t d_width, uint
   if (is_yuv) {
     int xs, ys;
     gl_conversion_params_t params = {GL_TEXTURE_2D, use_yuv,
-          0.0, 1.0, 0.0, 1.0, 1.0, 1.0, 1.0,
+          {0.0, 1.0, 0.0, 1.0, 1.0, 1.0, 1.0},
           texture_width, texture_height, 0, 0, 0};
     switch (use_yuv) {
       case YUV_CONVERSION_FRAGMENT_LOOKUP:


More information about the MPlayer-cvslog mailing list