vl: fix low strength denoise filter
authorChristian König <deathsimple@vodafone.de>
Mon, 13 Feb 2012 10:41:23 +0000 (11:41 +0100)
committerChristian König <deathsimple@vodafone.de>
Tue, 14 Feb 2012 21:31:29 +0000 (22:31 +0100)
A filter strength of zero or one doesn't make any
sense. Thanks to Andy Furniss for pointing this out.

Signed-off-by: Christian König <deathsimple@vodafone.de>
src/gallium/auxiliary/vl/vl_median_filter.c
src/gallium/state_trackers/vdpau/mixer.c
src/gallium/state_trackers/vdpau/vdpau_private.h

index 0129013f637e9bf6187752f9609d52de5ea2b8e2..6a03f95855b6b5f44c44fb4de20f1fd80bdef4fa 100644 (file)
@@ -165,7 +165,7 @@ generate_offsets(enum vl_median_filter_shape shape, unsigned size,
    assert(offsets && num_offsets);
 
    /* size needs to be odd */
-   size = align(size, 2) - 1;
+   size = align(size + 1, 2) - 1;
    half_size = size >> 1;
 
    switch(shape) {
@@ -249,7 +249,7 @@ vl_median_filter_init(struct vl_median_filter *filter, struct pipe_context *pipe
 
    assert(filter && pipe);
    assert(width && height);
-   assert(size > 0 && size < 20);
+   assert(size > 1 && size < 20);
 
    memset(filter, 0, sizeof(*filter));
    filter->pipe = pipe;
index 5ce40d619ed863597346225db6c720dbf9e1d6ac..c3c2411eb7e0e9e9cd6c2efa74789851e2b4fad6 100644 (file)
@@ -278,12 +278,12 @@ vlVdpVideoMixerUpdateNoiseReductionFilter(vlVdpVideoMixer *vmixer)
    }
 
    /* and create a new filter as needed */
-   if (vmixer->noise_reduction. enabled && vmixer->noise_reduction.level > 0.0f) {
+   if (vmixer->noise_reduction. enabled && vmixer->noise_reduction.level > 0) {
       vmixer->noise_reduction.filter = MALLOC(sizeof(struct vl_median_filter));
       vl_median_filter_init(vmixer->noise_reduction.filter,
                             vmixer->device->context->pipe,
                             vmixer->video_width, vmixer->video_height,
-                            9 * vmixer->noise_reduction.level,
+                            vmixer->noise_reduction.level + 1,
                             VL_MEDIAN_FILTER_CROSS);
    }
 }
@@ -545,7 +545,7 @@ vlVdpVideoMixerSetAttributeValues(VdpVideoMixer mixer,
          if (val < 0.f || val > 1.f)
             return VDP_STATUS_INVALID_VALUE;
 
-         vmixer->noise_reduction.level = val;
+         vmixer->noise_reduction.level = val * 10;
          vlVdpVideoMixerUpdateNoiseReductionFilter(vmixer);
          break;
 
@@ -658,7 +658,7 @@ vlVdpVideoMixerGetAttributeValues(VdpVideoMixer mixer,
          break;
 
       case VDP_VIDEO_MIXER_ATTRIBUTE_NOISE_REDUCTION_LEVEL:
-         *(float*)attribute_values[i] = vmixer->noise_reduction.level;
+         *(float*)attribute_values[i] = (float)vmixer->noise_reduction.level / 10.0f;
          break;
 
       case VDP_VIDEO_MIXER_ATTRIBUTE_LUMA_KEY_MIN_LUMA:
index f47c0bf1a31ad36fbc11e4ea811de7edf7a691de..35f0dc0d58a2a6cc2dd85449190fa47756da9de9 100644 (file)
@@ -311,7 +311,7 @@ typedef struct
 
    struct {
       bool supported, enabled;
-      float level;
+      unsigned level;
       struct vl_median_filter *filter;
    } noise_reduction;