image: clean image API up.
authorGwenole Beauchesne <gwenole.beauchesne@intel.com>
Fri, 26 Jul 2013 10:57:19 +0000 (12:57 +0200)
committerGwenole Beauchesne <gwenole.beauchesne@intel.com>
Fri, 26 Jul 2013 11:16:52 +0000 (13:16 +0200)
Don't expose functions that reference a GstVaapiImageRaw, those are
meant to be internal only for implementing subpictures sync. Also add
a few private definitions to avoid functions calls for retrieving
image size and format information.

docs/reference/libs/libs-sections.txt
gst-libs/gst/vaapi/Makefile.am
gst-libs/gst/vaapi/gstvaapiimage.c
gst-libs/gst/vaapi/gstvaapiimage.h
gst-libs/gst/vaapi/gstvaapiimage_priv.h [new file with mode: 0644]
gst-libs/gst/vaapi/gstvaapisubpicture.c
gst-libs/gst/vaapi/gstvaapisurface.c

index 9b005e6..3c1b03a 100644 (file)
@@ -226,7 +226,6 @@ gst_vaapi_image_get_plane
 gst_vaapi_image_get_pitch
 gst_vaapi_image_get_data_size
 gst_vaapi_image_get_buffer
-gst_vaapi_image_get_raw
 gst_vaapi_image_update_from_buffer
 gst_vaapi_image_copy
 <SUBSECTION Standard>
index d4fa248..a8ccd6f 100644 (file)
@@ -109,6 +109,7 @@ libgstvaapi_source_priv_h =                 \
        gstvaapidecoder_priv.h                  \
        gstvaapidecoder_unit.h                  \
        gstvaapidisplay_priv.h                  \
+       gstvaapiimage_priv.h                    \
        gstvaapiminiobject.h                    \
        gstvaapiobject_priv.h                   \
        gstvaapiparser_frame.h                  \
index 3ddf124..49107ba 100644 (file)
 #include "gstvaapicompat.h"
 #include "gstvaapiutils.h"
 #include "gstvaapiimage.h"
+#include "gstvaapiimage_priv.h"
 #include "gstvaapiobject_priv.h"
 
 #define DEBUG 1
 #include "gstvaapidebug.h"
 
-typedef struct _GstVaapiImageClass              GstVaapiImageClass;
-
-/**
- * GstVaapiImage:
- *
- * A VA image wrapper
- */
-struct _GstVaapiImage {
-    /*< private >*/
-    GstVaapiObject      parent_instance;
-
-    VAImage             internal_image;
-    VAImage             image;
-    guchar             *image_data;
-    GstVideoFormat      internal_format;
-    GstVideoFormat      format;
-    guint               width;
-    guint               height;
-    guint               is_linear       : 1;
-};
-
-/**
- * GstVaapiImageClass:
- *
- * A VA image wrapper class
- */
-struct _GstVaapiImageClass {
-    /*< private >*/
-    GstVaapiObjectClass parent_class;
-};
-
 #define SWAP_UINT(a, b) do { \
         guint v = a;         \
         a = b;               \
index 124bdad..c5c3ed2 100644 (file)
@@ -58,22 +58,6 @@ G_BEGIN_DECLS
 #define GST_VAAPI_IMAGE_HEIGHT(image)   gst_vaapi_image_get_height(image)
 
 typedef struct _GstVaapiImage                   GstVaapiImage;
