[Mesa-dev] [PATCH 2/2] st/vdapu: use lanczos filter for scaling

Nayan Deshmukh nayan26deshmukh at gmail.com
Thu Jul 14 20:58:59 UTC 2016


HIGH_QUALITY_SCALING_L2 to HIGH_QUALTIY_SCALING_L9
uses lanczos filter with number representing the size
of the sinc window.

Signed-off-by: Nayan Deshmukh <nayan26deshmukh at gmail.com>
---
 src/gallium/state_trackers/vdpau/mixer.c         | 150 ++++++++++++++++++-----
 src/gallium/state_trackers/vdpau/query.c         |   8 ++
 src/gallium/state_trackers/vdpau/vdpau_private.h |   7 ++
 3 files changed, 131 insertions(+), 34 deletions(-)
 mode change 100644 => 100755 src/gallium/state_trackers/vdpau/mixer.c
 mode change 100644 => 100755 src/gallium/state_trackers/vdpau/query.c
 mode change 100644 => 100755 src/gallium/state_trackers/vdpau/vdpau_private.h

diff --git a/src/gallium/state_trackers/vdpau/mixer.c b/src/gallium/state_trackers/vdpau/mixer.c
old mode 100644
new mode 100755
index cb0ef03..744c355
--- a/src/gallium/state_trackers/vdpau/mixer.c
+++ b/src/gallium/state_trackers/vdpau/mixer.c
@@ -82,14 +82,6 @@ vlVdpVideoMixerCreate(VdpDevice device,
       switch (features[i]) {
       /* they are valid, but we doesn't support them */
       case VDP_VIDEO_MIXER_FEATURE_DEINTERLACE_TEMPORAL_SPATIAL:
-      case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L2:
-      case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L3:
-      case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L4:
-      case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L5:
-      case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L6:
-      case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L7:
-      case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L8:
-      case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L9:
       case VDP_VIDEO_MIXER_FEATURE_INVERSE_TELECINE:
          break;
 
@@ -112,6 +104,17 @@ vlVdpVideoMixerCreate(VdpDevice device,
       case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L1:
          vmixer->bicubic.supported = true;
          break;
+
+      case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L2:
+      case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L3:
+      case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L4:
+      case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L5:
+      case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L6:
+      case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L7:
+      case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L8:
+      case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L9:
+         vmixer->lanczos.supported = true;
+         break;
       default: goto no_params;
       }
    }
@@ -209,6 +212,10 @@ vlVdpVideoMixerDestroy(VdpVideoMixer mixer)
       vl_bicubic_filter_cleanup(vmixer->bicubic.filter);
       FREE(vmixer->bicubic.filter);
    }
+   if (vmixer->lanczos.filter) {
+      vl_lanczos_filter_cleanup(vmixer->lanczos.filter);
+      FREE(vmixer->lanczos.filter);
+   }
    pipe_mutex_unlock(vmixer->device->mutex);
    DeviceReference(&vmixer->device, NULL);
 
@@ -335,7 +342,7 @@ VdpStatus vlVdpVideoMixerRender(VdpVideoMixer mixer,
    }
    vl_compositor_set_buffer_layer(&vmixer->cstate, compositor, layer, video_buffer, prect, NULL, deinterlace);
 
