<div dir="ltr"><div>This patch is:<br>Reviewed-by: Julien Isorce <<a href="mailto:j.isorce@samsung.com" target="_blank">j.isorce@samsung.com</a>><br>Tested-by: Julien Isorce <<a href="mailto:j.isorce@samsung.com" target="_blank">j.isorce@samsung.com</a>><br><br></div>(tested with gstvaapipostproc from gstreamer-vaapi)<br></div><div class="gmail_extra"><br><div class="gmail_quote">On 11 December 2015 at 12:33, Christian König <span dir="ltr"><<a href="mailto:deathsimple@vodafone.de" target="_blank">deathsimple@vodafone.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">From: Christian König <<a href="mailto:christian.koenig@amd.com">christian.koenig@amd.com</a>><br>
<br>
Tested with MPV.<br>
<br>
Signed-off-by: Christian König <<a href="mailto:christian.koenig@amd.com">christian.koenig@amd.com</a>><br>
---<br>
 src/gallium/state_trackers/va/postproc.c | 72 ++++++++++++++++++++++++++++----<br>
 src/gallium/state_trackers/va/surface.c  | 16 ++++++-<br>
 2 files changed, 78 insertions(+), 10 deletions(-)<br>
<br>
diff --git a/src/gallium/state_trackers/va/postproc.c b/src/gallium/state_trackers/va/postproc.c<br>
index c6cfd3a..bcac66a 100644<br>
--- a/src/gallium/state_trackers/va/postproc.c<br>
+++ b/src/gallium/state_trackers/va/postproc.c<br>
@@ -51,7 +51,8 @@ vlVaPostProcCompositor(vlVaDriver *drv, vlVaContext *context,<br>
                        const VARectangle *src_region,<br>
                        const VARectangle *dst_region,<br>
                        struct pipe_video_buffer *src,<br>
-                       struct pipe_video_buffer *dst)<br>
+                       struct pipe_video_buffer *dst,<br>
+                       enum vl_compositor_deinterlace deinterlace)<br>
 {<br>
    struct pipe_surface **surfaces;<br>
    struct u_rect src_rect;<br>
@@ -100,7 +101,8 @@ static VAStatus vlVaPostProcBlit(vlVaDriver *drv, vlVaContext *context,<br>
                                  const VARectangle *src_region,<br>
                                  const VARectangle *dst_region,<br>
                                  struct pipe_video_buffer *src,<br>
-                                 struct pipe_video_buffer *dst)<br>
+                                 struct pipe_video_buffer *dst,<br>
+                                 enum vl_compositor_deinterlace deinterlace)<br>
 {<br>
    struct pipe_surface **src_surfaces;<br>
    struct pipe_surface **dst_surfaces;<br>
@@ -118,18 +120,33 @@ static VAStatus vlVaPostProcBlit(vlVaDriver *drv, vlVaContext *context,<br>
       return VA_STATUS_ERROR_INVALID_SURFACE;<br>
<br>
    for (i = 0; i < VL_MAX_SURFACES; ++i) {<br>
+      struct pipe_surface *from = src_surfaces[i];<br>
       struct pipe_blit_info blit;<br>
<br>
-      if (!src_surfaces[i] || !dst_surfaces[i])<br>
+      if (src->interlaced) {<br>
+         /* Not 100% accurate, but close enough */<br>
+         switch (deinterlace) {<br>
+         case VL_COMPOSITOR_BOB_TOP:<br>
+            from = src_surfaces[i & ~1];<br>
+            break;<br>
+         case VL_COMPOSITOR_BOB_BOTTOM:<br>
+            from = src_surfaces[(i & ~1) + 1];<br>
+            break;<br>
+         default:<br>
+            break;<br>
+         }<br>
+      }<br>
+<br>
+      if (!from || !dst_surfaces[i])<br>
          continue;<br>
<br>
       memset(&blit, 0, sizeof(blit));<br>
-      blit.src.resource = src_surfaces[i]->texture;<br>
-      blit.src.format = src_surfaces[i]->format;<br>
+      blit.src.resource = from->texture;<br>
+      blit.src.format = from->format;<br>
       blit.src.level = 0;<br>
       blit.src.box.x = src_region->x;<br>
       blit.src.box.y = src_region->y;<br>
-      blit.src.box.z = src_surfaces[i]->u.tex.first_layer;<br>
+      blit.src.box.z = from->u.tex.first_layer;<br>
       blit.src.box.width = src_region->width;<br>
       blit.src.box.height = src_region->height;<br>
       blit.src.box.depth = 1;<br>
@@ -158,10 +175,12 @@ static VAStatus vlVaPostProcBlit(vlVaDriver *drv, vlVaContext *context,<br>
 VAStatus<br>
 vlVaHandleVAProcPipelineParameterBufferType(vlVaDriver *drv, vlVaContext *context, vlVaBuffer *buf)<br>
 {<br>
+   enum vl_compositor_deinterlace deinterlace = VL_COMPOSITOR_WEAVE;<br>
    VARectangle def_src_region, def_dst_region;<br>
    const VARectangle *src_region, *dst_region;<br>
    VAProcPipelineParameterBuffer *param;<br>
    vlVaSurface *src_surface;<br>
+   unsigned i;<br>
<br>
    if (!drv || !context)<br>
       return VA_STATUS_ERROR_INVALID_CONTEXT;<br>
@@ -178,13 +197,50 @@ vlVaHandleVAProcPipelineParameterBufferType(vlVaDriver *drv, vlVaContext *contex<br>
    if (!src_surface || !src_surface->buffer)<br>
       return VA_STATUS_ERROR_INVALID_SURFACE;<br>
<br>
+   for (i = 0; i < param->num_filters; i++) {<br>
+      vlVaBuffer *buf = handle_table_get(drv->htab, param->filters[i]);<br>
+      VAProcFilterParameterBufferBase *filter;<br>
+<br>
+      if (!buf || buf->type != VAProcFilterParameterBufferType)<br>
+         return VA_STATUS_ERROR_INVALID_BUFFER;<br>
+<br>
+      filter = buf->data;<br>
+      switch (filter->type) {<br>
+      case VAProcFilterDeinterlacing: {<br>
+         VAProcFilterParameterBufferDeinterlacing *deint = buf->data;<br>
+         switch (deint->algorithm) {<br>
+         case VAProcDeinterlacingBob:<br>
+            if (deint->flags & VA_DEINTERLACING_BOTTOM_FIELD)<br>
+               deinterlace = VL_COMPOSITOR_BOB_BOTTOM;<br>
+            else<br>
+               deinterlace = VL_COMPOSITOR_BOB_TOP;<br>
+            break;<br>
+<br>
+         case VAProcDeinterlacingWeave:<br>
+            deinterlace = VL_COMPOSITOR_WEAVE;<br>
+            break;<br>
+<br>
+         default:<br>
+            return VA_STATUS_ERROR_UNIMPLEMENTED;<br>
+         }<br>
+<br>
+         break;<br>
+      }<br>
+<br>
+      default:<br>
+         return VA_STATUS_ERROR_UNIMPLEMENTED;<br>
+      }<br>
+   }<br>
+<br>
    src_region = vlVaRegionDefault(param->surface_region, src_surface->buffer, &def_src_region);<br>
    dst_region = vlVaRegionDefault(param->output_region, context->target, &def_dst_region);<br>
<br>
    if (context->target->buffer_format != PIPE_FORMAT_NV12)<br>
       return vlVaPostProcCompositor(drv, context, src_region, dst_region,<br>
-                                    src_surface->buffer, context->target);<br>
+                                    src_surface->buffer, context->target,<br>
+                                    deinterlace);<br>
    else<br>
       return vlVaPostProcBlit(drv, context, src_region, dst_region,<br>
-                              src_surface->buffer, context->target);<br>
+                              src_surface->buffer, context->target,<br>
+                              deinterlace);<br>
 }<br>
diff --git a/src/gallium/state_trackers/va/surface.c b/src/gallium/state_trackers/va/surface.c<br>
index 5ddaf04..d37f89c 100644<br>
--- a/src/gallium/state_trackers/va/surface.c<br>
+++ b/src/gallium/state_trackers/va/surface.c<br>
@@ -649,7 +649,7 @@ vlVaQueryVideoProcFilters(VADriverContextP ctx, VAContextID context,<br>
    if (!num_filters || !filters)<br>
       return VA_STATUS_ERROR_INVALID_PARAMETER;<br>
<br>
-   filters[num++] = VAProcFilterNone;<br>
+   filters[num++] = VAProcFilterDeinterlacing;<br>
<br>
    *num_filters = num;<br>
<br>
@@ -674,8 +674,20 @@ vlVaQueryVideoProcFilterCaps(VADriverContextP ctx, VAContextID context,<br>
    switch (type) {<br>
    case VAProcFilterNone:<br>
       break;<br>
+   case VAProcFilterDeinterlacing: {<br>
+      VAProcFilterCapDeinterlacing *deint = filter_caps;<br>
+<br>
+      if (*num_filter_caps < 2) {<br>
+         *num_filter_caps = 2;<br>
+         return VA_STATUS_ERROR_MAX_NUM_EXCEEDED;<br>
+      }<br>
+<br>
+      deint[i++].type = VAProcDeinterlacingBob;<br>
+      deint[i++].type = VAProcDeinterlacingWeave;<br>
+      break;<br>
+   }<br>
+<br>
    case VAProcFilterNoiseReduction:<br>
-   case VAProcFilterDeinterlacing:<br>
    case VAProcFilterSharpening:<br>
    case VAProcFilterColorBalance:<br>
    case VAProcFilterSkinToneEnhancement:<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.5.0<br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div>