1 /* 2 * This file is part of FFmpeg. 3 * 4 * FFmpeg is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU Lesser General Public 6 * License as published by the Free Software Foundation; either 7 * version 2.1 of the License, or (at your option) any later version. 8 * 9 * FFmpeg is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * Lesser General Public License for more details. 13 * 14 * You should have received a copy of the GNU Lesser General Public 15 * License along with FFmpeg; if not, write to the Free Software 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 */ 18 module ffmpeg.libavutil.hwcontext_drm; 19 extern (C) @nogc nothrow: 20 21 /** 22 * @file 23 * API-specific header for AV_HWDEVICE_TYPE_DRM. 24 * 25 * Internal frame allocation is not currently supported - all frames 26 * must be allocated by the user. Thus AVHWFramesContext is always 27 * NULL, though this may change if support for frame allocation is 28 * added in future. 29 */ 30 31 enum 32 { 33 /** 34 * The maximum number of layers/planes in a DRM frame. 35 */ 36 AV_DRM_MAX_PLANES = 4 37 } 38 39 /** 40 * DRM object descriptor. 41 * 42 * Describes a single DRM object, addressing it as a PRIME file 43 * descriptor. 44 */ 45 struct AVDRMObjectDescriptor 46 { 47 /** 48 * DRM PRIME fd for the object. 49 */ 50 int fd; 51 /** 52 * Total size of the object. 53 * 54 * (This includes any parts not which do not contain image data.) 55 */ 56 size_t size; 57 /** 58 * Format modifier applied to the object (DRM_FORMAT_MOD_*). 59 * 60 * If the format modifier is unknown then this should be set to 61 * DRM_FORMAT_MOD_INVALID. 62 */ 63 ulong format_modifier; 64 } 65 66 /** 67 * DRM plane descriptor. 68 * 69 * Describes a single plane of a layer, which is contained within 70 * a single object. 71 */ 72 struct AVDRMPlaneDescriptor 73 { 74 /** 75 * Index of the object containing this plane in the objects 76 * array of the enclosing frame descriptor. 77 */ 78 int object_index; 79 /** 80 * Offset within that object of this plane. 81 */ 82 ptrdiff_t offset; 83 /** 84 * Pitch (linesize) of this plane. 85 */ 86 ptrdiff_t pitch; 87 } 88 89 /** 90 * DRM layer descriptor. 91 * 92 * Describes a single layer within a frame. This has the structure 93 * defined by its format, and will contain one or more planes. 94 */ 95 struct AVDRMLayerDescriptor 96 { 97 /** 98 * Format of the layer (DRM_FORMAT_*). 99 */ 100 uint format; 101 /** 102 * Number of planes in the layer. 103 * 104 * This must match the number of planes required by format. 105 */ 106 int nb_planes; 107 /** 108 * Array of planes in this layer. 109 */ 110 AVDRMPlaneDescriptor[AV_DRM_MAX_PLANES] planes; 111 } 112 113 /** 114 * DRM frame descriptor. 115 * 116 * This is used as the data pointer for AV_PIX_FMT_DRM_PRIME frames. 117 * It is also used by user-allocated frame pools - allocating in 118 * AVHWFramesContext.pool must return AVBufferRefs which contain 119 * an object of this type. 120 * 121 * The fields of this structure should be set such it can be 122 * imported directly by EGL using the EGL_EXT_image_dma_buf_import 123 * and EGL_EXT_image_dma_buf_import_modifiers extensions. 124 * (Note that the exact layout of a particular format may vary between 125 * platforms - we only specify that the same platform should be able 126 * to import it.) 127 * 128 * The total number of planes must not exceed AV_DRM_MAX_PLANES, and 129 * the order of the planes by increasing layer index followed by 130 * increasing plane index must be the same as the order which would 131 * be used for the data pointers in the equivalent software format. 132 */ 133 struct AVDRMFrameDescriptor 134 { 135 /** 136 * Number of DRM objects making up this frame. 137 */ 138 int nb_objects; 139 /** 140 * Array of objects making up the frame. 141 */ 142 AVDRMObjectDescriptor[AV_DRM_MAX_PLANES] objects; 143 /** 144 * Number of layers in the frame. 145 */ 146 int nb_layers; 147 /** 148 * Array of layers in the frame. 149 */ 150 AVDRMLayerDescriptor[AV_DRM_MAX_PLANES] layers; 151 } 152 153 /** 154 * DRM device. 155 * 156 * Allocated as AVHWDeviceContext.hwctx. 157 */ 158 struct AVDRMDeviceContext 159 { 160 /** 161 * File descriptor of DRM device. 162 * 163 * This is used as the device to create frames on, and may also be 164 * used in some derivation and mapping operations. 165 * 166 * If no device is required, set to -1. 167 */ 168 int fd; 169 } 170 171 /* AVUTIL_HWCONTEXT_DRM_H */