From 553e8203879d163e6fe2f3a8f6b80a44749514c1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Christian=20K=C3=B6nig?= Date: Mon, 13 Feb 2012 11:41:23 +0100 Subject: [PATCH] vl: fix low strength denoise filter MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- src/gallium/auxiliary/vl/vl_median_filter.c | 4 ++-- src/gallium/state_trackers/vdpau/mixer.c | 8 ++++---- src/gallium/state_trackers/vdpau/vdpau_private.h | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/gallium/auxiliary/vl/vl_median_filter.c b/src/gallium/auxiliary/vl/vl_median_filter.c index 0129013f637..6a03f95855b 100644 --- a/src/gallium/auxiliary/vl/vl_median_filter.c +++ b/src/gallium/auxiliary/vl/vl_median_filter.c @@ -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; diff --git a/src/gallium/state_trackers/vdpau/mixer.c b/src/gallium/state_trackers/vdpau/mixer.c index 5ce40d619ed..c3c2411eb7e 100644 --- a/src/gallium/state_trackers/vdpau/mixer.c +++ b/src/gallium/state_trackers/vdpau/mixer.c @@ -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: diff --git a/src/gallium/state_trackers/vdpau/vdpau_private.h b/src/gallium/state_trackers/vdpau/vdpau_private.h index f47c0bf1a31..35f0dc0d58a 100644 --- a/src/gallium/state_trackers/vdpau/vdpau_private.h +++ b/src/gallium/state_trackers/vdpau/vdpau_private.h @@ -311,7 +311,7 @@ typedef struct struct { bool supported, enabled; - float level; + unsigned level; struct vl_median_filter *filter; } noise_reduction; -- 2.30.2