22 # include <va/va_x11.h> 25 # include <va/va_drm.h> 29 # include <va/va_drmcommon.h> 30 # include <drm_fourcc.h> 31 # ifndef DRM_FORMAT_MOD_INVALID 32 # define DRM_FORMAT_MOD_INVALID ((1ULL << 56) - 1) 90 #define MAP(va, rt, av) { \ 92 VA_RT_FORMAT_ ## rt, \ 102 MAP(NV12, YUV420, NV12),
103 MAP(YV12, YUV420, YUV420P),
104 MAP(IYUV, YUV420, YUV420P),
105 #ifdef VA_FOURCC_I420 106 MAP(I420, YUV420, YUV420P),
108 #ifdef VA_FOURCC_YV16 109 MAP(YV16, YUV422, YUV422P),
111 MAP(422
H, YUV422, YUV422P),
112 MAP(UYVY, YUV422, UYVY422),
113 MAP(YUY2, YUV422, YUYV422),
114 MAP(411
P, YUV411, YUV411P),
115 MAP(422
V, YUV422, YUV440P),
116 MAP(444
P, YUV444, YUV444P),
117 MAP(Y800, YUV400, GRAY8),
118 #ifdef VA_FOURCC_P010 119 MAP(P010, YUV420_10BPP, P010),
121 MAP(BGRA, RGB32, BGRA),
122 MAP(BGRX, RGB32, BGR0),
124 MAP(RGBX, RGB32, RGB0),
125 #ifdef VA_FOURCC_ABGR 126 MAP(ABGR, RGB32, ABGR),
127 MAP(XBGR, RGB32, 0BGR),
129 MAP(ARGB, RGB32, ARGB),
130 MAP(XRGB, RGB32, 0RGB),
145 VAImageFormat **image_format)
161 const void *hwconfig,
167 VASurfaceAttrib *attr_list =
NULL;
171 int err, i, j, attr_count, pix_fmt_count;
178 if (vas != VA_STATUS_SUCCESS) {
180 "%d (%s).\n", vas, vaErrorStr(vas));
185 attr_list =
av_malloc(attr_count *
sizeof(*attr_list));
192 attr_list, &attr_count);
193 if (vas != VA_STATUS_SUCCESS) {
195 "%d (%s).\n", vas, vaErrorStr(vas));
201 for (i = 0; i < attr_count; i++) {
202 switch (attr_list[i].
type) {
203 case VASurfaceAttribPixelFormat:
204 fourcc = attr_list[i].value.value.i;
212 case VASurfaceAttribMinWidth:
213 constraints->
min_width = attr_list[i].value.value.i;
215 case VASurfaceAttribMinHeight:
216 constraints->
min_height = attr_list[i].value.value.i;
218 case VASurfaceAttribMaxWidth:
219 constraints->
max_width = attr_list[i].value.value.i;
221 case VASurfaceAttribMaxHeight:
222 constraints->
max_height = attr_list[i].value.value.i;
226 if (pix_fmt_count == 0) {
238 for (i = j = 0; i < attr_count; i++) {
239 if (attr_list[i].
type != VASurfaceAttribPixelFormat)
241 fourcc = attr_list[i].value.value.i;
277 static const struct {
283 "Intel i965 (Quick Sync)",
294 "Splitted-Desktop Systems VDPAU backend for VA-API",
303 VAImageFormat *image_list =
NULL;
305 const char *vendor_string;
306 int err, i, image_count;
310 image_count = vaMaxNumImageFormats(hwctx->
display);
311 if (image_count <= 0) {
315 image_list =
av_malloc(image_count *
sizeof(*image_list));
320 vas = vaQueryImageFormats(hwctx->
display, image_list, &image_count);
321 if (vas != VA_STATUS_SUCCESS) {
332 for (i = 0; i < image_count; i++) {
333 fourcc = image_list[i].fourcc;
349 "quirks set by user.\n");
352 vendor_string = vaQueryVendorString(hwctx->
display);
356 if (strstr(vendor_string,
359 "driver \"%s\".\n", vendor_string,
368 "assuming standard behaviour.\n", vendor_string);
392 VASurfaceID surface_id;
395 surface_id = (VASurfaceID)(uintptr_t)
data;
397 vas = vaDestroySurfaces(hwctx->
display, &surface_id, 1);
398 if (vas != VA_STATUS_SUCCESS) {
400 "%d (%s).\n", surface_id, vas, vaErrorStr(vas));
410 VASurfaceID surface_id;
422 if (vas != VA_STATUS_SUCCESS) {
424 "%d (%s).\n", vas, vaErrorStr(vas));
433 vaDestroySurfaces(hwctx->
display, &surface_id, 1);
453 VAImageFormat *expected_format;
455 VASurfaceID test_surface_id;
477 int need_pixel_format = 1;
479 if (avfc->
attributes[i].type == VASurfaceAttribMemoryType)
480 need_memory_type = 0;
481 if (avfc->
attributes[i].type == VASurfaceAttribPixelFormat)
482 need_pixel_format = 0;
496 if (need_memory_type) {
498 .type = VASurfaceAttribMemoryType,
499 .flags = VA_SURFACE_ATTRIB_SETTABLE,
500 .value.type = VAGenericValueTypeInteger,
501 .value.value.i = VA_SURFACE_ATTRIB_MEM_TYPE_VA,
504 if (need_pixel_format) {
506 .type = VASurfaceAttribPixelFormat,
507 .flags = VA_SURFACE_ATTRIB_SETTABLE,
508 .value.type = VAGenericValueTypeInteger,
554 "user-configured buffer pool.\n");
562 "internal buffer pool.\n");
567 test_surface_id = (VASurfaceID)(uintptr_t)test_surface->
data;
574 vas = vaDeriveImage(hwctx->
display, test_surface_id, &test_image);
575 if (vas == VA_STATUS_SUCCESS) {
576 if (expected_format->fourcc == test_image.format.fourcc) {
581 "derived image format %08x does not match " 582 "expected format %08x.\n",
583 expected_format->fourcc, test_image.format.fourcc);
585 vaDestroyImage(hwctx->
display, test_image.image_id);
588 "deriving image does not work: " 589 "%d (%s).\n", vas, vaErrorStr(vas));
593 "image format is not supported.\n");
635 int i, k, sw_format_available;
637 sw_format_available = 0;
640 sw_format_available = 1;
647 if (sw_format_available) {
670 VASurfaceID surface_id;
673 surface_id = (VASurfaceID)(uintptr_t)hwmap->
source->
data[3];
677 if (vas != VA_STATUS_SUCCESS) {
679 "%#x: %d (%s).\n", surface_id, vas, vaErrorStr(vas));
684 vas = vaPutImage(hwctx->
display, surface_id, map->
image.image_id,
687 if (vas != VA_STATUS_SUCCESS) {
689 "%#x: %d (%s).\n", surface_id, vas, vaErrorStr(vas));
693 vas = vaDestroyImage(hwctx->
display, map->
image.image_id);
694 if (vas != VA_STATUS_SUCCESS) {
696 "%#x: %d (%s).\n", surface_id, vas, vaErrorStr(vas));
707 VASurfaceID surface_id;
708 VAImageFormat *image_format;
711 void *address =
NULL;
714 surface_id = (VASurfaceID)(uintptr_t)src->
data[3];
723 if (dst->
format != hwfc->
sw_format && (flags & AV_HWFRAME_MAP_DIRECT)) {
738 map->
image.image_id = VA_INVALID_ID;
740 vas = vaSyncSurface(hwctx->
display, surface_id);
741 if (vas != VA_STATUS_SUCCESS) {
743 "%#x: %d (%s).\n", surface_id, vas, vaErrorStr(vas));
757 vas = vaDeriveImage(hwctx->
display, surface_id, &map->
image);
758 if (vas != VA_STATUS_SUCCESS) {
760 "surface %#x: %d (%s).\n",
761 surface_id, vas, vaErrorStr(vas));
765 if (map->
image.format.fourcc != image_format->fourcc) {
767 "is in wrong format: expected %#08x, got %#08x.\n",
768 surface_id, image_format->fourcc, map->
image.format.fourcc);
774 vas = vaCreateImage(hwctx->
display, image_format,
776 if (vas != VA_STATUS_SUCCESS) {
778 "surface %#x: %d (%s).\n",
779 surface_id, vas, vaErrorStr(vas));
784 vas = vaGetImage(hwctx->
display, surface_id, 0, 0,
786 if (vas != VA_STATUS_SUCCESS) {
788 "surface %#x: %d (%s).\n",
789 surface_id, vas, vaErrorStr(vas));
796 vas = vaMapBuffer(hwctx->
display, map->
image.buf, &address);
797 if (vas != VA_STATUS_SUCCESS) {
799 "%#x: %d (%s).\n", surface_id, vas, vaErrorStr(vas));
812 for (i = 0; i < map->
image.num_planes; i++) {
817 #ifdef VA_FOURCC_YV16
818 map->
image.format.fourcc == VA_FOURCC_YV16 ||
820 map->
image.format.fourcc == VA_FOURCC_YV12) {
831 if (map->
image.image_id != VA_INVALID_ID)
924 #define DRM_MAP(va, layers, ...) { \ 929 static const struct {
931 int nb_layer_formats;
933 } vaapi_drm_format_map[] = {
935 DRM_MAP(NV12, 2, DRM_FORMAT_R8, DRM_FORMAT_RG88),
937 DRM_MAP(NV12, 1, DRM_FORMAT_NV12),
938 #if defined(VA_FOURCC_P010) && defined(DRM_FORMAT_R16) 939 DRM_MAP(P010, 2, DRM_FORMAT_R16, DRM_FORMAT_RG1616),
941 DRM_MAP(BGRA, 1, DRM_FORMAT_ARGB8888),
942 DRM_MAP(BGRX, 1, DRM_FORMAT_XRGB8888),
943 DRM_MAP(
RGBA, 1, DRM_FORMAT_ABGR8888),
944 DRM_MAP(RGBX, 1, DRM_FORMAT_XBGR8888),
945 #ifdef VA_FOURCC_ABGR 946 DRM_MAP(ABGR, 1, DRM_FORMAT_RGBA8888),
947 DRM_MAP(XBGR, 1, DRM_FORMAT_RGBX8888),
949 DRM_MAP(ARGB, 1, DRM_FORMAT_BGRA8888),
950 DRM_MAP(XRGB, 1, DRM_FORMAT_BGRX8888),
959 VASurfaceID surface_id = (VASurfaceID)(uintptr_t)hwmap->
priv;
963 vaDestroySurfaces(dst_dev->
display, &surface_id, 1);
973 VASurfaceID surface_id;
975 uint32_t va_fourcc, va_rt_format;
978 unsigned long buffer_handle;
979 VASurfaceAttribExternalBuffers buffer_desc;
980 VASurfaceAttrib attrs[2] = {
982 .type = VASurfaceAttribMemoryType,
983 .flags = VA_SURFACE_ATTRIB_SETTABLE,
984 .value.type = VAGenericValueTypeInteger,
985 .value.value.i = VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME,
988 .type = VASurfaceAttribExternalBufferDescriptor,
989 .flags = VA_SURFACE_ATTRIB_SETTABLE,
990 .value.type = VAGenericValueTypePointer,
991 .value.value.p = &buffer_desc,
997 if (
desc->nb_objects != 1) {
999 "made from a single DRM object.\n");
1005 if (
desc->nb_layers != vaapi_drm_format_map[i].nb_layer_formats)
1007 for (j = 0; j <
desc->nb_layers; j++) {
1008 if (
desc->layers[j].format !=
1009 vaapi_drm_format_map[i].layer_formats[j])
1012 if (j !=
desc->nb_layers)
1014 va_fourcc = vaapi_drm_format_map[i].va_fourcc;
1024 "%08x.\n",
desc->objects[0].fd, va_fourcc);
1031 buffer_handle =
desc->objects[0].fd;
1032 buffer_desc.pixel_format = va_fourcc;
1033 buffer_desc.width = src_fc->
width;
1034 buffer_desc.height = src_fc->
height;
1035 buffer_desc.data_size =
desc->objects[0].size;
1036 buffer_desc.buffers = &buffer_handle;
1037 buffer_desc.num_buffers = 1;
1038 buffer_desc.flags = 0;
1041 for (i = 0; i <
desc->nb_layers; i++) {
1042 for (j = 0; j <
desc->layers[i].nb_planes; j++) {
1043 buffer_desc.pitches[k] =
desc->layers[i].planes[j].pitch;
1044 buffer_desc.offsets[k] =
desc->layers[i].planes[j].offset;
1048 buffer_desc.num_planes = k;
1050 vas = vaCreateSurfaces(dst_dev->display, va_rt_format,
1054 if (vas != VA_STATUS_SUCCESS) {
1056 "object: %d (%s).\n", vas, vaErrorStr(vas));
1062 &vaapi_unmap_from_drm,
1063 (
void*)(uintptr_t)surface_id);
1072 "surface %#x.\n",
desc->objects[0].fd, surface_id);
1077 #if VA_CHECK_VERSION(1, 1, 0) 1094 VASurfaceID surface_id;
1096 VADRMPRIMESurfaceDescriptor va_desc;
1098 uint32_t export_flags;
1101 surface_id = (VASurfaceID)(uintptr_t)src->
data[3];
1103 export_flags = VA_EXPORT_SURFACE_SEPARATE_LAYERS;
1105 export_flags |= VA_EXPORT_SURFACE_READ_ONLY;
1107 export_flags |= VA_EXPORT_SURFACE_WRITE_ONLY;
1109 vas = vaExportSurfaceHandle(hwctx->
display, surface_id,
1110 VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME_2,
1111 export_flags, &va_desc);
1112 if (vas != VA_STATUS_SUCCESS) {
1113 if (vas == VA_STATUS_ERROR_UNIMPLEMENTED)
1116 "%d (%s).\n", surface_id, vas, vaErrorStr(vas));
1128 for (i = 0; i < va_desc.num_objects; i++) {
1129 drm_desc->
objects[i].
fd = va_desc.objects[i].fd;
1130 drm_desc->
objects[i].
size = va_desc.objects[i].size;
1132 va_desc.objects[i].drm_format_modifier;
1134 drm_desc->
nb_layers = va_desc.num_layers;
1135 for (i = 0; i < va_desc.num_layers; i++) {
1136 drm_desc->
layers[i].
format = va_desc.layers[i].drm_format;
1138 for (j = 0; j < va_desc.layers[i].num_planes; j++) {
1140 va_desc.layers[i].object_index[j];
1142 va_desc.layers[i].offset[j];
1144 va_desc.layers[i].pitch[j];
1149 &vaapi_unmap_to_drm_esh, drm_desc);
1160 for (i = 0; i < va_desc.num_objects; i++)
1161 close(va_desc.objects[i].fd);
1167 typedef struct VAAPIDRMImageBufferMapping {
1169 VABufferInfo buffer_info;
1172 } VAAPIDRMImageBufferMapping;
1178 VAAPIDRMImageBufferMapping *mapping = hwmap->
priv;
1179 VASurfaceID surface_id;
1182 surface_id = (VASurfaceID)(uintptr_t)hwmap->
source->
data[3];
1189 vas = vaReleaseBufferHandle(hwctx->
display, mapping->image.buf);
1190 if (vas != VA_STATUS_SUCCESS) {
1192 "handle of image %#x (derived from surface %#x): " 1193 "%d (%s).\n", mapping->image.buf, surface_id,
1194 vas, vaErrorStr(vas));
1197 vas = vaDestroyImage(hwctx->
display, mapping->image.image_id);
1198 if (vas != VA_STATUS_SUCCESS) {
1200 "derived from surface %#x: %d (%s).\n",
1201 surface_id, vas, vaErrorStr(vas));
1211 VAAPIDRMImageBufferMapping *mapping =
NULL;
1212 VASurfaceID surface_id;
1216 surface_id = (VASurfaceID)(uintptr_t)src->
data[3];
1224 vas = vaDeriveImage(hwctx->
display, surface_id,
1226 if (vas != VA_STATUS_SUCCESS) {
1228 "surface %#x: %d (%s).\n",
1229 surface_id, vas, vaErrorStr(vas));
1235 if (vaapi_drm_format_map[i].va_fourcc ==
1236 mapping->image.format.fourcc)
1241 "VAAPI format %#x.\n", mapping->image.format.fourcc);
1246 mapping->buffer_info.mem_type =
1247 VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME;
1249 mapping->drm_desc.nb_layers =
1250 vaapi_drm_format_map[i].nb_layer_formats;
1251 if (mapping->drm_desc.nb_layers > 1) {
1252 if (mapping->drm_desc.nb_layers != mapping->image.num_planes) {
1254 "expected format: got %d planes, but expected %d.\n",
1255 mapping->image.num_planes, mapping->drm_desc.nb_layers);
1260 for(p = 0; p < mapping->drm_desc.nb_layers; p++) {
1262 .format = vaapi_drm_format_map[i].layer_formats[p],
1266 .offset = mapping->image.offsets[p],
1267 .pitch = mapping->image.pitches[p],
1272 mapping->drm_desc.layers[0].format =
1273 vaapi_drm_format_map[i].layer_formats[0];
1274 mapping->drm_desc.layers[0].nb_planes = mapping->image.num_planes;
1275 for (p = 0; p < mapping->image.num_planes; p++) {
1278 .offset = mapping->image.offsets[p],
1279 .pitch = mapping->image.pitches[p],
1284 vas = vaAcquireBufferHandle(hwctx->
display, mapping->image.buf,
1285 &mapping->buffer_info);
1286 if (vas != VA_STATUS_SUCCESS) {
1288 "handle from image %#x (derived from surface %#x): " 1289 "%d (%s).\n", mapping->image.buf, surface_id,
1290 vas, vaErrorStr(vas));
1296 mapping->buffer_info.handle);
1298 mapping->drm_desc.nb_objects = 1;
1300 .fd = mapping->buffer_info.handle,
1301 .size = mapping->image.data_size,
1303 .format_modifier = DRM_FORMAT_MOD_INVALID,
1307 dst, src, &vaapi_unmap_to_drm_abh,
1319 vaReleaseBufferHandle(hwctx->
display, mapping->image.buf);
1321 vaDestroyImage(hwctx->
display, mapping->image.image_id);
1330 #if VA_CHECK_VERSION(1, 1, 0) 1332 err = vaapi_map_to_drm_esh(hwfc, dst, src, flags);
1336 return vaapi_map_to_drm_abh(hwfc, dst, src, flags);
1347 return vaapi_map_from_drm(hwfc, dst, src, flags);
1360 return vaapi_map_to_drm(hwfc, dst, src, flags);
1376 if (priv->x11_display)
1377 XCloseDisplay(priv->x11_display);
1387 static void vaapi_device_log_error(
void *context,
const char *
message)
1394 static void vaapi_device_log_info(
void *context,
const char *
message)
1410 vaSetErrorCallback(display, &vaapi_device_log_error, ctx);
1411 vaSetInfoCallback (display, &vaapi_device_log_info, ctx);
1416 vas = vaInitialize(display, &major, &minor);
1417 if (vas != VA_STATUS_SUCCESS) {
1419 "connection: %d (%s).\n", vas, vaErrorStr(vas));
1423 "version %d.%d\n", major, minor);
1432 VADisplay display =
NULL;
1444 if (!display && !(device && device[0] ==
'/')) {
1446 priv->x11_display = XOpenDisplay(device);
1447 if (!priv->x11_display) {
1449 "%s.\n", XDisplayName(device));
1451 display = vaGetDisplay(priv->x11_display);
1454 "from X11 display %s.\n", XDisplayName(device));
1459 "X11 display %s.\n", XDisplayName(device));
1469 const char *path = device ? device :
"/dev/dri/renderD128";
1470 priv->
drm_fd = open(path, O_RDWR);
1475 display = vaGetDisplayDRM(priv->
drm_fd);
1478 "from DRM device %s.\n", path);
1483 "DRM device %s.\n", path);
1490 "device: %s.\n", device ? device :
"");
1506 if (src_hwctx->
fd < 0) {
1508 "device to derive a VA display from.\n");
1522 display = vaGetDisplayDRM(src_hwctx->
fd);
This struct aggregates all the (hardware/vendor-specific) "high-level" state, i.e.
The maximum number of layers/planes in a DRM frame.
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it...
VAAPI-specific data associated with a frame pool.
static enum AVPixelFormat vaapi_pix_fmt_from_fourcc(unsigned int fourcc)
This structure describes decoded (raw) audio or video data.
static void vaapi_device_free(AVHWDeviceContext *ctx)
static int device_init(AVFormatContext *ctx, int *width, int *height, uint32_t pixelformat)
Memory handling functions.
VASurfaceAttrib * attributes
Set by the user to apply surface attributes to all surfaces in the frame pool.
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.
static int vaapi_get_buffer(AVHWFramesContext *hwfc, AVFrame *frame)
The driver does not support the VASurfaceAttribMemoryType attribute, so the surface allocation code w...
int max_width
The maximum size of frames in this hw_frames_ctx.
int nb_objects
Number of DRM objects making up this frame.
The quirks field has been set by the user and should not be detected automatically by av_hwdevice_ctx...
API-specific header for AV_HWDEVICE_TYPE_VAAPI.
AVBufferRef * hw_frames_ctx
For hwaccel-format frames, this should be a reference to the AVHWFramesContext describing the frame...
static int vaapi_transfer_data_from(AVHWFramesContext *hwfc, AVFrame *dst, const AVFrame *src)
static int vaapi_device_init(AVHWDeviceContext *hwdev)
#define av_assert0(cond)
assert() equivalent, that is always enabled.
AVBufferPool * pool_internal
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
static void vaapi_buffer_free(void *opaque, uint8_t *data)
static int vaapi_device_connect(AVHWDeviceContext *ctx, VADisplay display)
size_t size
Total size of the object.
static void vaapi_frames_uninit(AVHWFramesContext *hwfc)
static const struct @258 vaapi_format_map[]
void * hwctx
The format-specific data, allocated and freed by libavutil along with this context.
static const struct @259 vaapi_driver_quirks_table[]
AVDRMLayerDescriptor layers[AV_DRM_MAX_PLANES]
Array of layers in the frame.
#define AV_LOG_VERBOSE
Detailed information.
#define AV_BUFFER_FLAG_READONLY
Always treat the buffer as read-only, even when it has only one reference.
static int vaapi_device_derive(AVHWDeviceContext *ctx, AVHWDeviceContext *src_ctx, int flags)
The mapped frame will be overwritten completely in subsequent operations, so the current frame data n...
static int vaapi_map_frame(AVHWFramesContext *hwfc, AVFrame *dst, const AVFrame *src, int flags)
int fd
DRM PRIME fd for the object.
int nb_layers
Number of layers in the frame.
The driver does not destroy parameter buffers when they are used by vaRenderPicture().
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.
VAAPI hardware pipeline configuration details.
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.
The mapping must be direct.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
simple assert() macros that are a bit more flexible than ISO C assert().
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
int nb_planes
Number of planes in the layer.
AVBufferRef * av_buffer_create(uint8_t *data, int size, void(*free)(void *opaque, uint8_t *data), void *opaque, int flags)
Create an AVBuffer from an existing array.
enum AVHWDeviceType type
This field identifies the underlying API used for hardware access.
VASurfaceAttrib * attributes
int av_frame_copy(AVFrame *dst, const AVFrame *src)
Copy the frame data from src to dst.
const char * match_string
int initial_pool_size
Initial size of the frame pool.
static int vaapi_map_to_memory(AVHWFramesContext *hwfc, AVFrame *dst, const AVFrame *src, int flags)
AVFrame * source
A reference to the original source of the mapping.
AVDRMPlaneDescriptor planes[AV_DRM_MAX_PLANES]
Array of planes in this layer.
AVHWDeviceContext * device_ctx
The parent AVHWDeviceContext.
The mapping must be readable.
enum AVPixelFormat pix_fmt
The mapping must be writeable.
static int vaapi_transfer_get_formats(AVHWFramesContext *hwfc, enum AVHWFrameTransferDirection dir, enum AVPixelFormat **formats)
AVDRMObjectDescriptor objects[AV_DRM_MAX_PLANES]
Array of objects making up the frame.
static int vaapi_map_to(AVHWFramesContext *hwfc, AVFrame *dst, const AVFrame *src, int flags)
uint64_t format_modifier
Format modifier applied to the object (DRM_FORMAT_MOD_*).
AVBufferPool * av_buffer_pool_init2(int size, void *opaque, AVBufferRef *(*alloc)(void *opaque, int size), void(*pool_free)(void *opaque))
Allocate and initialize a buffer pool with a more complex allocator.
static int vaapi_transfer_data_to(AVHWFramesContext *hwfc, AVFrame *dst, const AVFrame *src)
static void vaapi_unmap_frame(AVHWFramesContext *hwfc, HWMapDescriptor *hwmap)
#define FF_ARRAY_ELEMS(a)
VADisplay display
The VADisplay handle, to be filled by the user.
VAAPISurfaceFormat * formats
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames...
int min_width
The minimum size of frames in this hw_frames_ctx.
void * priv
Hardware-specific private data associated with the mapping.
This struct describes the constraints on hardware frames attached to a given device with a hardware-s...
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
const char * friendly_name
uint8_t * data
The data buffer.
static int vaapi_map_from(AVHWFramesContext *hwfc, AVFrame *dst, const AVFrame *src, int flags)
static int vaapi_frames_init(AVHWFramesContext *hwfc)
void * hwctx
The format-specific data, allocated and freed automatically along with this context.
unsigned int driver_quirks
Driver quirks to apply - this is filled by av_hwdevice_ctx_init(), with reference to a table of known...
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.
refcounted data buffer API
enum AVPixelFormat * valid_hw_formats
A list of possible values for format in the hw_frames_ctx, terminated by AV_PIX_FMT_NONE.
const VDPAUPixFmtMap * map
static int vaapi_get_image_format(AVHWDeviceContext *hwdev, enum AVPixelFormat pix_fmt, VAImageFormat **image_format)
API-specific header for AV_HWDEVICE_TYPE_DRM.
AVHWFramesInternal * internal
Private data used internally by libavutil.
static enum AVPixelFormat pix_fmts[]
static void vaapi_device_uninit(AVHWDeviceContext *hwdev)
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
void * user_opaque
Arbitrary user data, to be used e.g.
static int vaapi_device_create(AVHWDeviceContext *ctx, const char *device, AVDictionary *opts, int flags)
A reference to a data buffer.
common internal and external API header
static int ref[MAX_W *MAX_W]
int fd
File descriptor of DRM device.
static int vaapi_frames_get_constraints(AVHWDeviceContext *hwdev, const void *hwconfig, AVHWFramesConstraints *constraints)
uint32_t format
Format of the layer (DRM_FORMAT_*).
#define AVERROR_UNKNOWN
Unknown error, typically from an external library.
AVHWFrameTransferDirection
static AVBufferRef * vaapi_pool_alloc(void *opaque, int size)
AVBufferPool * pool
A pool from which the frames are allocated by av_hwframe_get_buffer().
enum AVPixelFormat * valid_sw_formats
A list of possible values for sw_format in the hw_frames_ctx, terminated by AV_PIX_FMT_NONE.
ptrdiff_t offset
Offset within that object of this plane.
VAAPI connection details.
VAConfigID config_id
ID of a VAAPI pipeline configuration.
void(* free)(struct AVHWDeviceContext *ctx)
This field may be set by the caller before calling av_hwdevice_ctx_init().
const HWContextType ff_hwcontext_type_vaapi
VASurfaceID * surface_ids
The surfaces IDs of all surfaces in the pool after creation.
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)
#define FFSWAP(type, a, b)
AVHWDeviceInternal * internal
Private data used internally by libavutil.
const char * av_get_pix_fmt_name(enum AVPixelFormat pix_fmt)
Return the short name for a pixel format, NULL in case pix_fmt is unknown.
The driver does not support surface attributes at all.
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.