changeset 33927:9bb97722d8c7

Hook up -vo gl noise support.
author reimar
date Fri, 26 Aug 2011 19:24:12 +0000
parents 6e3f257d7b05
children 27b1c4df84bd
files Changelog DOCS/man/en/mplayer.1 libvo/gl_common.c libvo/gl_common.h libvo/vo_gl.c
diffstat 5 files changed, 15 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/Changelog	Fri Aug 26 18:51:51 2011 +0000
+++ b/Changelog	Fri Aug 26 19:24:12 2011 +0000
@@ -13,6 +13,7 @@
     * delogo: allow to change the rectangle based on the time.
 
     Other:
+    * support adding noise at output resolution with -vo gl:noise-strength=8
     * experimental support for PGS (BluRay-compatible), DVB and XSUB subtitles.
     * experimental af_cmdline slave command to change e.g. audio equalizer options at runtime.
 
--- a/DOCS/man/en/mplayer.1	Fri Aug 26 18:51:51 2011 +0000
+++ b/DOCS/man/en/mplayer.1	Fri Aug 26 19:24:12 2011 +0000
@@ -4256,6 +4256,9 @@
 For details see lscale.
 .IPs filter-strength=<value>
 Set the effect strength for the lscale/cscale filters that support it.
+.IPs noise-strength=<value>
+Set how much noise to add. 0 to disable (default), 1.0 for level suitable
+for dithering to 6 bit.
 .IPs stereo=<value>
 Select a method for stereo display.
 You may have to use \-aspect to fix the aspect value.
--- a/libvo/gl_common.c	Fri Aug 26 18:51:51 2011 +0000
+++ b/libvo/gl_common.c	Fri Aug 26 19:24:12 2011 +0000
@@ -1341,12 +1341,12 @@
   char lum_scale_texs[1];
   char chrom_scale_texs[1];
   char conv_texs[1];
-  char filt_texs[1];
+  char filt_texs[1] = {0};
   GLint i;
   // this is the conversion matrix, with y, u, v factors
   // for red, green, blue and the constant offsets
   float yuv2rgb[3][4];
-  int noise = 0;
+  int noise = params->noise_strength != 0;
   create_conv_textures(params, &cur_texu, conv_texs);
   create_scaler_textures(YUV_LUM_SCALER(type), &cur_texu, lum_scale_texs);
   if (YUV_CHROM_SCALER(type) == YUV_LUM_SCALER(type))
@@ -1414,7 +1414,8 @@
   prog_pos    += strlen(prog_pos);
 
   if (noise) {
-    double str = 1.0 / 8;
+    // 1.0 strength is suitable for dithering 8 to 6 bit
+    double str = params->noise_strength * (1.0 / 64);
     double scale_x = (double)NOISE_RES / texw;
     double scale_y = (double)NOISE_RES / texh;
     if (rect) {
--- a/libvo/gl_common.h	Fri Aug 26 18:51:51 2011 +0000
+++ b/libvo/gl_common.h	Fri Aug 26 19:24:12 2011 +0000
@@ -376,6 +376,7 @@
   int chrom_texw;
   int chrom_texh;
   float filter_strength;
+  float noise_strength;
 } gl_conversion_params_t;
 
 int glAutodetectYUVConversion(void);
--- a/libvo/vo_gl.c	Fri Aug 26 18:51:51 2011 +0000
+++ b/libvo/vo_gl.c	Fri Aug 26 19:24:12 2011 +0000
@@ -118,6 +118,7 @@
 static int lscale;
 static int cscale;
 static float filter_strength;
+static float noise_strength;
 static int yuvconvtype;
 static int use_rectangle;
 static int err_shown;
@@ -240,7 +241,7 @@
   float bgamma = exp(log(8.0) * eq_bgamma / 100.0);
   gl_conversion_params_t params = {gl_target, yuvconvtype,
       {colorspace, levelconv, bri, cont, hue, sat, rgamma, ggamma, bgamma, 0},
-      texture_width, texture_height, 0, 0, filter_strength};
+      texture_width, texture_height, 0, 0, filter_strength, noise_strength};
   mp_get_chroma_shift(image_format, &xs, &ys, &depth);
   params.chrom_texw = params.texw >> xs;
   params.chrom_texh = params.texh >> ys;
@@ -1139,6 +1140,7 @@
   {"lscale",       OPT_ARG_INT,  &lscale,       int_non_neg},
   {"cscale",       OPT_ARG_INT,  &cscale,       int_non_neg},
   {"filter-strength", OPT_ARG_FLOAT, &filter_strength, NULL},
+  {"noise-strength", OPT_ARG_FLOAT, &noise_strength, NULL},
   {"ati-hack",     OPT_ARG_BOOL, &ati_hack,     NULL},
   {"force-pbo",    OPT_ARG_BOOL, &force_pbo,    NULL},
   {"mesa-buffer",  OPT_ARG_BOOL, &mesa_buffer,  NULL},
@@ -1169,6 +1171,7 @@
     lscale = 0;
     cscale = 0;
     filter_strength = 0.5;
+    noise_strength = 0.0;
     use_rectangle = -1;
     use_glFinish = 0;
     ati_hack = -1;
@@ -1244,6 +1247,8 @@
               "    as lscale but for chroma (2x slower with little visible effect).\n"
               "  filter-strength=<value>\n"
               "    set the effect strength for some lscale/cscale filters\n"
+              "  noise-strength=<value>\n"
+              "    set how much noise to add. 1.0 is suitable for dithering to 6 bit.\n"
               "  customprog=<filename>\n"
               "    use a custom YUV conversion program\n"
               "  customtex=<filename>\n"