[Mesa-dev] [RFC PATCH 5/7] st/vdpau: Rework the state tracker for the new compositor abstraction

Thomas Hellstrom thellstrom at vmware.com
Thu Mar 2 20:00:09 UTC 2017


Signed-off-by: Thomas Hellstrom <thellstrom at vmware.com>
Reviewed-by: Brian Paul <brianp at vmware.com>
---
 src/gallium/state_trackers/vdpau/device.c        |  11 +-
 src/gallium/state_trackers/vdpau/mixer.c         | 522 ++++++++---------------
 src/gallium/state_trackers/vdpau/output.c        | 114 ++---
 src/gallium/state_trackers/vdpau/presentation.c  |  23 +-
 src/gallium/state_trackers/vdpau/vdpau_private.h |  54 +--
 5 files changed, 261 insertions(+), 463 deletions(-)

diff --git a/src/gallium/state_trackers/vdpau/device.c b/src/gallium/state_trackers/vdpau/device.c
index 4f4ffdf..8bcc5bf 100644
--- a/src/gallium/state_trackers/vdpau/device.c
+++ b/src/gallium/state_trackers/vdpau/device.c
@@ -32,6 +32,8 @@
 #include "util/u_format.h"
 #include "util/u_sampler.h"
 
+#include "vl/vl_postproc.h"
+
 #include "vdpau_private.h"
 
 /**
@@ -128,9 +130,10 @@ vdp_imp_device_create_x11(Display *display, int screen, VdpDevice *device,
       goto no_handle;
    }
 
-   if (!vl_compositor_init(&dev->compositor, dev->context)) {
-       ret = VDP_STATUS_ERROR;
-       goto no_compositor;
+   dev->compositor = vl_pproc_create(dev->context, NULL);
+   if (!dev->compositor) {
+      ret = VDP_STATUS_RESOURCES;
+      goto no_compositor;
    }
 
    pipe_mutex_init(dev->mutex);
@@ -234,7 +237,7 @@ void
 vlVdpDeviceFree(vlVdpDevice *dev)
 {
    pipe_mutex_destroy(dev->mutex);
-   vl_compositor_cleanup(&dev->compositor);
+   dev->compositor->destroy(dev->compositor);
    pipe_sampler_view_reference(&dev->dummy_sv, NULL);
    dev->context->destroy(dev->context);
    dev->vscreen->destroy(dev->vscreen);
diff --git a/src/gallium/state_trackers/vdpau/mixer.c b/src/gallium/state_trackers/vdpau/mixer.c
index 37a6fcd..58e6404 100644
--- a/src/gallium/state_trackers/vdpau/mixer.c
+++ b/src/gallium/state_trackers/vdpau/mixer.c
@@ -31,6 +31,7 @@
 #include "util/u_debug.h"
 
 #include "vl/vl_csc.h"
+#include "vl/vl_compositor.h"
 
 #include "vdpau_private.h"
 
@@ -51,6 +52,7 @@ vlVdpVideoMixerCreate(VdpDevice device,
    struct pipe_screen *screen;
    uint32_t max_2d_texture_level;
    unsigned max_size, i;
+   struct util_video_compositor *comp;
 
    vlVdpDevice *dev = vlGetDataHTAB(device);
    if (!dev)
@@ -59,20 +61,23 @@ vlVdpVideoMixerCreate(VdpDevice device,
 
    vmixer = CALLOC(1, sizeof(vlVdpVideoMixer));
    if (!vmixer)
-      return VDP_STATUS_RESOURCES;
+      return VDP_STATUS_ERROR;
 
    DeviceReference(&vmixer->device, dev);
+   comp = dev->compositor;
 
    pipe_mutex_lock(dev->mutex);
 
-   if (!vl_compositor_init_state(&vmixer->cstate, dev->context)) {
-      ret = VDP_STATUS_ERROR;
+   vmixer->cctx = dev->compositor->context_create(dev->compositor);
+   if (!vmixer->cctx) {
+      ret = VDP_STATUS_RESOURCES;
       goto no_compositor_state;
    }
 
    vl_csc_get_matrix(VL_CSC_COLOR_STANDARD_BT_601, NULL, true, &vmixer->csc);
    if (!debug_get_bool_option("G3DVL_NO_CSC", FALSE)) {
-      if (!vl_compositor_set_csc_matrix(&vmixer->cstate, (const vl_csc_matrix *)&vmixer->csc, 1.0f, 0.0f)) {
+      if (!vmixer->cctx->set_csc_matrix
+          (vmixer->cctx, (const util_video_compositor_csc_matrix *)&vmixer->csc)) {
          ret = VDP_STATUS_ERROR;
          goto err_csc_matrix;
       }
@@ -89,36 +94,45 @@ 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;
 
       case VDP_VIDEO_MIXER_FEATURE_DEINTERLACE_TEMPORAL:
-         vmixer->deint.supported = true;
+         vmixer->deint_supported =
+            !!comp->buffer_filter_supported(comp, UTIL_VIDEO_FILTER_DEINT_TEMPORAL);
          break;
 
       case VDP_VIDEO_MIXER_FEATURE_SHARPNESS:
-         vmixer->sharpness.supported = true;
+         vmixer->sharpness_supported =
+            !!comp->buffer_filter_supported(comp, UTIL_VIDEO_FILTER_SHARPNESS);
          break;
 
       case VDP_VIDEO_MIXER_FEATURE_NOISE_REDUCTION:
-         vmixer->noise_reduction.supported = true;
+         vmixer->noise_red_supported =
+            !!comp->buffer_filter_supported(comp, UTIL_VIDEO_FILTER_NOISE_REDUCTION);
          break;
 
       case VDP_VIDEO_MIXER_FEATURE_LUMA_KEY:
-         vmixer->luma_key.supported = true;
+         vmixer->luma_key_supported =
+            !!comp->buffer_filter_supported(comp, UTIL_VIDEO_FILTER_LUMA_KEY);
          break;
 
       case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L1:
-         vmixer->bicubic.supported = true;
+      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:
+      {
+         unsigned j = features[i] -
+            VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L1;
+         vmixer->hq_supported[j] =
+            (comp->buffer_filter_supported(comp, UTIL_VIDEO_FILTER_HQ_SCALING) > j);
          break;
+      }
       default: goto no_params;
       }
    }
@@ -160,6 +174,11 @@ vlVdpVideoMixerCreate(VdpDevice device,
                 vmixer->video_height, max_size);
       goto no_params;
    }
+   vmixer->noise_reduction.filter.ftype = UTIL_VIDEO_FILTER_NOISE_REDUCTION;
+   vmixer->sharpness.filter.ftype = UTIL_VIDEO_FILTER_SHARPNESS;
+   vmixer->hq.filter.ftype = UTIL_VIDEO_FILTER_HQ_SCALING;
+   vmixer->deint.filter.ftype = UTIL_VIDEO_FILTER_DEINT_TEMPORAL;
+   vmixer->luma_key.filter.ftype = UTIL_VIDEO_FILTER_LUMA_KEY;
    vmixer->luma_key.luma_min = 1.0f;
    vmixer->luma_key.luma_max = 0.0f;
    pipe_mutex_unlock(dev->mutex);
@@ -171,7 +190,7 @@ no_params:
 
 no_handle:
 err_csc_matrix:
-   vl_compositor_cleanup_state(&vmixer->cstate);
+   vmixer->cctx->destroy(vmixer->cctx);
 no_compositor_state:
    pipe_mutex_unlock(dev->mutex);
    DeviceReference(&vmixer->device, NULL);
@@ -195,27 +214,7 @@ vlVdpVideoMixerDestroy(VdpVideoMixer mixer)
 
    vlRemoveDataHTAB(mixer);
 
-   vl_compositor_cleanup_state(&vmixer->cstate);
-
-   if (vmixer->deint.filter) {
-      vl_deint_filter_cleanup(vmixer->deint.filter);
-      FREE(vmixer->deint.filter);
-   }
-
-   if (vmixer->noise_reduction.filter) {
-      vl_median_filter_cleanup(vmixer->noise_reduction.filter);
-      FREE(vmixer->noise_reduction.filter);
-   }
-
-   if (vmixer->sharpness.filter) {
-      vl_matrix_filter_cleanup(vmixer->sharpness.filter);
-      FREE(vmixer->sharpness.filter);
-   }
-
-   if (vmixer->bicubic.filter) {
-      vl_bicubic_filter_cleanup(vmixer->bicubic.filter);
-      FREE(vmixer->bicubic.filter);
-   }
+   vmixer->cctx->destroy(vmixer->cctx);
    pipe_mutex_unlock(vmixer->device->mutex);
    DeviceReference(&vmixer->device, NULL);
 
@@ -243,26 +242,23 @@ VdpStatus vlVdpVideoMixerRender(VdpVideoMixer mixer,
                                 uint32_t layer_count,
                                 VdpLayer const *layers)
 {
-   enum vl_compositor_deinterlace deinterlace;
-   struct u_rect rect, clip, *prect, dirty_area;
+   enum util_video_compositor_deinterlace deinterlace;
+   struct u_rect rect, clip, *prect;
    unsigned i, layer = 0;
    struct pipe_video_buffer *video_buffer;
-   struct pipe_sampler_view *sampler_view, sv_templ;
-   struct pipe_surface *surface, surf_templ;
-   struct pipe_context *pipe = NULL;
-   struct pipe_resource res_tmpl, *res;
-
    vlVdpVideoMixer *vmixer;
    vlVdpSurface *surf;
    vlVdpOutputSurface *dst, *bg = NULL;
+   struct pipe_video_buffer *past[3];
+   struct pipe_video_buffer *future[3];
 
-   struct vl_compositor *compositor;
+   struct util_video_compositor_context *cctx;
 
    vmixer = vlGetDataHTAB(mixer);
    if (!vmixer)
       return VDP_STATUS_INVALID_HANDLE;
 
-   compositor = &vmixer->device->compositor;
+   cctx = vmixer->cctx;
 
    surf = vlGetDataHTAB(video_surface_current);
    if (!surf)
@@ -292,23 +288,23 @@ VdpStatus vlVdpVideoMixerRender(VdpVideoMixer mixer,
 
    pipe_mutex_lock(vmixer->device->mutex);
 
-   vl_compositor_clear_layers(&vmixer->cstate);
+   cctx->clear_layers(cctx);
 
    if (bg)
-      vl_compositor_set_rgba_layer(&vmixer->cstate, compositor, layer++, bg->sampler_view,
-                                   RectToPipe(background_source_rect, &rect), NULL, NULL);
+      cctx->set_rgba_layer(cctx, layer++, bg->sampler_view,
+                           RectToPipe(background_source_rect, &rect), NULL, NULL);
 
    switch (current_picture_structure) {
    case VDP_VIDEO_MIXER_PICTURE_STRUCTURE_TOP_FIELD:
-      deinterlace = VL_COMPOSITOR_BOB_TOP;
+      deinterlace = UTIL_VIDEO_COMPOSITOR_BOB_TOP;
       break;
 
    case VDP_VIDEO_MIXER_PICTURE_STRUCTURE_BOTTOM_FIELD:
-      deinterlace = VL_COMPOSITOR_BOB_BOTTOM;
+      deinterlace = UTIL_VIDEO_COMPOSITOR_BOB_BOTTOM;
       break;
 
    case VDP_VIDEO_MIXER_PICTURE_STRUCTURE_FRAME:
-      deinterlace = VL_COMPOSITOR_WEAVE;
+      deinterlace = UTIL_VIDEO_COMPOSITOR_WEAVE;
       break;
 
    default:
@@ -316,21 +312,14 @@ VdpStatus vlVdpVideoMixerRender(VdpVideoMixer mixer,
       return VDP_STATUS_INVALID_VIDEO_MIXER_PICTURE_STRUCTURE;
    }
 
-   if (deinterlace != VL_COMPOSITOR_WEAVE && vmixer->deint.enabled &&
-       video_surface_past_count > 1 && video_surface_future_count > 0) {
-      vlVdpSurface *prevprev = vlGetDataHTAB(video_surface_past[1]);
-      vlVdpSurface *prev = vlGetDataHTAB(video_surface_past[0]);
-      vlVdpSurface *next = vlGetDataHTAB(video_surface_future[0]);
-      if (prevprev && prev && next &&
-          vl_deint_filter_check_buffers(vmixer->deint.filter,
-          prevprev->video_buffer, prev->video_buffer, surf->video_buffer, next->video_buffer)) {
-         vl_deint_filter_render(vmixer->deint.filter, prevprev->video_buffer,
-                                prev->video_buffer, surf->video_buffer,
-                                next->video_buffer,
-                                deinterlace == VL_COMPOSITOR_BOB_BOTTOM);
-         deinterlace = VL_COMPOSITOR_WEAVE;
-         video_buffer = vmixer->deint.filter->video_buffer;
-      }
+   for (i = 0; i < 3 && i < video_surface_past_count; ++i) {
+      vlVdpSurface *tmp = vlGetDataHTAB(video_surface_past[i]);
+      past[i] = (tmp != NULL) ? tmp->video_buffer : NULL;
+   }
+
+   for (i = 0; i < 3 && i < video_surface_future_count; ++i) {
+      vlVdpSurface *tmp = vlGetDataHTAB(video_surface_future[i]);
+      future[i] = (tmp != NULL) ? tmp->video_buffer : NULL;
    }
 
    prect = RectToPipe(video_source_rect, &rect);
@@ -341,48 +330,10 @@ VdpStatus vlVdpVideoMixerRender(VdpVideoMixer mixer,
       rect.y1 = surf->templat.height;
       prect = ▭
    }
-   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) {
-      pipe = vmixer->device->context;
-      memset(&res_tmpl, 0, sizeof(res_tmpl));
-
-      res_tmpl.target = PIPE_TEXTURE_2D;
-      res_tmpl.format = dst->sampler_view->format;
-      res_tmpl.depth0 = 1;
-      res_tmpl.array_size = 1;
-      res_tmpl.bind = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET;
-      res_tmpl.usage = PIPE_USAGE_DEFAULT;
-
-      if (!vmixer->bicubic.filter) {
-         res_tmpl.width0 = dst->surface->width;
-         res_tmpl.height0 = dst->surface->height;
-      } else {
-         res_tmpl.width0 = surf->templat.width;
-         res_tmpl.height0 = surf->templat.height;
-      }
-
-      res = pipe->screen->resource_create(pipe->screen, &res_tmpl);
-
-      vlVdpDefaultSamplerViewTemplate(&sv_templ, res);
-      sampler_view = pipe->create_sampler_view(pipe, res, &sv_templ);
-
-      memset(&surf_templ, 0, sizeof(surf_templ));
-      surf_templ.format = res->format;
-      surface = pipe->create_surface(pipe, res, &surf_templ);
-
-      vl_compositor_reset_dirty_area(&dirty_area);
-      pipe_resource_reference(&res, NULL);
-   } else {
-      surface = dst->surface;
-      sampler_view = dst->sampler_view;
-      dirty_area = dst->dirty_area;
-   }
-
-   if (!vmixer->bicubic.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));
-   }
+   cctx->set_buffer_layer(cctx, layer, video_buffer, prect, NULL, deinterlace);
+   cctx->set_layer_dst_area(cctx, layer++, RectToPipe(destination_video_rect,
+                                                      &rect));
+   cctx->set_dst_clip(cctx, RectToPipe(destination_rect, &clip));
 
    for (i = 0; i < layer_count; ++i) {
       vlVdpOutputSurface *src = vlGetDataHTAB(layers->source_surface);
@@ -393,189 +344,21 @@ VdpStatus vlVdpVideoMixerRender(VdpVideoMixer mixer,
 
       assert(layers->struct_version == VDP_LAYER_VERSION);
 
-      vl_compositor_set_rgba_layer(&vmixer->cstate, compositor, layer, src->sampler_view,
-                                   RectToPipe(layers->source_rect, &rect), NULL, NULL);
-      vl_compositor_set_layer_dst_area(&vmixer->cstate, layer++, RectToPipe(layers->destination_rect, &rect));
+      cctx->set_rgba_layer(cctx, layer, src->sampler_view,
+                           RectToPipe(layers->source_rect, &rect), NULL, NULL);
+      cctx->set_layer_dst_area(cctx, layer++, RectToPipe(layers->destination_rect, &rect));
 
       ++layers;
    }
 
-   vl_compositor_render(&vmixer->cstate, compositor, surface, &dirty_area, true);
-
-   if (vmixer->noise_reduction.filter) {
-      if (!vmixer->sharpness.filter && !vmixer->bicubic.filter) {
-         vl_median_filter_render(vmixer->noise_reduction.filter,
-                                 sampler_view, dst->surface);
-      } else {
-         res = pipe->screen->resource_create(pipe->screen, &res_tmpl);
-         struct pipe_sampler_view *sampler_view_temp = pipe->create_sampler_view(pipe, res, &sv_templ);
-         struct pipe_surface *surface_temp = pipe->create_surface(pipe, res, &surf_templ);
-         pipe_resource_reference(&res, NULL);
-
-         vl_median_filter_render(vmixer->noise_reduction.filter,
-                                 sampler_view, surface_temp);
-
-         pipe_sampler_view_reference(&sampler_view, NULL);
-         pipe_surface_reference(&surface, NULL);
-
-         sampler_view = sampler_view_temp;
-         surface = surface_temp;
-      }
-   }
-
-   if (vmixer->sharpness.filter) {
-      if (!vmixer->bicubic.filter) {
-         vl_matrix_filter_render(vmixer->sharpness.filter,
-                                 sampler_view, dst->surface);
-      } else {
-         res = pipe->screen->resource_create(pipe->screen, &res_tmpl);
-         struct pipe_sampler_view *sampler_view_temp = pipe->create_sampler_view(pipe, res, &sv_templ);
-         struct pipe_surface *surface_temp = pipe->create_surface(pipe, res, &surf_templ);
-         pipe_resource_reference(&res, NULL);
+   cctx->render(cctx, dst->surface, &dst->dirty_area, true, past, future,
+                video_surface_past_count, video_surface_future_count);
 
-         vl_matrix_filter_render(vmixer->sharpness.filter,
-                                 sampler_view, surface_temp);
-
-         pipe_sampler_view_reference(&sampler_view, NULL);
-         pipe_surface_reference(&surface, NULL);
-
-         sampler_view = sampler_view_temp;
-         surface = surface_temp;
-      }
-   }
-
-   if (vmixer->bicubic.filter)
-      vl_bicubic_filter_render(vmixer->bicubic.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);
-   }
    pipe_mutex_unlock(vmixer->device->mutex);
 
    return VDP_STATUS_OK;
 }
 
-static void
-vlVdpVideoMixerUpdateDeinterlaceFilter(vlVdpVideoMixer *vmixer)
-{
-   struct pipe_context *pipe = vmixer->device->context;
-   assert(vmixer);
-
-   /* remove existing filter */
-   if (vmixer->deint.filter) {
-      vl_deint_filter_cleanup(vmixer->deint.filter);
-      FREE(vmixer->deint.filter);
-      vmixer->deint.filter = NULL;
-   }
-
-   /* create a new filter if requested */
-   if (vmixer->deint.enabled && vmixer->chroma_format == PIPE_VIDEO_CHROMA_FORMAT_420) {
-      vmixer->deint.filter = MALLOC(sizeof(struct vl_deint_filter));
-      vmixer->deint.enabled = vl_deint_filter_init(vmixer->deint.filter, pipe,
-            vmixer->video_width, vmixer->video_height,
-            vmixer->skip_chroma_deint, vmixer->deint.spatial);
-      if (!vmixer->deint.enabled) {
-         FREE(vmixer->deint.filter);
-      }
-   }
-}
-
-/**
- * Update the noise reduction setting
- */
-static void
-vlVdpVideoMixerUpdateNoiseReductionFilter(vlVdpVideoMixer *vmixer)
-{
-   assert(vmixer);
-
-   /* if present remove the old filter first */
-   if (vmixer->noise_reduction.filter) {
-      vl_median_filter_cleanup(vmixer->noise_reduction.filter);
-      FREE(vmixer->noise_reduction.filter);
-      vmixer->noise_reduction.filter = NULL;
-   }
-
-   /* and create a new filter as needed */
-   if (vmixer->noise_reduction. enabled && vmixer->noise_reduction.level > 0) {
-      vmixer->noise_reduction.filter = MALLOC(sizeof(struct vl_median_filter));
-      vl_median_filter_init(vmixer->noise_reduction.filter, vmixer->device->context,
-                            vmixer->video_width, vmixer->video_height,
-                            vmixer->noise_reduction.level + 1,
-                            VL_MEDIAN_FILTER_CROSS);
-   }
-}
-
-static void
-vlVdpVideoMixerUpdateSharpnessFilter(vlVdpVideoMixer *vmixer)
-{
-   assert(vmixer);
-
-   /* if present remove the old filter first */
-   if (vmixer->sharpness.filter) {
-      vl_matrix_filter_cleanup(vmixer->sharpness.filter);
-      FREE(vmixer->sharpness.filter);
-      vmixer->sharpness.filter = NULL;
-   }
-
-   /* and create a new filter as needed */
-   if (vmixer->sharpness.enabled && vmixer->sharpness.value != 0.0f) {
-      float matrix[9];
-      unsigned i;
-
-      if (vmixer->sharpness.value > 0.0f) {
-         matrix[0] = -1.0f; matrix[1] = -1.0f; matrix[2] = -1.0f;
-         matrix[3] = -1.0f; matrix[4] =  8.0f; matrix[5] = -1.0f;
-         matrix[6] = -1.0f; matrix[7] = -1.0f; matrix[8] = -1.0f;
-
-         for (i = 0; i < 9; ++i)
-            matrix[i] *= vmixer->sharpness.value;
-
-         matrix[4] += 1.0f;
-
-      } else {
-         matrix[0] = 1.0f; matrix[1] = 2.0f; matrix[2] = 1.0f;
-         matrix[3] = 2.0f; matrix[4] = 4.0f; matrix[5] = 2.0f;
-         matrix[6] = 1.0f; matrix[7] = 2.0f; matrix[8] = 1.0f;
-
-         for (i = 0; i < 9; ++i)
-               matrix[i] *= fabsf(vmixer->sharpness.value) / 16.0f;
-
-         matrix[4] += 1.0f - fabsf(vmixer->sharpness.value);
-      }
-
-      vmixer->sharpness.filter = MALLOC(sizeof(struct vl_matrix_filter));
-      vl_matrix_filter_init(vmixer->sharpness.filter, vmixer->device->context,
-                            vmixer->video_width, vmixer->video_height,
-                            3, 3, matrix);
-   }
-}
-
-/**
- * Update the bicubic filter
- */
-static void
-vlVdpVideoMixerUpdateBicubicFilter(vlVdpVideoMixer *vmixer)
-{
-   assert(vmixer);
-
-   /* if present remove the old filter first */
-   if (vmixer->bicubic.filter) {
-      vl_bicubic_filter_cleanup(vmixer->bicubic.filter);
-      FREE(vmixer->bicubic.filter);
-      vmixer->bicubic.filter = NULL;
-   }
-   /* and create a new filter as needed */
-   if (vmixer->bicubic.enabled) {
-      vmixer->bicubic.filter = MALLOC(sizeof(struct vl_bicubic_filter));
-      vl_bicubic_filter_init(vmixer->bicubic.filter, vmixer->device->context,
-                            vmixer->video_width, vmixer->video_height);
-   }
-}
-
 /**
  * Retrieve whether features were requested at creation time.
  */
