[Mesa-dev] [PATCH 2/2] st/vdapu: use lanczos filter for scaling v4
Nayan Deshmukh
nayan26deshmukh at gmail.com
Wed Aug 31 09:56:41 UTC 2016
HIGH_QUALITY_SCALING_L2 to HIGH_QUALTIY_SCALING_L7
uses lanczos filter with number representing the size
of the sinc window.
v3: avoid L8 and L9 to allow for other scaling algrithms
v4 (chk): rebased on master
Signed-off-by: Nayan Deshmukh <nayan26deshmukh at gmail.com>
---
src/gallium/state_trackers/vdpau/mixer.c | 105 +++++++++++++++++------
src/gallium/state_trackers/vdpau/query.c | 8 ++
src/gallium/state_trackers/vdpau/vdpau_private.h | 7 ++
3 files changed, 92 insertions(+), 28 deletions(-)
diff --git a/src/gallium/state_trackers/vdpau/mixer.c b/src/gallium/state_trackers/vdpau/mixer.c
index c205427..84fd923 100644
--- a/src/gallium/state_trackers/vdpau/mixer.c
+++ b/src/gallium/state_trackers/vdpau/mixer.c
@@ -82,12 +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:
@@ -112,6 +106,15 @@ 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:
+ 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);
@@ -337,7 +344,8 @@ VdpStatus vlVdpVideoMixerRender(VdpVideoMixer mixer,
}
vl_compositor_set_buffer_layer(&vmixer->cstate, compositor, layer, video_buffer, prect, NULL, deinterlace);
- if (vmixer->bicubic.filter || vmixer->sharpness.filter || vmixer->noise_reduction.filter) {
+ if (vmixer->bicubic.filter || vmixer->sharpness.filter ||
+ vmixer->noise_reduction.filter || vmixer->lanczos.filter) {
pipe = vmixer->device->context;
memset(&res_tmpl, 0, sizeof(res_tmpl));
@@ -348,7 +356,7 @@ VdpStatus vlVdpVideoMixerRender(VdpVideoMixer mixer,
res_tmpl.bind = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET;
res_tmpl.usage = PIPE_USAGE_DEFAULT;
- if (!vmixer->bicubic.filter) {
+ if (!vmixer->bicubic.filter && !vmixer->lanczos.filter) {
res_tmpl.width0 = dst->surface->width;
res_tmpl.height0 = dst->surface->height;
} else {
@@ -373,7 +381,7 @@ VdpStatus vlVdpVideoMixerRender(VdpVideoMixer mixer,
dirty_area = dst->dirty_area;
}
- if (!vmixer->bicubic.filter) {
+ if (!vmixer->bicubic.filter && !vmixer->lanczos.filter) {
vl_compositor_set_layer_dst_area(&vmixer->cstate, layer++, RectToPipe(destination_video_rect, &rect));
vl_compositor_set_dst_clip(&vmixer->cstate, RectToPipe(destination_rect, &clip));
}
@@ -394,7 +402,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);
@@ -447,6 +455,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);
@@ -575,6 +589,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
@@ -597,12 +634,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:
@@ -629,6 +660,15 @@ 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:
+ feature_supports[i] = vmixer->lanczos.supported;
+ break;
+
default:
return VDP_STATUS_INVALID_VIDEO_MIXER_FEATURE;
}
@@ -661,12 +701,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:
@@ -699,6 +733,18 @@ 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:
+ 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;
@@ -733,12 +779,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:
@@ -760,6 +800,15 @@ 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:
+ 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