1 /* 2 * GStreamer 3 * Copyright (C) 2012 Edward Hervey <edward@collabora.com> 4 * 5 * This library is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU Library General Public 7 * License as published by the Free Software Foundation; either 8 * version 2 of the License, or (at your option) any later version. 9 * 10 * This library is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * Library General Public License for more details. 14 * 15 * You should have received a copy of the GNU Library General Public 16 * License along with this library; if not, write to the 17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 * Boston, MA 02111-1307, USA. 19 */ 20 21 #ifndef _GST_VDP_VIDEO_MEMORY_H_ 22 #define _GST_VDP_VIDEO_MEMORY_H_ 23 24 #include <gst/gst.h> 25 #include <gst/gstmemory.h> 26 #include <gst/gstallocator.h> 27 #include <gst/video/video-info.h> 28 #include <gst/video/gstvideometa.h> 29 30 #include "gstvdpdevice.h" 31 32 G_BEGIN_DECLS 33 34 #define GST_TYPE_VDP_VIDEO_ALLOCATOR (gst_vdp_video_allocator_get_type()) 35 GType gst_vdp_video_allocator_get_type(void); 36 37 #define GST_IS_VDP_VIDEO_ALLOCATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_VDP_VIDEO_ALLOCATOR)) 38 #define GST_IS_VDP_VIDEO_ALLOCATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_VDP_VIDEO_ALLOCATOR)) 39 #define GST_VDP_VIDEO_ALLOCATOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_VDP_VIDEO_ALLOCATOR, GstVdpVideoAllocatorClass)) 40 #define GST_VDP_VIDEO_ALLOCATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_VDP_VIDEO_ALLOCATOR, GstVdpVideoAllocator)) 41 #define GST_VDP_VIDEO_ALLOCATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_VDP_VIDEO_ALLOCATOR, GstVdpVideoAllocatorClass)) 42 #define GST_VDP_VIDEO_ALLOCATOR_CAST(obj) ((GstVdpVideoAllocator *)(obj)) 43 44 typedef struct _GstVdpVideoMemory GstVdpVideoMemory; 45 typedef struct _GstVdpVideoAllocator GstVdpVideoAllocator; 46 typedef struct _GstVdpVideoAllocatorClass GstVdpVideoAllocatorClass; 47 48 /** 49 * GstVdpVideoMemory: 50 * @mem: the parent object 51 * @device: the #GstVdpDevice to use 52 * @surface: the #VdpVideoSurface 53 * 54 * Represents information about a #VdpVideoSurface 55 */ 56 struct _GstVdpVideoMemory 57 { 58 GstMemory mem; 59 60 GstVdpDevice *device; 61 VdpVideoSurface surface; 62 63 GstVideoInfo *info; 64 VdpChromaType chroma_type; 65 VdpYCbCrFormat ycbcr_format; 66 67 /* Cached data for mapping */ 68 volatile gint refcount; 69 GstMapFlags map_flags; 70 guint n_planes; 71 guint8 *cache; 72 void * cached_data[4]; 73 uint32_t destination_pitches[4]; 74 }; 75 76 #define GST_VDP_VIDEO_MEMORY_ALLOCATOR "VdpVideoMemory" 77 78 #define GST_CAPS_FEATURE_MEMORY_VDPAU "memory:VdpVideoSurface" 79 80 void gst_vdp_video_memory_init (void); 81 82 GstMemory * 83 gst_vdp_video_memory_alloc (GstVdpDevice * device, GstVideoInfo *info); 84 85 gboolean gst_vdp_video_memory_map(GstVideoMeta * meta, guint plane, 86 GstMapInfo * info, gpointer * data, 87 gint * stride, GstMapFlags flags); 88 gboolean gst_vdp_video_memory_unmap(GstVideoMeta * meta, guint plane, 89 GstMapInfo * info); 90 91 struct _GstVdpVideoAllocator 92 { 93 GstAllocator parent; 94 }; 95 96 struct _GstVdpVideoAllocatorClass 97 { 98 GstAllocatorClass parent_class; 99 }; 100 101 G_END_DECLS 102 103 #endif /* _GST_VDP_VIDEO_MEMORY_H_ */ 104