[Mesa-dev] [PATCH v2 2/2] st/vdapu: use lanczos filter for scaling v2
Nayan Deshmukh
nayan26deshmukh at gmail.com
Mon Jul 18 19:55:53 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 | 116 ++++++++++++++++-------
src/gallium/state_trackers/vdpau/query.c | 8 ++
src/gallium/state_trackers/vdpau/vdpau_private.h | 7 ++
3 files changed, 97 insertions(+), 34 deletions(-)
diff --git a/src/gallium/state_trackers/vdpau/mixer.c b/src/gallium/state_trackers/vdpau/mixer.c
index cb0ef03..87822c8 100644
--- 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,20 @@ vlVdpVideoMixerSetFeatureEnables(VdpVideoMixer mixer,
vlVdpVideoMixerUpdateBicubicFilter(vmixer);
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.enabled = feature_enables[i];
+ vmixer->lanczos.size = features[i] -
+ VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L1 + 1;
+ vlVdpVideoMixerUpdateLanczosFilter(vmixer);
+ break;
+
default:
pipe_mutex_unlock(vmixer->device->mutex);
return VDP_STATUS_INVALID_VIDEO_MIXER_FEATURE;
@@ -694,14 +739,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 +758,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
index e69c9b1..fbde747 100644
--- 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
index bcd4bb1..e82d343 100644
--- 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