46 hwctx->
fd = open(device, O_RDWR);
50 version = drmGetVersion(hwctx->
fd);
53 "from %s: probably not a DRM device?\n", device);
59 "version %d.%d.%d.\n", device, version->name,
60 version->version_major, version->version_minor,
61 version->version_patchlevel);
63 drmFreeVersion(version);
109 int err, i, p,
plane;
119 mmap_prot |= PROT_READ;
121 mmap_prot |= PROT_WRITE;
127 if (addr == MAP_FAILED) {
130 "memory: %d.\n", desc->
objects[i].
fd, errno);
134 map->address[i] = addr;
165 munmap(
map->address[i],
map->length[i]);
This struct aggregates all the (hardware/vendor-specific) "high-level" state, i.e.
The maximum number of layers/planes in a DRM frame.
This structure describes decoded (raw) audio or video data.
static int drm_map_from(AVHWFramesContext *hwfc, AVFrame *dst, const AVFrame *src, int flags)
AVBufferRef * buf[AV_NUM_DATA_POINTERS]
AVBuffer references backing the data for this frame.
int width
The allocated dimensions of the frames in this pool.
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
int nb_objects
Number of DRM objects making up this frame.
AVBufferRef * hw_frames_ctx
For hwaccel-format frames, this should be a reference to the AVHWFramesContext describing the frame...
#define av_assert0(cond)
assert() equivalent, that is always enabled.
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
size_t size
Total size of the object.
void * hwctx
The format-specific data, allocated and freed by libavutil along with this context.
static int drm_device_create(AVHWDeviceContext *hwdev, const char *device, AVDictionary *opts, int flags)
AVDRMLayerDescriptor layers[AV_DRM_MAX_PLANES]
Array of layers in the frame.
#define AV_LOG_VERBOSE
Detailed information.
static void drm_unmap_frame(AVHWFramesContext *hwfc, HWMapDescriptor *hwmap)
The mapped frame will be overwritten completely in subsequent operations, so the current frame data n...
int fd
DRM PRIME fd for the object.
int nb_layers
Number of layers in the frame.
int object_index
Index of the object containing this plane in the objects array of the enclosing frame descriptor...
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void(* free)(struct AVHWDeviceContext *ctx)
This field may be set by the caller before calling av_hwdevice_ctx_init().
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
ptrdiff_t pitch
Pitch (linesize) of this plane.
static int drm_transfer_get_formats(AVHWFramesContext *ctx, enum AVHWFrameTransferDirection dir, enum AVPixelFormat **formats)
simple assert() macros that are a bit more flexible than ISO C assert().
int nb_planes
Number of planes in the layer.
int av_frame_copy(AVFrame *dst, const AVFrame *src)
Copy the frame data from src to dst.
AVDRMPlaneDescriptor planes[AV_DRM_MAX_PLANES]
Array of planes in this layer.
The mapping must be readable.
The mapping must be writeable.
AVDRMObjectDescriptor objects[AV_DRM_MAX_PLANES]
Array of objects making up the frame.
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames...
const HWContextType ff_hwcontext_type_drm
void * priv
Hardware-specific private data associated with the mapping.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
uint8_t * data
The data buffer.
static int drm_transfer_data_from(AVHWFramesContext *hwfc, AVFrame *dst, const AVFrame *src)
int ff_hwframe_map_create(AVBufferRef *hwframe_ref, AVFrame *dst, const AVFrame *src, void(*unmap)(AVHWFramesContext *ctx, HWMapDescriptor *hwmap), void *priv)
DRM-managed buffers exposed through PRIME buffer sharing.
This struct describes a set or pool of "hardware" frames (i.e.
static int drm_transfer_data_to(AVHWFramesContext *hwfc, AVFrame *dst, const AVFrame *src)
const VDPAUPixFmtMap * map
API-specific header for AV_HWDEVICE_TYPE_DRM.
static enum AVPixelFormat pix_fmts[]
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int fd
File descriptor of DRM device.
void * address[AV_DRM_MAX_PLANES]
static void drm_device_free(AVHWDeviceContext *hwdev)
AVHWFrameTransferDirection
AVBufferPool * pool
A pool from which the frames are allocated by av_hwframe_get_buffer().
size_t length[AV_DRM_MAX_PLANES]
ptrdiff_t offset
Offset within that object of this plane.
static int drm_get_buffer(AVHWFramesContext *hwfc, AVFrame *frame)
AVBufferRef * av_buffer_pool_get(AVBufferPool *pool)
Allocate a new AVBuffer, reusing an old buffer from the pool when available.
#define av_malloc_array(a, b)
enum AVPixelFormat sw_format
The pixel format identifying the actual data layout of the hardware frames.
AVPixelFormat
Pixel format.
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
static int drm_map_frame(AVHWFramesContext *hwfc, AVFrame *dst, const AVFrame *src, int flags)