[MPlayer-cvslog] r28673 - trunk/libvo/vo_vdpau.c

reimar subversion at mplayerhq.hu
Fri Feb 20 10:45:49 CET 2009


Author: reimar
Date: Fri Feb 20 10:45:48 2009
New Revision: 28673

Log:
Add support for VDPAU deinterlacing, pullup, denoise and sharpening.
Deinterlacing can not yet be toggled at runtime, and actually it does
not seem to work at all...

Modified:
   trunk/libvo/vo_vdpau.c

Modified: trunk/libvo/vo_vdpau.c
==============================================================================
--- trunk/libvo/vo_vdpau.c	Thu Feb 19 17:08:07 2009	(r28672)
+++ trunk/libvo/vo_vdpau.c	Fri Feb 20 10:45:48 2009	(r28673)
@@ -42,6 +42,7 @@
 #include "x11_common.h"
 #include "aspect.h"
 #include "sub.h"
+#include "subopt-helper.h"
 
 #include "libavcodec/vdpau.h"
 
@@ -111,6 +112,8 @@ static VdpOutputSurfaceDestroy          
 static VdpVideoMixerCreate               *vdp_video_mixer_create;
 static VdpVideoMixerDestroy              *vdp_video_mixer_destroy;
 static VdpVideoMixerRender               *vdp_video_mixer_render;
+static VdpVideoMixerSetFeatureEnables    *vdp_video_mixer_set_feature_enables;
+static VdpVideoMixerSetAttributeValues   *vdp_video_mixer_set_attribute_values;
 
 static VdpPresentationQueueTargetDestroy *vdp_presentation_queue_target_destroy;
 static VdpPresentationQueueCreate        *vdp_presentation_queue_create;
@@ -132,6 +135,10 @@ static VdpOutputSurface                 
 static int                                output_surface_width, output_surface_height;
 
 static VdpVideoMixer                      video_mixer;
+static int                                deint;
+static int                                pullup;
+static float                              denoise;
+static float                              sharpen;
 
 static VdpDecoder                         decoder;
 static int                                decoder_max_refs;
