FFmpeg 7.1.5
Loading...
Searching...
No Matches
hwcontext_drm.h
Go to the documentation of this file.
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
19#ifndef AVUTIL_HWCONTEXT_DRM_H
20#define AVUTIL_HWCONTEXT_DRM_H
21
22#include <stddef.h>
23#include <stdint.h>
24
25#include "buffer.h"
26
27/**
28 * @file
29 * API-specific header for AV_HWDEVICE_TYPE_DRM.
30 *
31 * Internal frame allocation is not currently supported - all frames
32 * must be allocated by the user. Thus AVHWFramesContext is always
33 * NULL, though this may change if support for frame allocation is
34 * added in future.
35 */
36
37enum {
38 /**
39 * The maximum number of layers/planes in a DRM frame.
40 */
42};
43
44/**
45 * DRM object descriptor.
46 *
47 * Describes a single DRM object, addressing it as a PRIME file
48 * descriptor.
49 */
50typedef struct AVDRMObjectDescriptor {
51 /**
52 * DRM PRIME fd for the object.
53 */
54 int fd;
55 /**
56 * Total size of the object.
57 *
58 * (This includes any parts not which do not contain image data.)
59 */
60 size_t size;
61 /**
62 * Format modifier applied to the object (DRM_FORMAT_MOD_*).
63 *
64 * If the format modifier is unknown then this should be set to
65 * DRM_FORMAT_MOD_INVALID.
66 */
69
70/**
71 * DRM plane descriptor.
72 *
73 * Describes a single plane of a layer, which is contained within
74 * a single object.
75 */
76typedef struct AVDRMPlaneDescriptor {
77 /**
78 * Index of the object containing this plane in the objects
79 * array of the enclosing frame descriptor.
80 */
82 /**
83 * Offset within that object of this plane.
84 */
85 ptrdiff_t offset;
86 /**
87 * Pitch (linesize) of this plane.
88 */
89 ptrdiff_t pitch;
91
92/**
93 * DRM layer descriptor.
94 *
95 * Describes a single layer within a frame. This has the structure
96 * defined by its format, and will contain one or more planes.
97 */
98typedef struct AVDRMLayerDescriptor {
99 /**
100 * Format of the layer (DRM_FORMAT_*).
101 */
102 uint32_t format;
103 /**
104 * Number of planes in the layer.
105 *
106 * This must match the number of planes required by format.
107 */
109 /**
110 * Array of planes in this layer.
111 */
114
115/**
116 * DRM frame descriptor.
117 *
118 * This is used as the data pointer for AV_PIX_FMT_DRM_PRIME frames.
119 * It is also used by user-allocated frame pools - allocating in
120 * AVHWFramesContext.pool must return AVBufferRefs which contain
121 * an object of this type.
122 *
123 * The fields of this structure should be set such it can be
124 * imported directly by EGL using the EGL_EXT_image_dma_buf_import
125 * and EGL_EXT_image_dma_buf_import_modifiers extensions.
126 * (Note that the exact layout of a particular format may vary between
127 * platforms - we only specify that the same platform should be able
128 * to import it.)
129 *
130 * The total number of planes must not exceed AV_DRM_MAX_PLANES, and
131 * the order of the planes by increasing layer index followed by
132 * increasing plane index must be the same as the order which would
133 * be used for the data pointers in the equivalent software format.
134 */
135typedef struct AVDRMFrameDescriptor {
136 /**
137 * Number of DRM objects making up this frame.
138 */
140 /**
141 * Array of objects making up the frame.
142 */
144 /**
145 * Number of layers in the frame.
146 */
148 /**
149 * Array of layers in the frame.
150 */
153
154/**
155 * DRM device.
156 *
157 * Allocated as AVHWDeviceContext.hwctx.
158 */
159typedef struct AVDRMDeviceContext {
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;
170
171/**
172 * Test if a given V4L2 buffer fourcc is allowed in this DRM hardware device context.
173 *
174 * @param hw_device_ctx AVBufferRef to an AVHWDeviceContext of type AV_HWDEVICE_TYPE_DRM,
175 * or NULL (returns 0 if NULL)
176 * @param fcc V4L2 fourcc pixel format code to test
177 * @return 1 if the format is allowed, 0 otherwise
178 */
180
181#endif /* AVUTIL_HWCONTEXT_DRM_H */
refcounted data buffer API
static AVBufferRef * hw_device_ctx
Definition hw_decode.c:45
@ AV_DRM_MAX_PLANES
The maximum number of layers/planes in a DRM frame.
int av_hwcontext_drm_v4l2_4cc_test(AVBufferRef *hw_device_ctx, uint32_t fcc)
Test if a given V4L2 buffer fourcc is allowed in this DRM hardware device context.
A reference to a data buffer.
Definition buffer.h:82
int fd
File descriptor of DRM device.
DRM frame descriptor.
AVDRMObjectDescriptor objects[AV_DRM_MAX_PLANES]
Array of objects making up the frame.
int nb_layers
Number of layers in the frame.
int nb_objects
Number of DRM objects making up this frame.
AVDRMLayerDescriptor layers[AV_DRM_MAX_PLANES]
Array of layers in the frame.
DRM layer descriptor.
AVDRMPlaneDescriptor planes[AV_DRM_MAX_PLANES]
Array of planes in this layer.
int nb_planes
Number of planes in the layer.
uint32_t format
Format of the layer (DRM_FORMAT_*).
DRM object descriptor.
int fd
DRM PRIME fd for the object.
size_t size
Total size of the object.
uint64_t format_modifier
Format modifier applied to the object (DRM_FORMAT_MOD_*).
DRM plane descriptor.
ptrdiff_t pitch
Pitch (linesize) of this plane.
int object_index
Index of the object containing this plane in the objects array of the enclosing frame descriptor.
ptrdiff_t offset
Offset within that object of this plane.