frontends/va/postproc: Convert destination when deinterlacing
authorThong Thai <thong.thai@amd.com>
Mon, 21 Sep 2020 17:56:05 +0000 (13:56 -0400)
committerMarge Bot <eric+marge@anholt.net>
Wed, 25 Nov 2020 20:08:15 +0000 (20:08 +0000)
When the VAAPI deinterlacing filter is chained with other VAAPI
post-processing filters, the image might get deinterlaced multiple
times, as the filters after the deinterlacing filter might still see an
interlaced buffer.

Signed-off-by: Thong Thai <thong.thai@amd.com>
Acked-by: Leo Liu <leo.liu@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6803>

src/gallium/frontends/va/postproc.c

index f84a5ae..946761b 100644 (file)
@@ -287,7 +287,7 @@ vlVaHandleVAProcPipelineParameterBufferType(vlVaDriver *drv, vlVaContext *contex
    VARectangle def_src_region, def_dst_region;
    const VARectangle *src_region, *dst_region;
    VAProcPipelineParameterBuffer *param;
-   struct pipe_video_buffer *src;
+   struct pipe_video_buffer *src, *dst;
    vlVaSurface *src_surface, *dst_surface;
    unsigned i;
 
@@ -309,6 +309,21 @@ vlVaHandleVAProcPipelineParameterBufferType(vlVaDriver *drv, vlVaContext *contex
       return VA_STATUS_ERROR_INVALID_SURFACE;
 
    src = src_surface->buffer;
+   dst = dst_surface->buffer;
+
+   /* convert the destination buffer to progressive if we're deinterlacing 
+      otherwise we might end up deinterlacing twice */
+   if (param->num_filters && dst->interlaced) {
+      vlVaSurface *surf;
+      surf = dst_surface;
+      surf->templat.interlaced = false;
+      dst->destroy(dst);
+
+      if (vlVaHandleSurfaceAllocate(drv, surf, &surf->templat) != VA_STATUS_SUCCESS)
+         return VA_STATUS_ERROR_ALLOCATION_FAILED;
+
+      dst = context->target = surf->buffer;
+   }
 
    for (i = 0; i < param->num_filters; i++) {
       vlVaBuffer *buf = handle_table_get(drv->htab, param->filters[i]);