changeset 36105:10a63b5e6513

Enable/disable extra instructions for gamma correction at runtime, on-demand.
author reimar
date Wed, 01 May 2013 18:27:38 +0000
parents 4e3c56728d1e
children 959e6a52e5b0
files DOCS/man/en/mplayer.1 libvo/gl_common.c libvo/vo_gl.c
diffstat 3 files changed, 17 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/DOCS/man/en/mplayer.1	Wed May 01 11:18:58 2013 +0000
+++ b/DOCS/man/en/mplayer.1	Wed May 01 18:27:38 2013 +0000
@@ -4213,16 +4213,16 @@
 Provides saturation and hue control.
 This method is fast but inexact.
 .br
-2: Use a fragment program.
-Needs the GL_ARB_fragment_program extension and at least three texture units.
-Provides brightness, contrast, saturation and hue control.
-.br
-3: Use a fragment program using the POW instruction.
+2: Use a fragment program using the POW instruction.
 Needs the GL_ARB_fragment_program extension and at least three texture units.
 Provides brightness, contrast, saturation, hue and gamma control.
 Gamma can also be set independently for red, green and blue.
 Method 4 is usually faster.
 .br
+3: Same as 2.
+They exist as distinct values for legacy reasons, MPlayer now inserts
+the extra instructions for gamma control on-demand.
+.br
 4: Use a fragment program with additional lookup.
 Needs the GL_ARB_fragment_program extension and at least four texture units.
 Provides brightness, contrast, saturation, hue and gamma control.
--- a/libvo/gl_common.c	Wed May 01 11:18:58 2013 +0000
+++ b/libvo/gl_common.c	Wed May 01 18:27:38 2013 +0000
@@ -1405,6 +1405,8 @@
   int texw = params->texw;
   int texh = params->texh;
   int rect = params->target == GL_TEXTURE_RECTANGLE;
+  int convtype = YUV_CONVERSION(type);
+  int has_gamma = params->csp_params.rgamma != 1 || params->csp_params.bgamma != 1 || params->csp_params.bgamma != 1;
   static const char prog_hdr[] =
     "!!ARBfp1.0\n"
     "OPTION ARB_precision_hint_fastest;\n"
@@ -1455,7 +1457,13 @@
   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);
   mp_get_yuv2rgb_coeffs(&params->csp_params, yuv2rgb);
-  switch (YUV_CONVERSION(type)) {
+
+  // enable/disable gamma on demand
+  if (has_gamma && convtype == YUV_CONVERSION_FRAGMENT) convtype = YUV_CONVERSION_FRAGMENT_POW;
+  else if (!has_gamma && (convtype == YUV_CONVERSION_FRAGMENT_POW || convtype == YUV_CONVERSION_FRAGMENT_LOOKUP))
+    convtype = YUV_CONVERSION_FRAGMENT;
+
+  switch (convtype) {
     case YUV_CONVERSION_FRAGMENT:
       snprintf(prog_pos, prog_remain, yuv_prog_template,
                yuv2rgb[ROW_R][COL_Y], yuv2rgb[ROW_G][COL_Y], yuv2rgb[ROW_B][COL_Y],
--- a/libvo/vo_gl.c	Wed May 01 11:18:58 2013 +0000
+++ b/libvo/vo_gl.c	Wed May 01 18:27:38 2013 +0000
@@ -106,7 +106,7 @@
 static int use_ycbcr;
 #define MASK_ALL_YUV (~(1 << YUV_CONVERSION_NONE))
 #define MASK_NOT_COMBINERS (~((1 << YUV_CONVERSION_NONE) | (1 << YUV_CONVERSION_COMBINERS)))
-#define MASK_GAMMA_SUPPORT (MASK_NOT_COMBINERS & ~(1 << YUV_CONVERSION_FRAGMENT))
+#define MASK_GAMMA_SUPPORT MASK_NOT_COMBINERS
 static int use_yuv;
 static int colorspace;
 static int levelconv;
@@ -1327,8 +1327,8 @@
               "  yuv=<n>\n"
               "    0: use software YUV to RGB conversion.\n"
               "    1: use register combiners (nVidia only, for older cards).\n"
-              "    2: use fragment program.\n"
-              "    3: use fragment program with gamma correction.\n"
+              "    2: use fragment program with gamma correction.\n"
+              "    3: same as 2.\n"
               "    4: use fragment program with gamma correction via lookup.\n"
               "    5: use ATI-specific method (for older cards).\n"
               "    6: use lookup via 3D texture.\n"