@@ -254,6 +261,10 @@ static int win_x11_init_vdpau_procs(void
         {VDP_FUNC_ID_VIDEO_MIXER_CREATE, &vdp_video_mixer_create},
         {VDP_FUNC_ID_VIDEO_MIXER_DESTROY,       &vdp_video_mixer_destroy},
         {VDP_FUNC_ID_VIDEO_MIXER_RENDER,        &vdp_video_mixer_render},
+        {VDP_FUNC_ID_VIDEO_MIXER_SET_FEATURE_ENABLES,
+                        &vdp_video_mixer_set_feature_enables},
+        {VDP_FUNC_ID_VIDEO_MIXER_SET_ATTRIBUTE_VALUES,
+                        &vdp_video_mixer_set_attribute_values},
         {VDP_FUNC_ID_PRESENTATION_QUEUE_TARGET_DESTROY,
                         &vdp_presentation_queue_target_destroy},
         {VDP_FUNC_ID_PRESENTATION_QUEUE_CREATE, &vdp_presentation_queue_create},
@@ -310,7 +321,16 @@ static int win_x11_init_vdpau_flip_queue
 
 static int create_vdp_mixer(VdpChromaType vdp_chroma_type) {
 #define VDP_NUM_MIXER_PARAMETER 3
+#define MAX_NUM_FEATURES 5
+    int i;
     VdpStatus vdp_st;
+    int feature_count = 0;
+    VdpVideoMixerFeature features[MAX_NUM_FEATURES];
+    VdpBool feature_enables[MAX_NUM_FEATURES];
+    static const denoise_attrib[] = {VDP_VIDEO_MIXER_ATTRIBUTE_NOISE_REDUCTION_LEVEL};
+    const void * const denoise_value[] = {&denoise};
+    static const sharpen_attrib[] = {VDP_VIDEO_MIXER_ATTRIBUTE_SHARPNESS_LEVEL};
+    const void * const sharpen_value[] = {&sharpen};
     static const VdpVideoMixerParameter parameters[VDP_NUM_MIXER_PARAMETER] = {
         VDP_VIDEO_MIXER_PARAMETER_VIDEO_SURFACE_WIDTH,
         VDP_VIDEO_MIXER_PARAMETER_VIDEO_SURFACE_HEIGHT,
@@ -321,13 +341,31 @@ static int create_vdp_mixer(VdpChromaTyp
         &vid_height,
         &vdp_chroma_type
     };
+    if (deint == 1)
+        features[feature_count++] = VDP_VIDEO_MIXER_FEATURE_DEINTERLACE_TEMPORAL;
+    if (deint == 2)
+        features[feature_count++] = VDP_VIDEO_MIXER_FEATURE_DEINTERLACE_TEMPORAL_SPATIAL;
+    if (pullup)
+        features[feature_count++] = VDP_VIDEO_MIXER_FEATURE_INVERSE_TELECINE;
+    if (denoise)
+        features[feature_count++] = VDP_VIDEO_MIXER_FEATURE_NOISE_REDUCTION;
+    if (sharpen)
+        features[feature_count++] = VDP_VIDEO_MIXER_FEATURE_SHARPNESS;
 
-    vdp_st = vdp_video_mixer_create(vdp_device, 0, 0,
+    vdp_st = vdp_video_mixer_create(vdp_device, feature_count, features,
                                     VDP_NUM_MIXER_PARAMETER,
                                     parameters, parameter_values,
                                     &video_mixer);
     CHECK_ST_ERROR("Error when calling vdp_video_mixer_create")
 
+    for (i = 0; i < feature_count; i++) feature_enables[i] = VDP_TRUE;
+    if (feature_count)
+        vdp_video_mixer_set_feature_enables(video_mixer, feature_count, features, feature_enables);
+    if (denoise)
+        vdp_video_mixer_set_attribute_values(video_mixer, 1, denoise_attrib, denoise_value);
+    if (sharpen)
+        vdp_video_mixer_set_attribute_values(video_mixer, 1, sharpen_attrib, sharpen_value);
+
     return 0;
 }
 
@@ -711,15 +749,43 @@ static void uninit(void)
     dlclose(vdpau_lib_handle);
 }
 
+static opt_t subopts[] = {
+    {"deint",   OPT_ARG_INT,   &deint,   (opt_test_f)int_non_neg},
+    {"pullup",  OPT_ARG_BOOL,  &pullup,  NULL},
+    {"denoise", OPT_ARG_FLOAT, &denoise, NULL},
+    {"sharpen", OPT_ARG_FLOAT, &sharpen, NULL},
+    {NULL}
+};
+
+static const char help_msg[] =
+    "\n-vo vdpau command line help:\n"
+    "Example: mplayer -vo vdpau:deint=2\n"
+    "\nOptions:\n"
+    "  deint\n"
+    "    0: no deinterlacing\n"
+    "    1: temporal deinterlacing\n"
+    "    2: temporal-spatial deinterlacing\n"
+    "  pullup\n"
+    "    Try to apply inverse-telecine\n"
+    "  denoise\n"
+    "    Apply denoising, argument is strength from 0.0 to 1.0\n"
+    "  sharpen\n"
+    "    Apply sharpening or softening, argument is strength from -1.0 to 1.0\n"
+    ;
+
 static int preinit(const char *arg)
 {
     int i;
     static const char *vdpaulibrary = "libvdpau.so.1";
     static const char *vdpau_device_create = "vdp_device_create_x11";
 
-    if (arg) {
-        mp_msg(MSGT_VO, MSGL_ERR, "[vdpau] Unknown subdevice: %s\n", arg);
-        return ENOSYS;
+    deint = 0;
+    pullup = 0;
+    denoise = 0;
+    sharpen = 0;
+    if (subopt_parse(arg, subopts) != 0) {
+        mp_msg(MSGT_VO, MSGL_FATAL, help_msg);
+        return -1;
     }
 
     vdpau_lib_handle = dlopen(vdpaulibrary, RTLD_LAZY);



More information about the MPlayer-cvslog mailing list