1 /* GStreamer 2 * Copyright (C) 2020 Igalia, S.L. 3 * Author: Víctor Jáquez <vjaquez@igalia.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., 51 Franklin St, Fifth Floor, 18 * Boston, MA 02110-1301, USA. 19 */ 20 21 #pragma once 22 23 #include <gst/allocators/allocators.h> 24 #include <gst/va/gstvadisplay.h> 25 #include <gst/video/video.h> 26 #include <stdint.h> 27 #include <va/va.h> 28 29 G_BEGIN_DECLS 30 31 #define GST_TYPE_VA_DMABUF_ALLOCATOR (gst_va_dmabuf_allocator_get_type()) 32 G_DECLARE_FINAL_TYPE (GstVaDmabufAllocator, gst_va_dmabuf_allocator, GST, 33 VA_DMABUF_ALLOCATOR, GstDmaBufAllocator); 34 35 GstAllocator * gst_va_dmabuf_allocator_new (GstVaDisplay * display); 36 gboolean gst_va_dmabuf_allocator_setup_buffer (GstAllocator * allocator, 37 GstBuffer * buffer); 38 gboolean gst_va_dmabuf_allocator_prepare_buffer (GstAllocator * allocator, 39 GstBuffer * buffer); 40 void gst_va_dmabuf_allocator_flush (GstAllocator * allocator); 41 gboolean gst_va_dmabuf_allocator_set_format (GstAllocator * allocator, 42 GstVideoInfo * info, 43 guint usage_hint); 44 gboolean gst_va_dmabuf_allocator_get_format (GstAllocator * allocator, 45 GstVideoInfo * info, 46 guint * usage_hint); 47 48 gboolean gst_va_dmabuf_memories_setup (GstVaDisplay * display, 49 GstVideoInfo * info, 50 guint n_planes, 51 GstMemory * mem[GST_VIDEO_MAX_PLANES], 52 uintptr_t * fds, 53 gsize offset[GST_VIDEO_MAX_PLANES], 54 guint usage_hint); 55 56 #define GST_TYPE_VA_ALLOCATOR (gst_va_allocator_get_type()) 57 G_DECLARE_FINAL_TYPE (GstVaAllocator, gst_va_allocator, GST, VA_ALLOCATOR, GstAllocator); 58 59 #define GST_ALLOCATOR_VASURFACE "VAMemory" 60 61 #define GST_MAP_VA (GST_MAP_FLAG_LAST << 1) 62 63 GstAllocator * gst_va_allocator_new (GstVaDisplay * display, 64 GArray * surface_formats); 65 GstMemory * gst_va_allocator_alloc (GstAllocator * allocator); 66 gboolean gst_va_allocator_setup_buffer (GstAllocator * allocator, 67 GstBuffer * buffer); 68 gboolean gst_va_allocator_prepare_buffer (GstAllocator * allocator, 69 GstBuffer * buffer); 70 void gst_va_allocator_flush (GstAllocator * allocator); 71 gboolean gst_va_allocator_set_format (GstAllocator * allocator, 72 GstVideoInfo * info, 73 guint usage_hint); 74 gboolean gst_va_allocator_get_format (GstAllocator * allocator, 75 GstVideoInfo * info, 76 guint * usage_hint); 77 78 VASurfaceID gst_va_memory_get_surface (GstMemory * mem); 79 VASurfaceID gst_va_buffer_get_surface (GstBuffer * buffer); 80 81 gboolean gst_va_buffer_create_aux_surface (GstBuffer * buffer); 82 VASurfaceID gst_va_buffer_get_aux_surface (GstBuffer * buffer); 83 84 G_END_DECLS 85