From f09456361c4c753f686b8f155f5c8de3f1feebb9 Mon Sep 17 00:00:00 2001 From: Thong Thai Date: Mon, 21 Sep 2020 13:56:05 -0400 Subject: [PATCH] frontends/va/postproc: Convert destination when deinterlacing 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 Acked-by: Leo Liu Part-of: --- src/gallium/frontends/va/postproc.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/gallium/frontends/va/postproc.c b/src/gallium/frontends/va/postproc.c index f84a5aeeb1f..946761be312 100644 --- a/src/gallium/frontends/va/postproc.c +++ b/src/gallium/frontends/va/postproc.c @@ -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]);