2 * gstvaapivideomemory.h - Gstreamer/VA video memory
4 * Copyright (C) 2013 Intel Corporation
5 * Author: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public License
9 * as published by the Free Software Foundation; either version 2.1
10 * of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free
19 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 * Boston, MA 02110-1301 USA
23 #ifndef GST_VAAPI_VIDEO_MEMORY_H
24 #define GST_VAAPI_VIDEO_MEMORY_H
26 #include <gst/gstallocator.h>
27 #include <gst/video/video-info.h>
28 #include <gst/vaapi/gstvaapidisplay.h>
29 #include <gst/vaapi/gstvaapisurfacepool.h>
30 #include "gstvaapivideometa.h"
34 typedef struct _GstVaapiVideoMemory GstVaapiVideoMemory;
35 typedef struct _GstVaapiVideoAllocator GstVaapiVideoAllocator;
36 typedef struct _GstVaapiVideoAllocatorClass GstVaapiVideoAllocatorClass;
38 /* ------------------------------------------------------------------------ */
39 /* --- GstVaapiVideoMemory --- */
40 /* ------------------------------------------------------------------------ */
42 #define GST_VAAPI_VIDEO_MEMORY_CAST(mem) \
43 ((GstVaapiVideoMemory *)(mem))
45 #define GST_VAAPI_VIDEO_MEMORY_NAME "GstVaapiVideoMemory"
47 #if GST_CHECK_VERSION(1,1,0)
48 #define GST_CAPS_FEATURE_MEMORY_VAAPI_SURFACE "memory:VASurface"
52 * GstVaapiVideoMemoryMapType:
53 * @GST_VAAPI_VIDEO_MEMORY_MAP_TYPE_SURFACE: map with gst_buffer_map()
54 * and flags = 0x00 to return a #GstVaapiSurfaceProxy
55 * @GST_VAAPI_VIDEO_MEMORY_MAP_TYPE_PLANAR: map individual plane with
56 * gst_video_frame_map()
57 * @GST_VAAPI_VIDEO_MEMORY_MAP_TYPE_LINEAR: map with gst_buffer_map()
58 * and flags = GST_MAP_READ to return the raw pixels of the whole image
60 * The set of all #GstVaapiVideoMemory map types.
63 GST_VAAPI_VIDEO_MEMORY_MAP_TYPE_SURFACE = 1,
64 GST_VAAPI_VIDEO_MEMORY_MAP_TYPE_PLANAR,
65 GST_VAAPI_VIDEO_MEMORY_MAP_TYPE_LINEAR
66 } GstVaapiVideoMemoryMapType;
69 * GstVaapiVideoMemory:
71 * A VA video memory object holder, including VA surfaces, images and
74 struct _GstVaapiVideoMemory {
75 GstMemory parent_instance;
78 GstVaapiSurfaceProxy *proxy;
79 const GstVideoInfo *surface_info;
80 GstVaapiSurface *surface;
81 const GstVideoInfo *image_info;
83 GstVaapiVideoMeta *meta;
86 gboolean use_direct_rendering;
91 gst_vaapi_video_memory_new(GstAllocator *allocator, GstVaapiVideoMeta *meta);
95 gst_video_meta_map_vaapi_memory(GstVideoMeta *meta, guint plane,
96 GstMapInfo *info, gpointer *data, gint *stride, GstMapFlags flags);
100 gst_video_meta_unmap_vaapi_memory(GstVideoMeta *meta, guint plane,
105 gst_vaapi_video_memory_reset_surface(GstVaapiVideoMemory *mem);
107 /* ------------------------------------------------------------------------ */
108 /* --- GstVaapiVideoAllocator --- */
109 /* ------------------------------------------------------------------------ */
111 #define GST_VAAPI_VIDEO_ALLOCATOR_CAST(allocator) \
112 ((GstVaapiVideoAllocator *)(allocator))
114 #define GST_VAAPI_TYPE_VIDEO_ALLOCATOR \
115 (gst_vaapi_video_allocator_get_type())
117 #define GST_VAAPI_VIDEO_ALLOCATOR(obj) \
118 (G_TYPE_CHECK_INSTANCE_CAST((obj), \
119 GST_VAAPI_TYPE_VIDEO_ALLOCATOR, \
120 GstVaapiVideoAllocator))
122 #define GST_VAAPI_IS_VIDEO_ALLOCATOR(obj) \
123 (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_VAAPI_TYPE_VIDEO_ALLOCATOR))
125 #define GST_VAAPI_VIDEO_ALLOCATOR_NAME "GstVaapiVideoAllocator"
128 * GstVaapiVideoAllocator:
130 * A VA video memory allocator object.
132 struct _GstVaapiVideoAllocator {
133 GstAllocator parent_instance;
136 GstVideoInfo video_info;
137 GstVideoInfo surface_info;
138 GstVaapiVideoPool *surface_pool;
139 GstVideoInfo image_info;
140 gboolean has_direct_rendering;
144 * GstVaapiVideoAllocatorClass:
146 * A VA video memory allocator class.
148 struct _GstVaapiVideoAllocatorClass {
149 GstAllocatorClass parent_class;
154 gst_vaapi_video_allocator_get_type(void) G_GNUC_CONST;
158 gst_vaapi_video_allocator_new(GstVaapiDisplay *display,
159 const GstVideoInfo *vip);
163 #endif /* GST_VAAPI_VIDEO_MEMORY_H */