Hi,

vaQueryImageFormats() returns the image formats supported by vaCreateImage(). However, some implementations may not support vaGetImage() or vaPutImage() with a particular format. In that case, it may be interesting to know about it beforehand, instead of having the user test the outcome of va{Get,Put}Image() and try another format.

It should also be possible to provide a default implementation right into va/va.c.

WDYT?

Regards,
Gwenole.
From 24b72ce13405de975ea6019ac435cda6d5729348 Mon Sep 17 00:00:00 2001
From: Gwenole Beauchesne <[email protected]>
Date: Tue, 23 Nov 2010 01:19:25 +0100
Subject: [PATCH] Add vaQuery{Get,Put}ImageFormats().

---
 va/va.c         |   34 ++++++++++++++++++++++++++++++++++
 va/va.h         |   38 ++++++++++++++++++++++++++++++++++++++
 va/va_backend.h |   12 ++++++++++++
 3 files changed, 84 insertions(+), 0 deletions(-)

diff --git a/va/va.c b/va/va.c
index 268ba36..d7e849b 100644
--- a/va/va.c
+++ b/va/va.c
@@ -865,6 +865,40 @@ VAStatus vaQueryImageFormats (
   return ctx->vtable.vaQueryImageFormats ( ctx, format_list, num_formats);
 }
 
+VAStatus
+vaQueryGetImageFormats(
+    VADisplay      dpy,
+    VAImageFormat *format_list, /* out */
+    int           *num_formats  /* out */
+)
+{
+    VADriverContextP ctx;
+
+    CHECK_DISPLAY(dpy);
+    ctx = CTX(dpy);
+
+    if (ctx->vtable.vaQueryGetImageFormats)
+        return ctx->vtable.vaQueryGetImageFormats(ctx, format_list, num_formats);
+    return VA_STATUS_ERROR_UNIMPLEMENTED;
+}
+
+VAStatus
+vaQueryPutImageFormats(
+    VADisplay      dpy,
+    VAImageFormat *format_list, /* out */
+    int           *num_formats  /* out */
+)
+{
+    VADriverContextP ctx;
+
+    CHECK_DISPLAY(dpy);
+    ctx = CTX(dpy);
+
+    if (ctx->vtable.vaQueryPutImageFormats)
+        return ctx->vtable.vaQueryPutImageFormats(ctx, format_list, num_formats);
+    return VA_STATUS_ERROR_UNIMPLEMENTED;
+}
+
 /* 
  * The width and height fields returned in the VAImage structure may get 
  * enlarged for some YUV formats. The size of the data buffer that needs
diff --git a/va/va.h b/va/va.h
index 7f24a85..99c9c19 100644
--- a/va/va.h
+++ b/va/va.h
@@ -1568,6 +1568,25 @@ VAStatus vaSetImagePalette (
     unsigned char *palette 
 );
 
+/**
+ * Query image formats supported for vaGetImage()
+ *
+ * The caller must provide a format_list array that can hold at least
+ * vaMaxNumImageFormats() entries. The actual number of formats
+ * returned in format_list is returned in num_formats.
+ *
+ * @param[in]  dpy         the VA display
+ * @param[out] format_list the supported VA image formats for vaGetImage()
+ * @param[out] num_formats the actual number of formats in format_list
+ * @return VA_STATUS_SUCCESS if successful
+ */
+VAStatus
+vaQueryGetImageFormats(
+    VADisplay      dpy,
+    VAImageFormat *format_list, /* out */
+    int           *num_formats  /* out */
+);
+
 /*
  * Retrive surface data into a VAImage
  * Image must be in a format supported by the implementation
@@ -1582,6 +1601,25 @@ VAStatus vaGetImage (
     VAImageID image
 );
 
+/**
+ * Query image formats supported for vaPutImage()
+ *
+ * The caller must provide a format_list array that can hold at least
+ * vaMaxNumImageFormats() entries. The actual number of formats
+ * returned in format_list is returned in num_formats.
+ *
+ * @param[in]  dpy         the VA display
+ * @param[out] format_list the supported VA image formats for vaPutImage()
+ * @param[out] num_formats the actual number of formats in format_list
+ * @return VA_STATUS_SUCCESS if successful
+ */
+VAStatus
+vaQueryPutImageFormats(
+    VADisplay      dpy,
+    VAImageFormat *format_list, /* out */
+    int           *num_formats  /* out */
+);
+
 /*
  * Copy data from a VAImage to a surface
  * Image must be in a format supported by the implementation
diff --git a/va/va_backend.h b/va/va_backend.h
index 62ac970..1c4edc9 100644
--- a/va/va_backend.h
+++ b/va/va_backend.h
@@ -374,6 +374,18 @@ struct VADriverVTable
 
         /* Optional: GLX support hooks */
         struct VADriverVTableGLX *glx;
+
+	VAStatus (*vaQueryGetImageFormats)(
+            VADriverContextP ctx,
+            VAImageFormat  *format_list, /* out */
+            int            *num_formats  /* out */
+	);
+
+	VAStatus (*vaQueryPutImageFormats)(
+            VADriverContextP ctx,
+            VAImageFormat  *format_list, /* out */
+            int            *num_formats  /* out */
+	);
 };
 
 struct VADriverContext
-- 
1.5.4.3

_______________________________________________
Libva mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/libva

Reply via email to