[Mesa-dev] [PATCH 2/3] st/va move YUV content to deinterlaced buffer

Leo Liu leo.liu at amd.com
Fri Aug 25 14:55:48 UTC 2017


When reallocation for encoder

v2: use deinterlace common function
v3: make sure deinterlace only 
v4: bail out when reallocation for interlaced buffer

Signed-off-by: Leo Liu <leo.liu at amd.com>
---
 src/gallium/state_trackers/va/picture.c | 25 ++++++++++++++++++++-----
 1 file changed, 20 insertions(+), 5 deletions(-)

diff --git a/src/gallium/state_trackers/va/picture.c b/src/gallium/state_trackers/va/picture.c
index 47e63d3b30..76434ee721 100644
--- a/src/gallium/state_trackers/va/picture.c
+++ b/src/gallium/state_trackers/va/picture.c
@@ -626,10 +626,20 @@ vlVaEndPicture(VADriverContextP ctx, VAContextID context_id)
                                         PIPE_VIDEO_CAP_SUPPORTS_INTERLACED);
 
    if (surf->buffer->interlaced != interlaced) {
-      surf->templat.interlaced = screen->get_video_param(screen, context->decoder->profile,
-                                                         PIPE_VIDEO_ENTRYPOINT_BITSTREAM,
-                                                         PIPE_VIDEO_CAP_PREFERS_INTERLACED);
-      realloc = true;
+      interlaced = screen->get_video_param(screen, context->decoder->profile,
+                                           context->decoder->entrypoint,
+                                           PIPE_VIDEO_CAP_PREFERS_INTERLACED);
+      if (!interlaced) {
+         /* The current cases for buffer reallocation are
+            all from the interlaced to the deinterlaced,
+            and there is no case for the other way around */
+         surf->templat.interlaced = false;
+         realloc = true;
+      } else {
+         mtx_unlock(&drv->mutex);
+         return VA_STATUS_ERROR_INVALID_SURFACE;
+      }
+
    }
 
    format = screen->get_video_param(screen, context->decoder->profile,
@@ -657,13 +667,18 @@ vlVaEndPicture(VADriverContextP ctx, VAContextID context_id)
    }
 
    if (realloc) {
-      surf->buffer->destroy(surf->buffer);
+      struct pipe_video_buffer *old_buf = surf->buffer;
 
       if (vlVaHandleSurfaceAllocate(ctx, surf, &surf->templat) != VA_STATUS_SUCCESS) {
+         old_buf->destroy(old_buf);
          mtx_unlock(&drv->mutex);
          return VA_STATUS_ERROR_ALLOCATION_FAILED;
       }
 
+      if (context->decoder->entrypoint == PIPE_VIDEO_ENTRYPOINT_ENCODE)
+         vl_compositor_yuv_deint(&drv->cstate, &drv->compositor, old_buf, surf->buffer);
+
+      old_buf->destroy(old_buf);
       context->target = surf->buffer;
    }
 
-- 
2.11.0



More information about the mesa-dev mailing list