plugins: integrate GstVaapiVideoMeta from libgstvaapi.

Move GstVaapiVideoMeta from core libgstvaapi decoding library to the
actual plugin elements. That's only useful there. Also inline reference
counting code from GstVaapiMiniObject.
This commit is contained in:
Gwenole Beauchesne 2013-03-26 10:31:10 +01:00
parent 63fedf6767
commit 140fa66be3
13 changed files with 80 additions and 73 deletions

View file

@ -171,34 +171,6 @@ GST_VAAPI_IS_IMAGE_POOL_CLASS
GST_VAAPI_IMAGE_POOL_GET_CLASS
</SECTION>
<SECTION>
<FILE>gstvaapivideometa</FILE>
<TITLE>GstVaapiVideoMeta</TITLE>
gst_vaapi_video_meta_new
gst_vaapi_video_meta_new_from_pool
gst_vaapi_video_meta_new_with_image
gst_vaapi_video_meta_new_with_surface
gst_vaapi_video_meta_new_with_surface_proxy
gst_vaapi_video_meta_ref
gst_vaapi_video_meta_unref
gst_vaapi_video_meta_replace
gst_vaapi_video_meta_get_display
gst_vaapi_video_meta_get_image
gst_vaapi_video_meta_set_image
gst_vaapi_video_meta_set_image_from_pool
gst_vaapi_video_meta_get_surface
gst_vaapi_video_meta_set_surface
gst_vaapi_video_meta_set_surface_from_pool
gst_vaapi_video_meta_set_surface_converter
gst_vaapi_video_meta_get_surface_converter
gst_vaapi_video_meta_get_surface_proxy
gst_vaapi_video_meta_set_surface_proxy
gst_vaapi_video_meta_get_render_flags
gst_vaapi_video_meta_set_render_flags
<SUBSECTION Standard>
gst_vaapi_video_meta_get_type
</SECTION>
<SECTION>
<FILE>gstvaapitypes</FILE>
<TITLE>Basic data structures</TITLE>

View file

@ -68,7 +68,6 @@ libgstvaapi_source_c = \
gstvaapisurfaceproxy.c \
gstvaapiutils.c \
gstvaapivalue.c \
gstvaapivideometa.c \
gstvaapivideopool.c \
gstvaapiwindow.c \
$(NULL)
@ -94,7 +93,6 @@ libgstvaapi_source_h = \
gstvaapisurfaceproxy.h \
gstvaapitypes.h \
gstvaapivalue.h \
gstvaapivideometa.h \
gstvaapivideopool.h \
gstvaapiwindow.h \
$(NULL)

View file

@ -39,6 +39,7 @@ libgstvaapi_source_c = \
gstvaapiupload.c \
gstvaapiuploader.c \
gstvaapivideobuffer.c \
gstvaapivideometa.c \
$(NULL)
libgstvaapi_source_h = \
@ -50,6 +51,7 @@ libgstvaapi_source_h = \
gstvaapiupload.h \
gstvaapiuploader.h \
gstvaapivideobuffer.h \
gstvaapivideometa.h \
$(NULL)
if USE_GLX

View file

@ -30,7 +30,6 @@
#include "gst/vaapi/sysdeps.h"
#include <gst/vaapi/gstvaapidisplay.h>
#include <gst/vaapi/gstvaapivideometa.h>
#include <gst/video/videocontext.h>
#include "gstvaapidecode.h"

View file

@ -31,7 +31,6 @@
#include <gst/gst.h>
#include <gst/video/video.h>
#include <gst/video/videocontext.h>
#include <gst/vaapi/gstvaapivideometa.h>
#include "gstvaapidownload.h"
#include "gstvaapipluginutil.h"

View file

@ -31,7 +31,6 @@
#include "gst/vaapi/sysdeps.h"
#include <gst/video/video.h>
#include <gst/video/videocontext.h>
#include <gst/vaapi/gstvaapivideometa.h>
#include "gstvaapipostproc.h"
#include "gstvaapipluginutil.h"

