[vlc-devel] [PATCH 42/42] vdpau: check for sharpening/blurring support

Rémi Denis-Courmont remi at remlab.net
Fri Jun 28 20:30:30 CEST 2013


---
 modules/hw/vdpau/chroma.c  | 36 +++++++++++++++++++++++++++++++++++-
 modules/hw/vdpau/sharpen.c | 23 +++++++++++++++++++++++
 2 files changed, 58 insertions(+), 1 deletion(-)

diff --git a/modules/hw/vdpau/chroma.c b/modules/hw/vdpau/chroma.c
index aac0053..d91376b 100644
--- a/modules/hw/vdpau/chroma.c
+++ b/modules/hw/vdpau/chroma.c
@@ -53,6 +53,26 @@ static VdpVideoMixer MixerCreate(filter_t *filter)
     VdpVideoMixer mixer;
     VdpStatus err;
 
+    /* Check for potentially useful features */
+    VdpVideoMixerFeature featv[] = {
+        VDP_VIDEO_MIXER_FEATURE_SHARPNESS,
+    };
+    unsigned featc = 0;
+
+    for (unsigned i = 0; i < sizeof (featv) / sizeof (featv[0]); i++)
+    {
+        VdpBool ok;
+
+        err = vdp_video_mixer_query_feature_support(sys->vdp, sys->device,
+                                                    featv[i], &ok);
+        if (err == VDP_STATUS_OK && ok == VDP_TRUE)
+        {
+            msg_Dbg(filter, "using video mixer feature %u", featv[i]);
+            featv[featc++] = featv[i];
+        }
+    }
+
+    /* Create the mixer */
     VdpVideoMixerParameter parms[3] = {
         VDP_VIDEO_MIXER_PARAMETER_VIDEO_SURFACE_WIDTH,
         VDP_VIDEO_MIXER_PARAMETER_VIDEO_SURFACE_HEIGHT,
@@ -62,7 +82,7 @@ static VdpVideoMixer MixerCreate(filter_t *filter)
     uint32_t height = filter->fmt_in.video.i_height;
     const void *values[3] = { &width, &height, &sys->chroma, };
 
-    err = vdp_video_mixer_create(sys->vdp, sys->device, 0, NULL,
+    err = vdp_video_mixer_create(sys->vdp, sys->device, featc, featv,
                                  3, parms, values, &mixer);
     if (err != VDP_STATUS_OK)
     {
@@ -290,6 +310,20 @@ static picture_t *MixerRender(filter_t *filter, picture_t *src)
 
     vlc_vdp_video_field_t *f = src->context;
 
+    /* Enable/Disable features */
+    const VdpVideoMixerFeature features[] = {
+        VDP_VIDEO_MIXER_FEATURE_SHARPNESS,
+    };
+    const VdpBool enables[] = {
+        f->sharpen != 0.f,
+    };
+
+    err = vdp_video_mixer_set_feature_enables(sys->vdp, sys->mixer,
+                  sizeof (features) / sizeof (features[0]), features, enables);
+    if (err != VDP_STATUS_OK)
+        msg_Err(filter, "video %s %s failure: %s", "mixer", "features",
+                vdp_get_error_string(sys->vdp, err));
+
     /* Configure mixer depending on upstream video filters */
     const VdpVideoMixerAttribute attrs[] = {
         VDP_VIDEO_MIXER_ATTRIBUTE_SHARPNESS_LEVEL,
diff --git a/modules/hw/vdpau/sharpen.c b/modules/hw/vdpau/sharpen.c
index 594c690..915dc90 100644
--- a/modules/hw/vdpau/sharpen.c
+++ b/modules/hw/vdpau/sharpen.c
@@ -83,6 +83,29 @@ static int Open(vlc_object_t *obj)
     if (!video_format_IsSimilar(&filter->fmt_in.video, &filter->fmt_out.video))
         return VLC_EGENERIC;
 
+    /* Check for sharpen support */
+    vdp_t *vdp;
+    VdpDevice device;
+    VdpStatus err;
+    VdpBool ok;
+
+    err = vdp_get_x11(NULL, -1, &vdp, &device);
+    if (err != VDP_STATUS_OK)
+        return VLC_EGENERIC; /* Weird. The decoder should be active... */
+
+    err = vdp_video_mixer_query_feature_support(vdp, device,
+                                       VDP_VIDEO_MIXER_FEATURE_SHARPNESS, &ok);
+    if (err != VDP_STATUS_OK)
+        ok = VDP_FALSE;
+    vdp_release_x11(vdp);
+
+    if (ok != VDP_TRUE)
+    {
+        msg_Err(filter, "sharpening/blurring not supported by VDPAU device");
+        return VLC_EGENERIC;
+    }
+
+    /* Initialization */
     filter_sys_t *sys = malloc(sizeof (*sys));
     if (unlikely(sys == NULL))
         return VLC_ENOMEM;
-- 
1.8.3.1




More information about the vlc-devel mailing list