[Mesa-dev] [PATCH 09/15] st/va: implement vlVa(Begin|Render|End)Picture

Christian König deathsimple at vodafone.de
Tue Jun 18 02:27:39 PDT 2013


From: Christian König <christian.koenig at amd.com>

Signed-off-by: Christian König <christian.koenig at amd.com>
---
 src/gallium/state_trackers/va/picture.c    |   88 ++++++++++++++++++++++++++--
 src/gallium/state_trackers/va/surface.c    |    3 +-
 src/gallium/state_trackers/va/va_private.h |    5 +-
 3 files changed, 87 insertions(+), 9 deletions(-)

diff --git a/src/gallium/state_trackers/va/picture.c b/src/gallium/state_trackers/va/picture.c
index 66612b8..8d16dfa 100644
--- a/src/gallium/state_trackers/va/picture.c
+++ b/src/gallium/state_trackers/va/picture.c
@@ -26,31 +26,107 @@
  *
  **************************************************************************/
 
+#include "pipe/p_video_decoder.h"
+
+#include "util/u_handle_table.h"
+
 #include "va_private.h"
 
 VAStatus
-vlVaBeginPicture(VADriverContextP ctx, VAContextID context, VASurfaceID render_target)
+vlVaBeginPicture(VADriverContextP ctx, VAContextID context_id, VASurfaceID render_target)
 {
+   vlVaDriver *drv;
+   vlVaContext *context;
+   vlVaSurface *surf;
+
    if (!ctx)
       return VA_STATUS_ERROR_INVALID_CONTEXT;
 
-   return VA_STATUS_ERROR_UNIMPLEMENTED;
+   drv = VL_VA_DRIVER(ctx);
+   if (!drv)
+      return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+   context = handle_table_get(drv->htab, context_id);
+   if (!context)
+      return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+   surf = handle_table_get(drv->htab, render_target);
+   if (!surf || !surf->buffer)
+      return VA_STATUS_ERROR_INVALID_SURFACE;
+
+   context->target = surf->buffer;
+   context->decoder->begin_frame(context->decoder, context->target, NULL);
+
+   return VA_STATUS_SUCCESS;
 }
 
 VAStatus
-vlVaRenderPicture(VADriverContextP ctx, VAContextID context, VABufferID *buffers, int num_buffers)
+vlVaRenderPicture(VADriverContextP ctx, VAContextID context_id, VABufferID *buffers, int num_buffers)
 {
+   vlVaDriver *drv;
+   vlVaContext *context;
+
+   unsigned i;
+
    if (!ctx)
       return VA_STATUS_ERROR_INVALID_CONTEXT;
 
-   return VA_STATUS_ERROR_UNIMPLEMENTED;
+   drv = VL_VA_DRIVER(ctx);
+   if (!drv)
+      return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+   context = handle_table_get(drv->htab, context_id);
+   if (!context)
+      return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+   for (i = 0; i < num_buffers; ++i) {
+      vlVaBuffer *buf = handle_table_get(drv->htab, buffers[i]);
+      if (!buf)
+         return VA_STATUS_ERROR_INVALID_BUFFER;
+
+      switch (buf->type) {
+      case VAPictureParameterBufferType:
+         // TODO
+         break;
+
+      case VAIQMatrixBufferType:
+         // TODO
+         break;
+
+      case VASliceParameterBufferType:
+         // TODO
+         break;
+
+      case VASliceDataBufferType:
+         // TODO
+         break;
+
+      default:
+         return VA_STATUS_ERROR_INVALID_BUFFER;
+      }
+   }
+
+   return VA_STATUS_SUCCESS;
 }
 
 VAStatus
-vlVaEndPicture(VADriverContextP ctx, VAContextID context)
+vlVaEndPicture(VADriverContextP ctx, VAContextID context_id)
 {
+   vlVaDriver *drv;
+   vlVaContext *context;
+
    if (!ctx)
       return VA_STATUS_ERROR_INVALID_CONTEXT;
 
-   return VA_STATUS_ERROR_UNIMPLEMENTED;
+   drv = VL_VA_DRIVER(ctx);
+   if (!drv)
+      return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+   context = handle_table_get(drv->htab, context_id);
+   if (!context)
+      return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+   context->decoder->end_frame(context->decoder, context->target, &context->desc.base);
+
+   return VA_STATUS_SUCCESS;
 }
diff --git a/src/gallium/state_trackers/va/surface.c b/src/gallium/state_trackers/va/surface.c
index 5b54d7c..7641ded 100644
--- a/src/gallium/state_trackers/va/surface.c
+++ b/src/gallium/state_trackers/va/surface.c
@@ -27,6 +27,7 @@
  **************************************************************************/
 
 #include "pipe/p_screen.h"
+#include "pipe/p_video_decoder.h"
 
 #include "util/u_memory.h"
 #include "util/u_handle_table.h"
@@ -73,7 +74,7 @@ vlVaCreateSurfaces(VADriverContextP ctx, int width, int height, int format,
       if (!surf)
          goto no_res;
 
-      surf->templat = templat;
+      surf->buffer = drv->pipe->create_video_buffer(drv->pipe, &templat);
       surfaces[i] = handle_table_add(drv->htab, surf);
    }
 
diff --git a/src/gallium/state_trackers/va/va_private.h b/src/gallium/state_trackers/va/va_private.h
index caa8c4a..58b787d 100644
--- a/src/gallium/state_trackers/va/va_private.h
+++ b/src/gallium/state_trackers/va/va_private.h
@@ -35,7 +35,7 @@
 #include <va/va_backend.h>
 
 #include "pipe/p_video_enums.h"
-#include "pipe/p_video_decoder.h"
+#include "pipe/p_video_state.h"
 
 #define VL_VA_DRIVER(ctx) ((vlVaDriver *)ctx->pDriverData)
 #define VL_VA_PSCREEN(ctx) (VL_VA_DRIVER(ctx)->vscreen->pscreen)
@@ -123,6 +123,7 @@ typedef struct {
 
 typedef struct {
    struct pipe_video_decoder *decoder;
+   struct pipe_video_buffer *target;
    union {
       struct pipe_picture_desc base;
       struct pipe_mpeg12_picture_desc mpeg12;
@@ -140,7 +141,7 @@ typedef struct {
 } vlVaBuffer;
 
 typedef struct {
-   struct pipe_video_buffer templat, *buffer;
+   struct pipe_video_buffer *buffer;
 } vlVaSurface;
 
 // Public functions:
-- 
1.7.9.5



More information about the mesa-dev mailing list