View file

@ -34,7 +34,6 @@
#include <gst/video/video.h>
#include <gst/video/videocontext.h>
#include <gst/vaapi/gstvaapivalue.h>
#include <gst/vaapi/gstvaapivideometa.h>
#if USE_DRM
# include <gst/vaapi/gstvaapidisplay_drm.h>
#endif
@ -56,6 +55,7 @@
#include "gstvaapisink.h"
#include "gstvaapipluginutil.h"
#include "gstvaapivideometa.h"
#define GST_PLUGIN_NAME "vaapisink"
#define GST_PLUGIN_DESC "A VA-API based videosink"

View file

@ -32,7 +32,6 @@
#include <gst/gst.h>
#include <gst/video/video.h>
#include <gst/video/videocontext.h>
#include <gst/vaapi/gstvaapivideometa.h>
#include "gstvaapiupload.h"
#include "gstvaapipluginutil.h"

View file

@ -26,7 +26,6 @@
#include <gst/vaapi/gstvaapisurface.h>
#include <gst/vaapi/gstvaapiimagepool.h>
#include <gst/vaapi/gstvaapisurfacepool.h>
#include <gst/vaapi/gstvaapivideometa.h>
#include "gstvaapiuploader.h"
#include "gstvaapivideobuffer.h"

View file

@ -23,7 +23,7 @@
#ifndef GST_VAAPI_VIDEO_BUFFER_H
#define GST_VAAPI_VIDEO_BUFFER_H
#include <gst/vaapi/gstvaapivideometa.h>
#include "gstvaapivideometa.h"
G_BEGIN_DECLS

View file

@ -22,10 +22,10 @@
*/
#include "gst/vaapi/sysdeps.h"
#include <gst/vaapi/gstvaapivideometa.h>
#include <gst/vaapi/gstvaapitexture.h>
#include "gstvaapivideoconverter_glx.h"
#include "gstvaapipluginutil.h"
#include "gstvaapivideometa.h"
typedef gboolean (*GstSurfaceUploadFunction)(GstSurfaceConverter *,
GstSurfaceBuffer *);

View file

