1 /* GStreamer Intel MSDK plugin
2 * Copyright (c) 2018, Intel Corporation
3 * Copyright (c) 2018, Igalia S.L.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
9 * 1. Redistributions of source code must retain the above copyright notice,
10 * this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright notice,
13 * this list of conditions and the following disclaimer in the documentation
14 * and/or other materials provided with the distribution.
16 * 3. Neither the name of the copyright holder nor the names of its contributors
17 * may be used to endorse or promote products derived from this software
18 * without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
24 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGDECE
29 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 #ifndef GST_MSDK_VIDEO_MEMORY_H
34 #define GST_MSDK_VIDEO_MEMORY_H
37 #include "gstmsdkcontext.h"
38 #include "gstmsdkallocator.h"
39 #include <gst/allocators/allocators.h>
43 typedef struct _GstMsdkVideoMemory GstMsdkVideoMemory;
44 typedef struct _GstMsdkVideoAllocator GstMsdkVideoAllocator;
45 typedef struct _GstMsdkVideoAllocatorClass GstMsdkVideoAllocatorClass;
46 typedef struct _GstMsdkDmaBufAllocator GstMsdkDmaBufAllocator;
47 typedef struct _GstMsdkDmaBufAllocatorClass GstMsdkDmaBufAllocatorClass;
49 /* ---------------------------------------------------------------------*/
50 /* GstMsdkVideoMemory */
51 /* ---------------------------------------------------------------------*/
53 #define GST_MSDK_VIDEO_MEMORY_CAST(mem) \
54 ((GstMsdkVideoMemory *) (mem))
56 #define GST_IS_MSDK_VIDEO_MEMORY(mem) \
57 ((mem) && (mem)->allocator && GST_IS_MSDK_VIDEO_ALLOCATOR((mem)->allocator))
59 #define GST_MSDK_VIDEO_MEMORY_NAME "GstMsdkVideoMemory"
64 * A MSDK memory object holder, including mfxFrameSurface,
65 * video info of the surface.
67 struct _GstMsdkVideoMemory
69 GstMemory parent_instance;
71 mfxFrameSurface1 *surface;
76 gst_msdk_video_memory_new (GstAllocator * allocator);
79 gst_msdk_video_memory_get_surface_available (GstMemory * mem);
82 gst_msdk_video_memory_release_surface (GstMemory * mem);
85 gst_video_meta_map_msdk_memory (GstVideoMeta * meta, guint plane,
86 GstMapInfo * info, gpointer * data, gint * stride, GstMapFlags flags);
89 gst_video_meta_unmap_msdk_memory (GstVideoMeta * meta, guint plane,
93 /* ---------------------------------------------------------------------*/
94 /* GstMsdkVideoAllocator */
95 /* ---------------------------------------------------------------------*/
97 #define GST_MSDK_VIDEO_ALLOCATOR_CAST(allocator) \
98 ((GstMsdkVideoAllocator *) (allocator))
100 #define GST_TYPE_MSDK_VIDEO_ALLOCATOR \
101 (gst_msdk_video_allocator_get_type ())
102 #define GST_MSDK_VIDEO_ALLOCATOR(obj) \
103 (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_MSDK_VIDEO_ALLOCATOR, \
104 GstMsdkVideoAllocator))
105 #define GST_IS_MSDK_VIDEO_ALLOCATOR(obj) \
106 (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_MSDK_VIDEO_ALLOCATOR))
109 * GstMsdkVideoAllocator:
111 * A MSDK video memory allocator object.
113 struct _GstMsdkVideoAllocator
115 GstAllocator parent_instance;
117 GstMsdkContext *context;
118 GstVideoInfo image_info;
119 mfxFrameAllocResponse mfx_response;
120 mfxFrameAllocResponse *alloc_response;
124 * GstMsdkVideoAllocatorClass:
126 * A MSDK video memory allocator class.
128 struct _GstMsdkVideoAllocatorClass
130 GstAllocatorClass parent_class;
133 GType gst_msdk_video_allocator_get_type (void);
135 GstAllocator * gst_msdk_video_allocator_new (GstMsdkContext * context,
136 GstVideoInfo *image_info, mfxFrameAllocResponse * alloc_resp);
138 /* ---------------------------------------------------------------------*/
139 /* GstMsdkDmaBufMemory */
140 /* ---------------------------------------------------------------------*/
142 #define GST_MSDK_DMABUF_MEMORY_NAME "GstMsdkDmaBufMemory"
145 gst_msdk_dmabuf_memory_new (GstAllocator * allocator);
148 gst_msdk_dmabuf_memory_new_with_surface (GstAllocator * base_allocator, mfxFrameSurface1 * surface);
150 /* ---------------------------------------------------------------------*/
151 /* GstMsdkDmaBufAllocator */
152 /* ---------------------------------------------------------------------*/
154 #define GST_MSDK_DMABUF_ALLOCATOR_CAST(allocator) \
155 ((GstMsdkDmaBufAllocator *) (allocator))
157 #define GST_TYPE_MSDK_DMABUF_ALLOCATOR \
158 (gst_msdk_dmabuf_allocator_get_type ())
159 #define GST_MSDK_DMABUF_ALLOCATOR(obj) \
160 (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_MSDK_DMABUF_ALLOCATOR, \
161 GstMsdkDmaBufAllocator))
162 #define GST_IS_MSDK_DMABUF_ALLOCATOR(obj) \
163 (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_MSDK_DMABUF_ALLOCATOR))
166 * GstMsdkDmaBufAllocator:
168 * A MSDK DMABuf memory allocator object.
170 struct _GstMsdkDmaBufAllocator
172 GstDmaBufAllocator parent_instance;
174 GstMsdkContext *context;
175 GstVideoInfo image_info;
176 mfxFrameAllocResponse mfx_response;
177 mfxFrameAllocResponse *alloc_response;
181 * GstMsdkDmaBufAllocatorClass:
183 * A MSDK DMABuf memory allocator class.
185 struct _GstMsdkDmaBufAllocatorClass
187 GstDmaBufAllocatorClass parent_class;
190 GType gst_msdk_dmabuf_allocator_get_type (void);
192 GstAllocator * gst_msdk_dmabuf_allocator_new (GstMsdkContext * context,
193 GstVideoInfo *image_info, mfxFrameAllocResponse * alloc_resp);
197 #endif /* GST_MSDK_VIDEO_MEMORY_H */