-typedef struct _GstVaapiImageRaw                GstVaapiImageRaw;
-
-/**
- * GstVaapiImageRaw:
- *
- * A raw image wrapper. The caller is responsible for initializing all
- * the fields with sensible values.
- */
-struct _GstVaapiImageRaw {
-    GstVideoFormat      format;
-    guint               width;
-    guint               height;
-    guint               num_planes;
-    guchar             *pixels[3];
-    guint               stride[3];
-};
 
 GstVaapiImage *
 gst_vaapi_image_new(
@@ -136,13 +120,6 @@ gst_vaapi_image_get_buffer(
 );
 
 gboolean
-gst_vaapi_image_get_raw(
-    GstVaapiImage     *image,
-    GstVaapiImageRaw  *dst_image,
-    GstVaapiRectangle *rect
-);
-
-gboolean
 gst_vaapi_image_update_from_buffer(
     GstVaapiImage     *image,
     GstBuffer         *buffer,
@@ -150,13 +127,6 @@ gst_vaapi_image_update_from_buffer(
 );
 
 gboolean
-gst_vaapi_image_update_from_raw(
-    GstVaapiImage     *image,
-    GstVaapiImageRaw  *src_image,
-    GstVaapiRectangle *rect
-);
-
-gboolean
 gst_vaapi_image_copy(GstVaapiImage *dst_image, GstVaapiImage *src_image);
 
 G_END_DECLS
diff --git a/gst-libs/gst/vaapi/gstvaapiimage_priv.h b/gst-libs/gst/vaapi/gstvaapiimage_priv.h
new file mode 100644 (file)
index 0000000..bc99d05
--- /dev/null
@@ -0,0 +1,126 @@
+/*
+ *  gstvaapiimage_priv.h - VA image abstraction (private definitions)
+ *
+ *  Copyright (C) 2010-2011 Splitted-Desktop Systems
+ *  Copyright (C) 2011-2013 Intel Corporation
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public License
+ *  as published by the Free Software Foundation; either version 2.1
+ *  of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, write to the Free
+ *  Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ *  Boston, MA 02110-1301 USA
+ */
+
+#ifndef GST_VAAPI_IMAGE_PRIV_H
+#define GST_VAAPI_IMAGE_PRIV_H
+
+#include <gst/vaapi/gstvaapiimage.h>
+#include "gstvaapiobject_priv.h"
+
+G_BEGIN_DECLS
+
+typedef struct _GstVaapiImageClass              GstVaapiImageClass;
+typedef struct _GstVaapiImageRaw                GstVaapiImageRaw;
+
+/**
+ * GstVaapiImage:
+ *
+ * A VA image wrapper
+ */
+struct _GstVaapiImage {
+    /*< private >*/
+    GstVaapiObject      parent_instance;
+
+    VAImage             internal_image;
+    VAImage             image;
+    guchar             *image_data;
+    GstVideoFormat      internal_format;
+    GstVideoFormat      format;
+    guint               width;
+    guint               height;
+    guint               is_linear       : 1;
+};
+
+/**
+ * GstVaapiImageClass:
+ *
+ * A VA image wrapper class
+ */
+struct _GstVaapiImageClass {
+    /*< private >*/
+    GstVaapiObjectClass parent_class;
+};
+
+/**
+ * GstVaapiImageRaw:
+ *
+ * A raw image wrapper. The caller is responsible for initializing all
+ * the fields with sensible values.
+ */
+struct _GstVaapiImageRaw {
+    GstVideoFormat      format;
+    guint               width;
+    guint               height;
+    guint               num_planes;
+    guchar             *pixels[3];
+    guint               stride[3];
+};
+
+/**
+ * GST_VAAPI_IMAGE_FORMAT:
+ * @image: a #GstVaapiImage
+ *
+ * Macro that evaluates to the #GstVideoFormat of @image.
+ */
+#undef  GST_VAAPI_IMAGE_FORMAT
+#define GST_VAAPI_IMAGE_FORMAT(image) \
+    (GST_VAAPI_IMAGE(image)->format)
+
+/**
+ * GST_VAAPI_IMAGE_WIDTH:
+ * @image: a #GstVaapiImage
+ *
+ * Macro that evaluates to the width of @image.
+ */
+#undef  GST_VAAPI_IMAGE_WIDTH
+#define GST_VAAPI_IMAGE_WIDTH(image) \
+    (GST_VAAPI_IMAGE(image)->width)
+
+/**
+ * GST_VAAPI_IMAGE_HEIGHT:
+ * @image: a #GstVaapiImage
+ *
+ * Macro that evaluates to the height of @image.
+ */
+#undef  GST_VAAPI_IMAGE_HEIGHT
+#define GST_VAAPI_IMAGE_HEIGHT(image) \
+    (GST_VAAPI_IMAGE(image)->height)
+
+G_GNUC_INTERNAL
+gboolean
+gst_vaapi_image_get_raw(
+    GstVaapiImage     *image,
+    GstVaapiImageRaw  *dst_image,
+    GstVaapiRectangle *rect
+);
+
+G_GNUC_INTERNAL
+gboolean
+gst_vaapi_image_update_from_raw(
+    GstVaapiImage     *image,
+    GstVaapiImageRaw  *src_image,
+    GstVaapiRectangle *rect
+);
+
+G_END_DECLS
+
+#endif /* GST_VAAPI_IMAGE_PRIV_H */
index 92bbb2e..a269df5 100644 (file)
@@ -31,6 +31,7 @@
 #include "gstvaapiutils.h"
 #include "gstvaapisubpicture.h"
 #include "gstvaapiobject_priv.h"
+#include "gstvaapiimage_priv.h"
 
 #define DEBUG 1
 #include "gstvaapidebug.h"
@@ -141,7 +142,7 @@ gst_vaapi_subpicture_new(GstVaapiImage *image, guint flags)
               GST_VAAPI_ID_ARGS(GST_VAAPI_OBJECT_ID(image)));
 
     display = GST_VAAPI_OBJECT_DISPLAY(image);
-    format  = gst_vaapi_image_get_format(image);
+    format  = GST_VAAPI_IMAGE_FORMAT(image);
     if (!gst_vaapi_display_has_subpicture_format(display, format, &va_flags))
         return NULL;
     if (flags & ~va_flags)
index 768a8a9..1a094b7 100644 (file)
@@ -32,6 +32,7 @@
 #include "gstvaapisurface_priv.h"
 #include "gstvaapicontext.h"
 #include "gstvaapiimage.h"
+#include "gstvaapiimage_priv.h"
 
 #define DEBUG 1
 #include "gstvaapidebug.h"
@@ -322,7 +323,7 @@ gst_vaapi_surface_get_format(GstVaapiSurface *surface)
     if (surface->format == GST_VIDEO_FORMAT_UNKNOWN) {
         GstVaapiImage * const image = gst_vaapi_surface_derive_image(surface);
         if (image) {
-            surface->format = gst_vaapi_image_get_format(image);
+            surface->format = GST_VAAPI_IMAGE_FORMAT(image);
             gst_vaapi_object_unref(image);
         }
         if (surface->format == GST_VIDEO_FORMAT_UNKNOWN)
@@ -502,7 +503,8 @@ gst_vaapi_surface_get_image(GstVaapiSurface *surface, GstVaapiImage *image)
     if (!display)
         return FALSE;
 
-    gst_vaapi_image_get_size(image, &width, &height);
+    width  = GST_VAAPI_IMAGE_WIDTH(image);
+    height = GST_VAAPI_IMAGE_HEIGHT(image);
     if (width != surface->width || height != surface->height)
         return FALSE;
 
@@ -549,7 +551,8 @@ gst_vaapi_surface_put_image(GstVaapiSurface *surface, GstVaapiImage *image)
     if (!display)
         return FALSE;
 
-    gst_vaapi_image_get_size(image, &width, &height);
+    width  = GST_VAAPI_IMAGE_WIDTH(image);
+    height = GST_VAAPI_IMAGE_HEIGHT(image);
     if (width != surface->width || height != surface->height)
         return FALSE;
 
@@ -659,11 +662,8 @@ _gst_vaapi_surface_associate_subpicture(
         src_rect                = &src_rect_default;
         src_rect_default.x      = 0;
         src_rect_default.y      = 0;
-        gst_vaapi_image_get_size(
-            image,
-            &src_rect_default.width,
-            &src_rect_default.height
-        );
+        src_rect_default.width  = GST_VAAPI_IMAGE_WIDTH(image);
+        src_rect_default.height = GST_VAAPI_IMAGE_HEIGHT(image);
     }
 
     if (!dst_rect) {