-   if(vmixer->bicubic.filter) {
+   if(vmixer->bicubic.filter || vmixer->lanczos.filter) {
       struct pipe_context *pipe;
       struct pipe_resource res_tmpl, *res;
       struct pipe_sampler_view sv_templ;
@@ -389,7 +396,7 @@ VdpStatus vlVdpVideoMixerRender(VdpVideoMixer mixer,
       ++layers;
    }
 
-   if (!vmixer->noise_reduction.filter && !vmixer->sharpness.filter && !vmixer->bicubic.filter)
+   if (!vmixer->noise_reduction.filter && !vmixer->sharpness.filter && !vmixer->bicubic.filter && !vmixer->lanczos.filter)
       vlVdpSave4DelayedRendering(vmixer->device, destination_surface, &vmixer->cstate);
    else {
       vl_compositor_render(&vmixer->cstate, compositor, surface, &dirty_area, true);
@@ -408,6 +415,12 @@ VdpStatus vlVdpVideoMixerRender(VdpVideoMixer mixer,
                                  RectToPipe(destination_video_rect, &rect),
                                  RectToPipe(destination_rect, &clip));
 
+      if (vmixer->lanczos.filter)
+         vl_lanczos_filter_render(vmixer->lanczos.filter,
+                                  sampler_view, dst->surface,
+                                  RectToPipe(destination_video_rect, &rect),
+                                  RectToPipe(destination_rect, &clip));
+
       if(surface != dst->surface) {
          pipe_sampler_view_reference(&sampler_view, NULL);
          pipe_surface_reference(&surface, NULL);
@@ -536,6 +549,29 @@ vlVdpVideoMixerUpdateBicubicFilter(vlVdpVideoMixer *vmixer)
 }
 
 /**
+ * Update the lanczos filter
+ */
+static void
+vlVdpVideoMixerUpdateLanczosFilter(vlVdpVideoMixer *vmixer)
+{
+   assert(vmixer);
+
+   /* if present remove the old filter first */
+   if (vmixer->lanczos.filter) {
+      vl_lanczos_filter_cleanup(vmixer->lanczos.filter);
+      FREE(vmixer->lanczos.filter);
+      vmixer->lanczos.filter = NULL;
+   }
+   /* and create a new filter as needed */
+   if (vmixer->lanczos.enabled) {
+      vmixer->lanczos.filter = MALLOC(sizeof(struct vl_lanczos_filter));
+      vl_lanczos_filter_init(vmixer->lanczos.filter, vmixer->device->context,
+                             vmixer->lanczos.size, vmixer->video_width,
+                             vmixer->video_height);
+   }
+}
+
+/**
  * Retrieve whether features were requested at creation time.
  */
 VdpStatus
@@ -558,14 +594,6 @@ vlVdpVideoMixerGetFeatureSupport(VdpVideoMixer mixer,
       switch (features[i]) {
       /* they are valid, but we doesn't support them */
       case VDP_VIDEO_MIXER_FEATURE_DEINTERLACE_TEMPORAL_SPATIAL:
-      case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L2:
-      case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L3:
-      case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L4:
-      case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L5:
-      case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L6:
-      case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L7:
-      case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L8:
-      case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L9:
       case VDP_VIDEO_MIXER_FEATURE_INVERSE_TELECINE:
          feature_supports[i] = false;
          break;
@@ -590,6 +618,17 @@ vlVdpVideoMixerGetFeatureSupport(VdpVideoMixer mixer,
          feature_supports[i] = vmixer->bicubic.supported;
          break;
 
+      case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L2:
+      case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L3:
+      case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L4:
+      case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L5:
+      case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L6:
+      case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L7:
+      case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L8:
+      case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L9:
+        feature_supports[i] = vmixer->lanczos.supported;
+         break;
+
       default:
          return VDP_STATUS_INVALID_VIDEO_MIXER_FEATURE;
       }
@@ -622,14 +661,6 @@ vlVdpVideoMixerSetFeatureEnables(VdpVideoMixer mixer,
       switch (features[i]) {
       /* they are valid, but we doesn't support them */
       case VDP_VIDEO_MIXER_FEATURE_DEINTERLACE_TEMPORAL_SPATIAL:
-      case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L2:
-      case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L3:
-      case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L4:
-      case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L5:
-      case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L6:
-      case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L7:
-      case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L8:
-      case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L9:
       case VDP_VIDEO_MIXER_FEATURE_INVERSE_TELECINE:
          break;
 
@@ -660,6 +691,54 @@ vlVdpVideoMixerSetFeatureEnables(VdpVideoMixer mixer,
          vlVdpVideoMixerUpdateBicubicFilter(vmixer);
          break;
 
+      case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L2:
+         vmixer->lanczos.enabled = feature_enables[i];
+         vmixer->lanczos.size = 2;
+         vlVdpVideoMixerUpdateLanczosFilter(vmixer);
+         break;
+
+      case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L3:
+         vmixer->lanczos.enabled = feature_enables[i];
+         vmixer->lanczos.size = 3;
+         vlVdpVideoMixerUpdateLanczosFilter(vmixer);
+         break;
+
+      case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L4:
+         vmixer->lanczos.enabled = feature_enables[i];
+         vmixer->lanczos.size = 4;
+         vlVdpVideoMixerUpdateLanczosFilter(vmixer);
+         break;
+
+      case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L5:
+         vmixer->lanczos.enabled = feature_enables[i];
+         vmixer->lanczos.size = 5;
+         vlVdpVideoMixerUpdateLanczosFilter(vmixer);
+         break;
+
+      case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L6:
+         vmixer->lanczos.enabled = feature_enables[i];
+         vmixer->lanczos.size = 6;
+         vlVdpVideoMixerUpdateLanczosFilter(vmixer);
+         break;
+
+      case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L7:
+         vmixer->lanczos.enabled = feature_enables[i];
+         vmixer->lanczos.size = 7;
+         vlVdpVideoMixerUpdateLanczosFilter(vmixer);
+         break;
+
+      case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L8:
+         vmixer->lanczos.enabled = feature_enables[i];
+         vmixer->lanczos.size = 8;
+         vlVdpVideoMixerUpdateLanczosFilter(vmixer);
+         break;
+
+      case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L9:
+         vmixer->lanczos.enabled = feature_enables[i];
+         vmixer->lanczos.size = 9;
+         vlVdpVideoMixerUpdateLanczosFilter(vmixer);
+         break;
+
       default:
          pipe_mutex_unlock(vmixer->device->mutex);
          return VDP_STATUS_INVALID_VIDEO_MIXER_FEATURE;
@@ -694,14 +773,6 @@ vlVdpVideoMixerGetFeatureEnables(VdpVideoMixer mixer,
       /* they are valid, but we doesn't support them */
       case VDP_VIDEO_MIXER_FEATURE_DEINTERLACE_TEMPORAL:
       case VDP_VIDEO_MIXER_FEATURE_DEINTERLACE_TEMPORAL_SPATIAL:
-      case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L2:
-      case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L3:
-      case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L4:
-      case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L5:
-      case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L6:
-      case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L7:
-      case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L8:
-      case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L9:
       case VDP_VIDEO_MIXER_FEATURE_INVERSE_TELECINE:
          break;
 
@@ -721,6 +792,17 @@ vlVdpVideoMixerGetFeatureEnables(VdpVideoMixer mixer,
          feature_enables[i] = vmixer->bicubic.enabled;
          break;
 
+      case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L2:
+      case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L3:
+      case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L4:
+      case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L5:
+      case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L6:
+      case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L7:
+      case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L8:
+      case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L9:
+        feature_enables[i] = vmixer->lanczos.enabled;
+         break;
+
       default:
          return VDP_STATUS_INVALID_VIDEO_MIXER_FEATURE;
       }
diff --git a/src/gallium/state_trackers/vdpau/query.c b/src/gallium/state_trackers/vdpau/query.c
old mode 100644
new mode 100755
index e69c9b1..fbde747
--- a/src/gallium/state_trackers/vdpau/query.c
+++ b/src/gallium/state_trackers/vdpau/query.c
@@ -472,6 +472,14 @@ vlVdpVideoMixerQueryFeatureSupport(VdpDevice device, VdpVideoMixerFeature featur
    case VDP_VIDEO_MIXER_FEATURE_DEINTERLACE_TEMPORAL:
    case VDP_VIDEO_MIXER_FEATURE_LUMA_KEY:
    case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L1:
+   case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L2:
+   case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L3:
+   case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L4:
+   case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L5:
+   case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L6:
+   case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L7:
+   case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L8:
+   case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L9:
       *is_supported = VDP_TRUE;
       break;
    default:
diff --git a/src/gallium/state_trackers/vdpau/vdpau_private.h b/src/gallium/state_trackers/vdpau/vdpau_private.h
old mode 100644
new mode 100755
index bcd4bb1..e82d343
--- a/src/gallium/state_trackers/vdpau/vdpau_private.h
+++ b/src/gallium/state_trackers/vdpau/vdpau_private.h
@@ -49,6 +49,7 @@
 #include "vl/vl_compositor.h"
 #include "vl/vl_csc.h"
 #include "vl/vl_deint_filter.h"
+#include "vl/vl_lanczos_filter.h"
 #include "vl/vl_matrix_filter.h"
 #include "vl/vl_median_filter.h"
 #include "vl/vl_winsys.h"
@@ -380,6 +381,12 @@ typedef struct
 
    struct {
       bool supported, enabled;
+      unsigned size;
+      struct vl_lanczos_filter *filter;
+   } lanczos;
+
+   struct {
+      bool supported, enabled;
       unsigned level;
       struct vl_median_filter *filter;
    } noise_reduction;
-- 
2.7.4



More information about the mesa-dev mailing list