@ -25,15 +25,13 @@
* @short_description: VA video meta for GStreamer
*/
#include "sysdeps.h"
#include "gst/vaapi/sysdeps.h"
#include <gst/vaapi/gstvaapiimagepool.h>
#include <gst/vaapi/gstvaapisurfacepool.h>
#include "gstvaapivideometa.h"
#include "gstvaapiminiobject.h"
#include "gstvaapiimagepool.h"
#include "gstvaapisurfacepool.h"
#include "gstvaapiobject_priv.h"
#define DEBUG 1
#include "gstvaapidebug.h"
#define GST_VAAPI_TYPE_VIDEO_META \
(gst_vaapi_video_meta_get_type())
#define GST_VAAPI_VIDEO_META(obj) \
((GstVaapiVideoMeta *)(obj))
@ -42,6 +40,7 @@
(GST_VAAPI_VIDEO_META(obj) != NULL)
struct _GstVaapiVideoMeta {
gint ref_count;
GstVaapiDisplay *display;
GstVaapiVideoPool *image_pool;
GstVaapiImage *image;
@ -65,14 +64,14 @@ static inline void
set_image(GstVaapiVideoMeta *meta, GstVaapiImage *image)
{
meta->image = g_object_ref(image);
set_display(meta, GST_VAAPI_OBJECT_DISPLAY(image));
set_display(meta, gst_vaapi_object_get_display(GST_VAAPI_OBJECT(image)));
}
static inline void
set_surface(GstVaapiVideoMeta *meta, GstVaapiSurface *surface)
{
meta->surface = g_object_ref(surface);
set_display(meta, GST_VAAPI_OBJECT_DISPLAY(surface));
set_display(meta, gst_vaapi_object_get_display(GST_VAAPI_OBJECT(surface)));
}
static void
@ -101,7 +100,7 @@ gst_vaapi_video_meta_destroy_surface(GstVaapiVideoMeta *meta)
g_clear_object(&meta->surface_pool);
}
GType
static GType
gst_vaapi_video_meta_get_type(void)
{
static gsize g_type;
@ -127,6 +126,7 @@ gst_vaapi_video_meta_finalize(GstVaapiVideoMeta *meta)
static void
gst_vaapi_video_meta_init(GstVaapiVideoMeta *meta)
{
meta->ref_count = 1;
meta->display = NULL;
meta->image_pool = NULL;
meta->image = NULL;
@ -137,28 +137,29 @@ gst_vaapi_video_meta_init(GstVaapiVideoMeta *meta)
meta->render_flags = 0;
}
static inline const GstVaapiMiniObjectClass *
gst_vaapi_video_meta_class(void)
{
static const GstVaapiMiniObjectClass GstVaapiVideoMetaClass = {
sizeof(GstVaapiVideoMeta),
(GDestroyNotify)gst_vaapi_video_meta_finalize
};
return &GstVaapiVideoMetaClass;
}
static inline GstVaapiVideoMeta *
_gst_vaapi_video_meta_new(void)
{
GstVaapiVideoMeta *meta;
meta = (GstVaapiVideoMeta *)
gst_vaapi_mini_object_new(gst_vaapi_video_meta_class());
if (meta)
gst_vaapi_video_meta_init(meta);
meta = g_slice_alloc(sizeof(*meta));
if (!meta)
return NULL;
gst_vaapi_video_meta_init(meta);
return meta;
}
static inline void
_gst_vaapi_video_meta_free(GstVaapiVideoMeta *meta)
{
g_atomic_int_inc(&meta->ref_count);
gst_vaapi_video_meta_finalize(meta);
if (G_LIKELY(g_atomic_int_dec_and_test(&meta->ref_count)))
g_slice_free1(sizeof(*meta), meta);
}
/**
* gst_vaapi_video_meta_new:
* @display: a #GstVaapiDisplay
@ -317,8 +318,10 @@ gst_vaapi_video_meta_new_with_surface_proxy(GstVaapiSurfaceProxy *proxy)
GstVaapiVideoMeta *
gst_vaapi_video_meta_ref(GstVaapiVideoMeta *meta)
{
return (GstVaapiVideoMeta *)
gst_vaapi_mini_object_ref(GST_VAAPI_MINI_OBJECT(meta));
g_return_val_if_fail(meta != NULL, NULL);
g_atomic_int_inc(&meta->ref_count);
return meta;
}
/**
@ -331,7 +334,11 @@ gst_vaapi_video_meta_ref(GstVaapiVideoMeta *meta)
void
gst_vaapi_video_meta_unref(GstVaapiVideoMeta *meta)
{
gst_vaapi_mini_object_unref(GST_VAAPI_MINI_OBJECT(meta));
g_return_if_fail(meta != NULL);
g_return_if_fail(meta->ref_count > 0);
if (g_atomic_int_dec_and_test(&meta->ref_count))
_gst_vaapi_video_meta_free(meta);
}
/**
@ -347,8 +354,24 @@ void
gst_vaapi_video_meta_replace(GstVaapiVideoMeta **old_meta_ptr,
GstVaapiVideoMeta *new_meta)
{
gst_vaapi_mini_object_replace((GstVaapiMiniObject **)(old_meta_ptr),
(GstVaapiMiniObject *)(new_meta));
GstVaapiVideoMeta *old_meta;
g_return_if_fail(old_meta_ptr != NULL);
old_meta = g_atomic_pointer_get((gpointer *)old_meta_ptr);
if (old_meta == new_meta)
return;
if (new_meta)
gst_vaapi_video_meta_ref(new_meta);
while (!g_atomic_pointer_compare_and_exchange((gpointer *)old_meta_ptr,
old_meta, new_meta))
old_meta = g_atomic_pointer_get((gpointer *)old_meta_ptr);
if (old_meta)
gst_vaapi_video_meta_unref(old_meta);
}
/**

View file

@ -31,85 +31,102 @@
G_BEGIN_DECLS
#define GST_VAAPI_TYPE_VIDEO_META \
(gst_vaapi_video_meta_get_type())
typedef struct _GstVaapiVideoMeta GstVaapiVideoMeta;
GType
gst_vaapi_video_meta_get_type(void) G_GNUC_CONST;
G_GNUC_INTERNAL
GstVaapiVideoMeta *
gst_vaapi_video_meta_new(GstVaapiDisplay *display);
G_GNUC_INTERNAL
GstVaapiVideoMeta *
gst_vaapi_video_meta_new_from_pool(GstVaapiVideoPool *pool);
G_GNUC_INTERNAL
GstVaapiVideoMeta *
gst_vaapi_video_meta_new_with_image(GstVaapiImage *image);
G_GNUC_INTERNAL
GstVaapiVideoMeta *
gst_vaapi_video_meta_new_with_surface(GstVaapiSurface *surface);
G_GNUC_INTERNAL
GstVaapiVideoMeta *
gst_vaapi_video_meta_new_with_surface_proxy(GstVaapiSurfaceProxy *proxy);
G_GNUC_INTERNAL
GstVaapiVideoMeta *
gst_vaapi_video_meta_ref(GstVaapiVideoMeta *meta);
G_GNUC_INTERNAL
void
gst_vaapi_video_meta_unref(GstVaapiVideoMeta *meta);
G_GNUC_INTERNAL
void
gst_vaapi_video_meta_replace(GstVaapiVideoMeta **old_meta_ptr,
GstVaapiVideoMeta *new_meta);
G_GNUC_INTERNAL
GstVaapiDisplay *
gst_vaapi_video_meta_get_display(GstVaapiVideoMeta *meta);
G_GNUC_INTERNAL
GstVaapiImage *
gst_vaapi_video_meta_get_image(GstVaapiVideoMeta *meta);
G_GNUC_INTERNAL
void
gst_vaapi_video_meta_set_image(GstVaapiVideoMeta *meta, GstVaapiImage *image);
G_GNUC_INTERNAL
gboolean
gst_vaapi_video_meta_set_image_from_pool(GstVaapiVideoMeta *meta,
GstVaapiVideoPool *pool);
G_GNUC_INTERNAL
GstVaapiSurface *
gst_vaapi_video_meta_get_surface(GstVaapiVideoMeta *meta);
G_GNUC_INTERNAL
void
gst_vaapi_video_meta_set_surface(GstVaapiVideoMeta *meta,
GstVaapiSurface *surface);
G_GNUC_INTERNAL
gboolean
gst_vaapi_video_meta_set_surface_from_pool(GstVaapiVideoMeta *meta,
GstVaapiVideoPool *pool);
G_GNUC_INTERNAL
GstVaapiSurfaceProxy *
gst_vaapi_video_meta_get_surface_proxy(GstVaapiVideoMeta *meta);
G_GNUC_INTERNAL
void
gst_vaapi_video_meta_set_surface_proxy(GstVaapiVideoMeta *meta,
GstVaapiSurfaceProxy *proxy);
G_GNUC_INTERNAL
GFunc
gst_vaapi_video_meta_get_surface_converter(GstVaapiVideoMeta *meta);
G_GNUC_INTERNAL
void
gst_vaapi_video_meta_set_surface_converter(GstVaapiVideoMeta *meta, GFunc func);
G_GNUC_INTERNAL
guint
gst_vaapi_video_meta_get_render_flags(GstVaapiVideoMeta *meta);
G_GNUC_INTERNAL
void
gst_vaapi_video_meta_set_render_flags(GstVaapiVideoMeta *meta, guint flags);
G_GNUC_INTERNAL
GstVaapiVideoMeta *
gst_buffer_get_vaapi_video_meta(GstBuffer *buffer);
G_GNUC_INTERNAL
void
gst_buffer_set_vaapi_video_meta(GstBuffer *buffer, GstVaapiVideoMeta *meta);