[vlc-commits] vdpau: configurable noise reduction

Rémi Denis-Courmont git at videolan.org
Sun Jul 7 20:13:42 CEST 2013


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Fri Jun 28 22:02:09 2013 +0300| [c0090b15ac84b8ff7e2e44e43b7d840e16bb970d] | committer: Rémi Denis-Courmont

vdpau: configurable noise reduction

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=c0090b15ac84b8ff7e2e44e43b7d840e16bb970d
---

 modules/hw/vdpau/chroma.c |   57 ++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 56 insertions(+), 1 deletion(-)

diff --git a/modules/hw/vdpau/chroma.c b/modules/hw/vdpau/chroma.c
index cdddbf4..c8504b5 100644
--- a/modules/hw/vdpau/chroma.c
+++ b/modules/hw/vdpau/chroma.c
@@ -55,9 +55,21 @@ static VdpVideoMixer MixerCreate(filter_t *filter)
     VdpBool ok;
 
     /* Check for potentially useful features */
-    VdpVideoMixerFeature featv[1];
+    VdpVideoMixerFeature featv[2];
     unsigned featc = 0;
 
+    const float noise = var_InheritFloat(filter, "vdpau-noise-reduction");
+    if (noise > 0.f)
+    {
+        err = vdp_video_mixer_query_feature_support(sys->vdp, sys->device,
+                                 VDP_VIDEO_MIXER_FEATURE_NOISE_REDUCTION, &ok);
+        if (err == VDP_STATUS_OK && ok == VDP_TRUE)
+        {
+            msg_Dbg(filter, "using video mixer %s feature", "noise reduction");
+            featv[featc++] = VDP_VIDEO_MIXER_FEATURE_NOISE_REDUCTION;
+        }
+    }
+
     err = vdp_video_mixer_query_feature_support(sys->vdp, sys->device,
                                        VDP_VIDEO_MIXER_FEATURE_SHARPNESS, &ok);
     if (err == VDP_STATUS_OK && ok == VDP_TRUE)
@@ -84,6 +96,45 @@ static VdpVideoMixer MixerCreate(filter_t *filter)
                 vdp_get_error_string(sys->vdp, err));
         mixer = VDP_INVALID_HANDLE;
     }
+
+    /* Set initial features and attributes */
+    VdpVideoMixerAttribute attrv[1];
+    const void *valv[1];
+    unsigned attrc = 0;
+
+    featc = 0;
+    if (noise > 0.f)
+    {
+        featv[featc++] = VDP_VIDEO_MIXER_FEATURE_NOISE_REDUCTION;
+
+        attrv[attrc] = VDP_VIDEO_MIXER_ATTRIBUTE_NOISE_REDUCTION_LEVEL;
+        valv[attrc] = &noise;
+        attrc++;
+    }
+
+    if (featc > 0)
+    {
+        VdpBool enablev[featc];
+
+        for (unsigned i = 0; i < featc; i++)
+            enablev[i] = VDP_TRUE;
+
+        err = vdp_video_mixer_set_feature_enables(sys->vdp, mixer,
+                                                  featc, featv, enablev);
+        if (err != VDP_STATUS_OK)
+            msg_Err(filter, "video %s %s failure: %s", "mixer", "features",
+                    vdp_get_error_string(sys->vdp, err));
+    }
+
+    if (attrc > 0)
+    {
+        err = vdp_video_mixer_set_attribute_values(sys->vdp, mixer,
+                                                   attrc, attrv, valv);
+        if (err != VDP_STATUS_OK)
+            msg_Err(filter, "video %s %s failure: %s", "mixer", "attributes",
+                    vdp_get_error_string(sys->vdp, err));
+    }
+
     return mixer;
 }
 
@@ -516,6 +567,10 @@ vlc_module_begin()
     set_category(CAT_VIDEO)
     set_subcategory(SUBCAT_VIDEO_VFILTER)
     set_callbacks(OutputOpen, OutputClose)
+
+    add_float_with_range("vdpau-noise-reduction", 0., 0., 1.,
+        N_("Noise reduction level"), N_("Noise reduction level"), true)
+
     add_submodule()
     set_callbacks(YCbCrOpen, YCbCrClose)
 vlc_module_end()



More information about the vlc-commits mailing list