@@ -587,6 +370,7 @@ vlVdpVideoMixerGetFeatureSupport(VdpVideoMixer mixer,
 {
    vlVdpVideoMixer *vmixer;
    unsigned i;
+   struct util_video_compositor *comp;
 
    if (!(features && feature_supports))
       return VDP_STATUS_INVALID_POINTER;
@@ -595,42 +379,52 @@ vlVdpVideoMixerGetFeatureSupport(VdpVideoMixer mixer,
    if (!vmixer)
       return VDP_STATUS_INVALID_HANDLE;
 
+   comp = vmixer->device->compositor;
+
    for (i = 0; i < feature_count; ++i) {
       switch (features[i]) {
-      /* they are valid, but we doesn't support them */
+      /* they are valid, but we don'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;
 
       case VDP_VIDEO_MIXER_FEATURE_DEINTERLACE_TEMPORAL:
-         feature_supports[i] = vmixer->deint.supported;
+         feature_supports[i] =
+            !!comp->buffer_filter_supported(comp, UTIL_VIDEO_FILTER_DEINT_TEMPORAL);
          break;
 
       case VDP_VIDEO_MIXER_FEATURE_SHARPNESS:
-         feature_supports[i] = vmixer->sharpness.supported;
+         feature_supports[i] =
+            !!comp->buffer_filter_supported(comp, UTIL_VIDEO_FILTER_SHARPNESS);
          break;
 
       case VDP_VIDEO_MIXER_FEATURE_NOISE_REDUCTION:
-         feature_supports[i] = vmixer->noise_reduction.supported;
+         feature_supports[i] =
+            !!comp->buffer_filter_supported(comp, UTIL_VIDEO_FILTER_NOISE_REDUCTION);
          break;
 
       case VDP_VIDEO_MIXER_FEATURE_LUMA_KEY:
-         feature_supports[i] = vmixer->luma_key.supported;
+         feature_supports[i] =
+            !!comp->buffer_filter_supported(comp, UTIL_VIDEO_FILTER_LUMA_KEY);
          break;
 
       case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L1:
-         feature_supports[i] = vmixer->bicubic.supported;
+      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:
+      {
+         unsigned j = features[i] -
+            VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L1;
+         feature_supports[i] =
+            (comp->buffer_filter_supported(comp, UTIL_VIDEO_FILTER_HQ_SCALING) > j);
          break;
-
+      }
       default:
          return VDP_STATUS_INVALID_VIDEO_MIXER_FEATURE;
       }
@@ -650,6 +444,7 @@ vlVdpVideoMixerSetFeatureEnables(VdpVideoMixer mixer,
 {
    vlVdpVideoMixer *vmixer;
    unsigned i;
+   struct util_video_compositor_context *cctx;
 
    if (!(features && feature_enables))
       return VDP_STATUS_INVALID_POINTER;
@@ -658,50 +453,56 @@ vlVdpVideoMixerSetFeatureEnables(VdpVideoMixer mixer,
    if (!vmixer)
       return VDP_STATUS_INVALID_HANDLE;
 
+   cctx = vmixer->cctx;
+
    pipe_mutex_lock(vmixer->device->mutex);
    for (i = 0; i < feature_count; ++i) {
       switch (features[i]) {
-      /* they are valid, but we doesn't support them */
+      /* they are valid, but we don'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;
 
       case VDP_VIDEO_MIXER_FEATURE_DEINTERLACE_TEMPORAL:
-         vmixer->deint.enabled = feature_enables[i];
-         vlVdpVideoMixerUpdateDeinterlaceFilter(vmixer);
+         vmixer->deint.filter.enabled = feature_enables[i];
+         if (!cctx->set_buffer_filter(cctx, &vmixer->deint.filter))
+            goto fail_error;
          break;
 
       case VDP_VIDEO_MIXER_FEATURE_SHARPNESS:
-         vmixer->sharpness.enabled = feature_enables[i];
-         vlVdpVideoMixerUpdateSharpnessFilter(vmixer);
+         vmixer->sharpness.filter.enabled = feature_enables[i];
+         if (!cctx->set_buffer_filter(cctx, &vmixer->sharpness.filter))
+            goto fail_error;
          break;
 
       case VDP_VIDEO_MIXER_FEATURE_NOISE_REDUCTION:
-         vmixer->noise_reduction.enabled = feature_enables[i];
-         vlVdpVideoMixerUpdateNoiseReductionFilter(vmixer);
+         vmixer->noise_reduction.filter.enabled = feature_enables[i];
+         if (!cctx->set_buffer_filter(cctx, &vmixer->noise_reduction.filter))
+            goto fail_error;
          break;
 
       case VDP_VIDEO_MIXER_FEATURE_LUMA_KEY:
-         vmixer->luma_key.enabled = feature_enables[i];
-         if (!debug_get_bool_option("G3DVL_NO_CSC", FALSE))
-            if (!vl_compositor_set_csc_matrix(&vmixer->cstate, (const vl_csc_matrix *)&vmixer->csc,
-                        vmixer->luma_key.luma_min, vmixer->luma_key.luma_max)) {
-               pipe_mutex_unlock(vmixer->device->mutex);
-               return VDP_STATUS_ERROR;
-            }
+         vmixer->luma_key.filter.enabled = feature_enables[i];
+         if (!debug_get_bool_option("G3DVL_NO_CSC", FALSE)) {
+            if (!cctx->set_buffer_filter(cctx, &vmixer->luma_key.filter))
+               goto fail_error;
+         }
          break;
 
       case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L1:
-         vmixer->bicubic.enabled = feature_enables[i];
-         vlVdpVideoMixerUpdateBicubicFilter(vmixer);
+      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->hq.filter.enabled = feature_enables[i];
+         vmixer->hq.level = features[i] -
+            VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L1 + 1;
+         if (!cctx->set_buffer_filter(cctx, &vmixer->hq.filter))
+            goto fail_error;
          break;
 
       default:
@@ -712,6 +513,10 @@ vlVdpVideoMixerSetFeatureEnables(VdpVideoMixer mixer,
    pipe_mutex_unlock(vmixer->device->mutex);
 
    return VDP_STATUS_OK;
+
+fail_error:
+   pipe_mutex_unlock(vmixer->device->mutex);
+   return VDP_STATUS_ERROR;
 }
 
 /**
@@ -735,34 +540,39 @@ vlVdpVideoMixerGetFeatureEnables(VdpVideoMixer mixer,
 
    for (i = 0; i < feature_count; ++i) {
       switch (features[i]) {
-      /* they are valid, but we doesn't support them */
-      case VDP_VIDEO_MIXER_FEATURE_DEINTERLACE_TEMPORAL:
+      /* they are valid, but we don'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;
 
+      case VDP_VIDEO_MIXER_FEATURE_DEINTERLACE_TEMPORAL:
+         feature_enables[i] = vmixer->deint.filter.enabled;
+         break;
+
       case VDP_VIDEO_MIXER_FEATURE_SHARPNESS:
-         feature_enables[i] = vmixer->sharpness.enabled;
+         feature_enables[i] = vmixer->sharpness.filter.enabled;
          break;
 
       case VDP_VIDEO_MIXER_FEATURE_NOISE_REDUCTION:
-         feature_enables[i] = vmixer->noise_reduction.enabled;
+         feature_enables[i] = vmixer->noise_reduction.filter.enabled;
          break;
 
       case VDP_VIDEO_MIXER_FEATURE_LUMA_KEY:
-         feature_enables[i] = vmixer->luma_key.enabled;
+         feature_enables[i] = vmixer->luma_key.filter.enabled;
          break;
 
       case VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L1:
-         feature_enables[i] = vmixer->bicubic.enabled;
+      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->hq.filter.enabled &&
+            (vmixer->hq.level == features[i] -
+             VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L1 + 1);
          break;
 
       default:
@@ -788,6 +598,7 @@ vlVdpVideoMixerSetAttributeValues(VdpVideoMixer mixer,
    float val;
    unsigned i;
    VdpStatus ret;
+   struct util_video_compositor_context *cctx;
 
    if (!(attributes && attribute_values))
       return VDP_STATUS_INVALID_POINTER;
@@ -796,8 +607,11 @@ vlVdpVideoMixerSetAttributeValues(VdpVideoMixer mixer,
    if (!vmixer)
       return VDP_STATUS_INVALID_HANDLE;
 
+   cctx = vmixer->cctx;
    pipe_mutex_lock(vmixer->device->mutex);
    for (i = 0; i < attribute_count; ++i) {
+      const struct util_video_filter *filter = NULL;
+
       switch (attributes[i]) {
       case VDP_VIDEO_MIXER_ATTRIBUTE_BACKGROUND_COLOR:
          background_color = attribute_values[i];
@@ -805,7 +619,7 @@ vlVdpVideoMixerSetAttributeValues(VdpVideoMixer mixer,
          color.f[1] = background_color->green;
          color.f[2] = background_color->blue;
          color.f[3] = background_color->alpha;
-         vl_compositor_set_clear_color(&vmixer->cstate, &color);
+         cctx->set_clear_color(cctx, &color);
          break;
       case VDP_VIDEO_MIXER_ATTRIBUTE_CSC_MATRIX:
          vdp_csc = attribute_values[i];
@@ -815,8 +629,8 @@ vlVdpVideoMixerSetAttributeValues(VdpVideoMixer mixer,
          else
             memcpy(vmixer->csc, vdp_csc, sizeof(vl_csc_matrix));
          if (!debug_get_bool_option("G3DVL_NO_CSC", FALSE))
-            if (!vl_compositor_set_csc_matrix(&vmixer->cstate, (const vl_csc_matrix *)&vmixer->csc,
-                                         vmixer->luma_key.luma_min, vmixer->luma_key.luma_max)) {
+            if (!cctx->set_csc_matrix
+                (cctx, (const util_video_compositor_csc_matrix *)&vmixer->csc)) {
                ret = VDP_STATUS_ERROR;
                goto fail;
             }
@@ -831,7 +645,7 @@ vlVdpVideoMixerSetAttributeValues(VdpVideoMixer mixer,
          }
 
          vmixer->noise_reduction.level = val * 10;
-         vlVdpVideoMixerUpdateNoiseReductionFilter(vmixer);
+         filter = &vmixer->noise_reduction.filter;
          break;
 
       case VDP_VIDEO_MIXER_ATTRIBUTE_LUMA_KEY_MIN_LUMA:
@@ -842,11 +656,7 @@ vlVdpVideoMixerSetAttributeValues(VdpVideoMixer mixer,
          }
          vmixer->luma_key.luma_min = val;
          if (!debug_get_bool_option("G3DVL_NO_CSC", FALSE))
-            if (!vl_compositor_set_csc_matrix(&vmixer->cstate, (const vl_csc_matrix *)&vmixer->csc,
-                        vmixer->luma_key.luma_min, vmixer->luma_key.luma_max)) {
-               ret = VDP_STATUS_ERROR;
-               goto fail;
-            }
+            filter = &vmixer->luma_key.filter;
          break;
 
       case VDP_VIDEO_MIXER_ATTRIBUTE_LUMA_KEY_MAX_LUMA:
@@ -857,11 +667,7 @@ vlVdpVideoMixerSetAttributeValues(VdpVideoMixer mixer,
          }
          vmixer->luma_key.luma_max = val;
          if (!debug_get_bool_option("G3DVL_NO_CSC", FALSE))
-            if (!vl_compositor_set_csc_matrix(&vmixer->cstate, (const vl_csc_matrix *)&vmixer->csc,
-                        vmixer->luma_key.luma_min, vmixer->luma_key.luma_max)) {
-               ret = VDP_STATUS_ERROR;
-               goto fail;
-            }
+            filter = &vmixer->luma_key.filter;
          break;
 
       case VDP_VIDEO_MIXER_ATTRIBUTE_SHARPNESS_LEVEL:
@@ -873,7 +679,7 @@ vlVdpVideoMixerSetAttributeValues(VdpVideoMixer mixer,
          }
 
          vmixer->sharpness.value = val;
-         vlVdpVideoMixerUpdateSharpnessFilter(vmixer);
+         filter = &vmixer->sharpness.filter;
          break;
 
       case VDP_VIDEO_MIXER_ATTRIBUTE_SKIP_CHROMA_DEINTERLACE:
@@ -881,17 +687,23 @@ vlVdpVideoMixerSetAttributeValues(VdpVideoMixer mixer,
             ret = VDP_STATUS_INVALID_VALUE;
             goto fail;
          }
-         vmixer->skip_chroma_deint = *(uint8_t*)attribute_values[i];
-         vlVdpVideoMixerUpdateDeinterlaceFilter(vmixer);
+         vmixer->deint.skip_chroma = !!*(uint8_t*)attribute_values[i];
+         filter = &vmixer->deint.filter;
          break;
       default:
          ret = VDP_STATUS_INVALID_VIDEO_MIXER_ATTRIBUTE;
          goto fail;
       }
+
+      if (filter && !cctx->set_buffer_filter(cctx, filter)) {
+         ret = VDP_STATUS_ERROR;
+         goto fail;
+      }
    }
    pipe_mutex_unlock(vmixer->device->mutex);
 
    return VDP_STATUS_OK;
+
 fail:
    pipe_mutex_unlock(vmixer->device->mutex);
    return ret;
@@ -959,7 +771,7 @@ vlVdpVideoMixerGetAttributeValues(VdpVideoMixer mixer,
    for (i = 0; i < attribute_count; ++i) {
       switch (attributes[i]) {
       case VDP_VIDEO_MIXER_ATTRIBUTE_BACKGROUND_COLOR:
-         vl_compositor_get_clear_color(&vmixer->cstate, attribute_values[i]);
+         vmixer->cctx->get_clear_color(vmixer->cctx, attribute_values[i]);
          break;
       case VDP_VIDEO_MIXER_ATTRIBUTE_CSC_MATRIX:
          vdp_csc = attribute_values[i];
diff --git a/src/gallium/state_trackers/vdpau/output.c b/src/gallium/state_trackers/vdpau/output.c
index 6506280..2e3e520 100644
--- a/src/gallium/state_trackers/vdpau/output.c
+++ b/src/gallium/state_trackers/vdpau/output.c
@@ -35,6 +35,7 @@
 #include "util/u_surface.h"
 
 #include "vl/vl_csc.h"
+#include "vl/vl_compositor.h"
 
 #include "state_tracker/drm_driver.h"
 
@@ -116,16 +117,19 @@ vlVdpOutputSurfaceCreate(VdpDevice device,
    if (*surface == 0)
       goto err_resource;
 
-   pipe_resource_reference(&res, NULL);
-
-   if (!vl_compositor_init_state(&vlsurface->cstate, pipe))
-      goto err_resource;
+   vlsurface->cctx = dev->compositor->context_create(dev->compositor);
+   if (!vlsurface->cctx)
+      goto err_compositor;
 
    vl_compositor_reset_dirty_area(&vlsurface->dirty_area);
+   pipe_resource_reference(&res, NULL);
+
    pipe_mutex_unlock(dev->mutex);
 
    return VDP_STATUS_OK;
 
+err_compositor:
+   vlRemoveDataHTAB(*surface);
 err_resource:
    pipe_sampler_view_reference(&vlsurface->sampler_view, NULL);
    pipe_surface_reference(&vlsurface->surface, NULL);
@@ -157,7 +161,7 @@ vlVdpOutputSurfaceDestroy(VdpOutputSurface surface)
    pipe_surface_reference(&vlsurface->surface, NULL);
    pipe_sampler_view_reference(&vlsurface->sampler_view, NULL);
    pipe->screen->fence_reference(pipe->screen, &vlsurface->fence, NULL);
-   vl_compositor_cleanup_state(&vlsurface->cstate);
+   vlsurface->cctx->destroy(vlsurface->cctx);
    pipe_mutex_unlock(vlsurface->device->mutex);
 
    vlRemoveDataHTAB(surface);
@@ -293,8 +297,7 @@ vlVdpOutputSurfacePutBitsIndexed(VdpOutputSurface surface,
 {
    vlVdpOutputSurface *vlsurface;
    struct pipe_context *context;
-   struct vl_compositor *compositor;
-   struct vl_compositor_state *cstate;
+   struct util_video_compositor_context *cctx;
 
    enum pipe_format index_format;
    enum pipe_format colortbl_format;
@@ -311,8 +314,7 @@ vlVdpOutputSurfacePutBitsIndexed(VdpOutputSurface surface,
       return VDP_STATUS_INVALID_HANDLE;
 
    context = vlsurface->device->context;
-   compositor = &vlsurface->device->compositor;
-   cstate = &vlsurface->cstate;
+   cctx = vlsurface->cctx;
 
    index_format = FormatIndexedToPipe(source_indexed_format);
    if (index_format == PIPE_FORMAT_NONE)
@@ -403,10 +405,11 @@ vlVdpOutputSurfacePutBitsIndexed(VdpOutputSurface surface,
    if (!sv_tbl)
       goto error_resource;
 
-   vl_compositor_clear_layers(cstate);
-   vl_compositor_set_palette_layer(cstate, compositor, 0, sv_idx, sv_tbl, NULL, NULL, false);
-   vl_compositor_set_layer_dst_area(cstate, 0, RectToPipe(destination_rect, &dst_rect));
-   vl_compositor_render(cstate, compositor, vlsurface->surface, &vlsurface->dirty_area, false);
+   cctx->clear_layers(cctx);
+   cctx->set_palette_layer(cctx, 0, sv_idx, sv_tbl, NULL, NULL, false);
+   cctx->set_layer_dst_area(cctx, 0, RectToPipe(destination_rect, &dst_rect));
+   cctx->render(cctx, vlsurface->surface, &vlsurface->dirty_area, false,
+                NULL, NULL, 0, 0);
 
    pipe_sampler_view_reference(&sv_idx, NULL);
    pipe_sampler_view_reference(&sv_tbl, NULL);
@@ -434,8 +437,7 @@ vlVdpOutputSurfacePutBitsYCbCr(VdpOutputSurface surface,
                                VdpCSCMatrix const *csc_matrix)
 {
    vlVdpOutputSurface *vlsurface;
-   struct vl_compositor *compositor;
-   struct vl_compositor_state *cstate;
+   struct util_video_compositor_context *cctx;
 
    struct pipe_context *pipe;
    enum pipe_format format;
@@ -451,8 +453,7 @@ vlVdpOutputSurfacePutBitsYCbCr(VdpOutputSurface surface,
 
 
    pipe = vlsurface->device->context;
-   compositor = &vlsurface->device->compositor;
-   cstate = &vlsurface->cstate;
+   cctx = vlsurface->cctx;
 
    format = FormatYCBCRToPipe(source_ycbcr_format);
    if (format == PIPE_FORMAT_NONE)
@@ -503,17 +504,20 @@ vlVdpOutputSurfacePutBitsYCbCr(VdpOutputSurface surface,
    if (!csc_matrix) {
       vl_csc_matrix csc;
       vl_csc_get_matrix(VL_CSC_COLOR_STANDARD_BT_601, NULL, 1, &csc);
-      if (!vl_compositor_set_csc_matrix(cstate, (const vl_csc_matrix*)&csc, 1.0f, 0.0f))
+      if (!cctx->set_csc_matrix
+          (cctx, (const util_video_compositor_csc_matrix*)&csc))
          goto err_csc_matrix;
    } else {
-      if (!vl_compositor_set_csc_matrix(cstate, csc_matrix, 1.0f, 0.0f))
+      if (!cctx->set_csc_matrix
+          (cctx, (const util_video_compositor_csc_matrix*) csc_matrix))
          goto err_csc_matrix;
    }
 
-   vl_compositor_clear_layers(cstate);
-   vl_compositor_set_buffer_layer(cstate, compositor, 0, vbuffer, NULL, NULL, VL_COMPOSITOR_WEAVE);
-   vl_compositor_set_layer_dst_area(cstate, 0, RectToPipe(destination_rect, &dst_rect));
-   vl_compositor_render(cstate, compositor, vlsurface->surface, &vlsurface->dirty_area, false);
+   cctx->clear_layers(cctx);
+   cctx->set_buffer_layer(cctx, 0, vbuffer, NULL, NULL, UTIL_VIDEO_COMPOSITOR_WEAVE);
+   cctx->set_layer_dst_area(cctx, 0, RectToPipe(destination_rect, &dst_rect));
+   cctx->render(cctx, vlsurface->surface, &vlsurface->dirty_area, false,
+                NULL, NULL, 0, 0);
 
    vbuffer->destroy(vbuffer);
    pipe_mutex_unlock(vlsurface->device->mutex);
@@ -614,11 +618,11 @@ BlenderToPipe(struct pipe_context *context,
    return context->create_blend_state(context, &blend);
 }
 
-static struct vertex4f *
-ColorsToPipe(VdpColor const *colors, uint32_t flags, struct vertex4f result[4])
+static struct util_video_vertex4f *
+ColorsToPipe(VdpColor const *colors, uint32_t flags, struct util_video_vertex4f result[4])
 {
    unsigned i;
-   struct vertex4f *dst = result;
+   struct util_video_vertex4f *dst = result;
 
    if (!colors)
       return NULL;
@@ -653,12 +657,11 @@ vlVdpOutputSurfaceRenderOutputSurface(VdpOutputSurface destination_surface,
 
    struct pipe_context *context;
    struct pipe_sampler_view *src_sv;
-   struct vl_compositor *compositor;
-   struct vl_compositor_state *cstate;
+   struct util_video_compositor_context *cctx;
 
    struct u_rect src_rect, dst_rect;
 
-   struct vertex4f vlcolors[4];
+   struct util_video_vertex4f vlcolors[4];
    void *blend;
 
    dst_vlsurface = vlGetDataHTAB(destination_surface);
@@ -682,23 +685,23 @@ vlVdpOutputSurfaceRenderOutputSurface(VdpOutputSurface destination_surface,
    pipe_mutex_lock(dst_vlsurface->device->mutex);
 
    context = dst_vlsurface->device->context;
-   compositor = &dst_vlsurface->device->compositor;
-   cstate = &dst_vlsurface->cstate;
+   cctx = dst_vlsurface->cctx;
 
    blend = BlenderToPipe(context, blend_state);
 
-   vl_compositor_clear_layers(cstate);
-   vl_compositor_set_layer_blend(cstate, 0, blend, false);
-   vl_compositor_set_rgba_layer(cstate, compositor, 0, src_sv,
-                                RectToPipe(source_rect, &src_rect), NULL,
-                                ColorsToPipe(colors, flags, vlcolors));
-   STATIC_ASSERT(VL_COMPOSITOR_ROTATE_0 == VDP_OUTPUT_SURFACE_RENDER_ROTATE_0);
-   STATIC_ASSERT(VL_COMPOSITOR_ROTATE_90 == VDP_OUTPUT_SURFACE_RENDER_ROTATE_90);
-   STATIC_ASSERT(VL_COMPOSITOR_ROTATE_180 == VDP_OUTPUT_SURFACE_RENDER_ROTATE_180);
-   STATIC_ASSERT(VL_COMPOSITOR_ROTATE_270 == VDP_OUTPUT_SURFACE_RENDER_ROTATE_270);
-   vl_compositor_set_layer_rotation(cstate, 0, flags & 3);
-   vl_compositor_set_layer_dst_area(cstate, 0, RectToPipe(destination_rect, &dst_rect));
-   vl_compositor_render(cstate, compositor, dst_vlsurface->surface, &dst_vlsurface->dirty_area, false);
+   cctx->clear_layers(cctx);
+   cctx->set_layer_blend(cctx, 0, blend, false);
+   cctx->set_rgba_layer(cctx, 0, src_sv,
+                        RectToPipe(source_rect, &src_rect), NULL,
+                        ColorsToPipe(colors, flags, vlcolors));
+   STATIC_ASSERT(UTIL_VIDEO_COMPOSITOR_ROTATE_0 == VDP_OUTPUT_SURFACE_RENDER_ROTATE_0);
+   STATIC_ASSERT(UTIL_VIDEO_COMPOSITOR_ROTATE_90 == VDP_OUTPUT_SURFACE_RENDER_ROTATE_90);
+   STATIC_ASSERT(UTIL_VIDEO_COMPOSITOR_ROTATE_180 == VDP_OUTPUT_SURFACE_RENDER_ROTATE_180);
+   STATIC_ASSERT(UTIL_VIDEO_COMPOSITOR_ROTATE_270 == VDP_OUTPUT_SURFACE_RENDER_ROTATE_270);
+   cctx->set_layer_rotation(cctx, 0, flags & 3);
+   cctx->set_layer_dst_area(cctx, 0, RectToPipe(destination_rect, &dst_rect));
+   cctx->render(cctx, dst_vlsurface->surface, &dst_vlsurface->dirty_area, false,
+                NULL, NULL, 0, 0);
 
    context->delete_blend_state(context, blend);
    pipe_mutex_unlock(dst_vlsurface->device->mutex);
@@ -723,12 +726,11 @@ vlVdpOutputSurfaceRenderBitmapSurface(VdpOutputSurface destination_surface,
 
    struct pipe_context *context;
    struct pipe_sampler_view *src_sv;
-   struct vl_compositor *compositor;
-   struct vl_compositor_state *cstate;
+   struct util_video_compositor_context *cctx;
 
    struct u_rect src_rect, dst_rect;
 
-   struct vertex4f vlcolors[4];
+   struct util_video_vertex4f vlcolors[4];
    void *blend;
 
    dst_vlsurface = vlGetDataHTAB(destination_surface);
@@ -750,21 +752,21 @@ vlVdpOutputSurfaceRenderBitmapSurface(VdpOutputSurface destination_surface,
    }
 
    context = dst_vlsurface->device->context;
-   compositor = &dst_vlsurface->device->compositor;
-   cstate = &dst_vlsurface->cstate;
+   cctx = dst_vlsurface->cctx;
 
    pipe_mutex_lock(dst_vlsurface->device->mutex);
 
    blend = BlenderToPipe(context, blend_state);
 
-   vl_compositor_clear_layers(cstate);
-   vl_compositor_set_layer_blend(cstate, 0, blend, false);
-   vl_compositor_set_rgba_layer(cstate, compositor, 0, src_sv,
-                                RectToPipe(source_rect, &src_rect), NULL,
-                                ColorsToPipe(colors, flags, vlcolors));
-   vl_compositor_set_layer_rotation(cstate, 0, flags & 3);
-   vl_compositor_set_layer_dst_area(cstate, 0, RectToPipe(destination_rect, &dst_rect));
-   vl_compositor_render(cstate, compositor, dst_vlsurface->surface, &dst_vlsurface->dirty_area, false);
+   cctx->clear_layers(cctx);
+   cctx->set_layer_blend(cctx, 0, blend, false);
+   cctx->set_rgba_layer(cctx, 0, src_sv,
+                        RectToPipe(source_rect, &src_rect), NULL,
+                        ColorsToPipe(colors, flags, vlcolors));
+   cctx->set_layer_rotation(cctx, 0, flags & 3);
+   cctx->set_layer_dst_area(cctx, 0, RectToPipe(destination_rect, &dst_rect));
+   cctx->render(cctx, dst_vlsurface->surface, &dst_vlsurface->dirty_area, false,
+                NULL, NULL, 0, 0);
 
    context->delete_blend_state(context, blend);
    pipe_mutex_unlock(dst_vlsurface->device->mutex);
diff --git a/src/gallium/state_trackers/vdpau/presentation.c b/src/gallium/state_trackers/vdpau/presentation.c
index 78cafc8..619cf3b 100644
--- a/src/gallium/state_trackers/vdpau/presentation.c
+++ b/src/gallium/state_trackers/vdpau/presentation.c
@@ -66,7 +66,8 @@ vlVdpPresentationQueueCreate(VdpDevice device,
    pq->drawable = pqt->drawable;
 
    pipe_mutex_lock(dev->mutex);
-   if (!vl_compositor_init_state(&pq->cstate, dev->context)) {
+   pq->cctx = dev->compositor->context_create(dev->compositor);
+   if (!pq->cctx) {
       pipe_mutex_unlock(dev->mutex);
       ret = VDP_STATUS_ERROR;
       goto no_compositor;
@@ -101,7 +102,7 @@ vlVdpPresentationQueueDestroy(VdpPresentationQueue presentation_queue)
       return VDP_STATUS_INVALID_HANDLE;
 
    pipe_mutex_lock(pq->device->mutex);
-   vl_compositor_cleanup_state(&pq->cstate);
+   pq->cctx->destroy(pq->cctx);
    pipe_mutex_unlock(pq->device->mutex);
 
    vlRemoveDataHTAB(presentation_queue);
@@ -134,7 +135,7 @@ vlVdpPresentationQueueSetBackgroundColor(VdpPresentationQueue presentation_queue
    color.f[3] = background_color->alpha;
 
    pipe_mutex_lock(pq->device->mutex);
-   vl_compositor_set_clear_color(&pq->cstate, &color);
+   pq->cctx->set_clear_color(pq->cctx, &color);
    pipe_mutex_unlock(pq->device->mutex);
 
    return VDP_STATUS_OK;
@@ -158,7 +159,7 @@ vlVdpPresentationQueueGetBackgroundColor(VdpPresentationQueue presentation_queue
       return VDP_STATUS_INVALID_HANDLE;
 
    pipe_mutex_lock(pq->device->mutex);
-   vl_compositor_get_clear_color(&pq->cstate, &color);
+   pq->cctx->get_clear_color(pq->cctx, &color);
    pipe_mutex_unlock(pq->device->mutex);
 
    background_color->red = color.f[0];
@@ -213,8 +214,7 @@ vlVdpPresentationQueueDisplay(VdpPresentationQueue presentation_queue,
    struct pipe_surface surf_templ, *surf_draw;
    struct u_rect src_rect, dst_clip, *dirty_area;
 
-   struct vl_compositor *compositor;
-   struct vl_compositor_state *cstate;
+   struct util_video_compositor_context *cctx;
    struct vl_screen *vscreen;
 
    pq = vlGetDataHTAB(presentation_queue);
@@ -226,8 +226,7 @@ vlVdpPresentationQueueDisplay(VdpPresentationQueue presentation_queue,
       return VDP_STATUS_INVALID_HANDLE;
 
    pipe = pq->device->context;
-   compositor = &pq->device->compositor;
-   cstate = &pq->cstate;
+   cctx = pq->cctx;
    vscreen = pq->device->vscreen;
 
    pipe_mutex_lock(pq->device->mutex);
@@ -256,10 +255,10 @@ vlVdpPresentationQueueDisplay(VdpPresentationQueue presentation_queue,
       src_rect.x1 = surf_draw->width;
       src_rect.y1 = surf_draw->height;
 
-      vl_compositor_clear_layers(cstate);
-      vl_compositor_set_rgba_layer(cstate, compositor, 0, surf->sampler_view, &src_rect, NULL, NULL);
-      vl_compositor_set_dst_clip(cstate, &dst_clip);
-      vl_compositor_render(cstate, compositor, surf_draw, dirty_area, true);
+      cctx->clear_layers(cctx);
+      cctx->set_rgba_layer(cctx, 0, surf->sampler_view, &src_rect, NULL, NULL);
+      cctx->set_dst_clip(cctx, &dst_clip);
+      cctx->render(cctx, surf_draw, dirty_area, true, NULL, NULL, 0, 0);
    }
 
    vscreen->set_next_timestamp(vscreen, earliest_presentation_time);
diff --git a/src/gallium/state_trackers/vdpau/vdpau_private.h b/src/gallium/state_trackers/vdpau/vdpau_private.h
index cc20e5d..88a4f19 100644
--- a/src/gallium/state_trackers/vdpau/vdpau_private.h
+++ b/src/gallium/state_trackers/vdpau/vdpau_private.h
@@ -45,12 +45,8 @@
 #include "os/os_thread.h"
 
 #include "vl/vl_video_buffer.h"
-#include "vl/vl_bicubic_filter.h"
-#include "vl/vl_compositor.h"
+#include "vl/vl_postproc.h"
 #include "vl/vl_csc.h"
-#include "vl/vl_deint_filter.h"
-#include "vl/vl_matrix_filter.h"
-#include "vl/vl_median_filter.h"
 #include "vl/vl_winsys.h"
 
 /* Full VDPAU API documentation available at :
@@ -60,6 +56,7 @@
 #define QUOTEME(x) #x
 #define TOSTRING(x) QUOTEME(x)
 #define INFORMATION_STRING TOSTRING(INFORMATION)
+#define VLVDP_HQ_LEVELS 9
 
 static inline enum pipe_video_chroma_format
 ChromaToPipe(VdpChromaType vdpau_type)
@@ -352,7 +349,7 @@ typedef struct
    struct pipe_reference reference;
    struct vl_screen *vscreen;
    struct pipe_context *context;
-   struct vl_compositor compositor;
+   struct util_video_compositor *compositor;
    struct pipe_sampler_view *dummy_sv;
    pipe_mutex mutex;
 } vlVdpDevice;
@@ -360,34 +357,19 @@ typedef struct
 typedef struct
 {
    vlVdpDevice *device;
-   struct vl_compositor_state cstate;
-
-   struct {
-       bool supported, enabled;
-       float luma_min, luma_max;
-   } luma_key;
-
-   struct {
-	  bool supported, enabled, spatial;
-	  struct vl_deint_filter *filter;
-   } deint;
-
-   struct {
-	  bool supported, enabled;
-	  struct vl_bicubic_filter *filter;
-   } bicubic;
-
-   struct {
-      bool supported, enabled;
-      unsigned level;
-      struct vl_median_filter *filter;
-   } noise_reduction;
-
-   struct {
-      bool supported, enabled;
-      float value;
-      struct vl_matrix_filter *filter;
-   } sharpness;
+   struct util_video_compositor_context *cctx;
+
+   struct util_video_filter_luma_key luma_key;
+   struct util_video_filter_deint deint;
+   struct util_video_filter_sharpness sharpness;
+   struct util_video_filter_noise_red noise_reduction;
+   struct util_video_filter_hq_scaling hq;
+
+   bool luma_key_supported;
+   bool deint_supported;
+   bool sharpness_supported;
+   bool noise_red_supported;
+   unsigned hq_supported[VLVDP_HQ_LEVELS];
 
    unsigned video_width, video_height;
    enum pipe_video_chroma_format chroma_format;
@@ -417,7 +399,7 @@ typedef struct
    struct pipe_surface *surface;
    struct pipe_sampler_view *sampler_view;
    struct pipe_fence_handle *fence;
-   struct vl_compositor_state cstate;
+   struct util_video_compositor_context *cctx;
    struct u_rect dirty_area;
    bool send_to_X;
 } vlVdpOutputSurface;
@@ -432,7 +414,7 @@ typedef struct
 {
    vlVdpDevice *device;
    Drawable drawable;
-   struct vl_compositor_state cstate;
+   struct util_video_compositor_context *cctx;
    vlVdpOutputSurface *last_surf;
 } vlVdpPresentationQueue;
 
-- 
2.4.11



More information about the mesa-dev mailing list