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 typedef struct VAAPIFormat {
97 #define MAP(va, rt, av, swap_uv) { \
99 VA_RT_FORMAT_ ## rt, \
106 MAP(NV12, YUV420, NV12, 0),
107 #ifdef VA_FOURCC_I420
108 MAP(I420, YUV420, YUV420P, 0),
110 MAP(YV12, YUV420, YUV420P, 1),
111 MAP(IYUV, YUV420, YUV420P, 0),
112 MAP(422
H, YUV422, YUV422P, 0),
113 #ifdef VA_FOURCC_YV16
114 MAP(YV16, YUV422, YUV422P, 1),
116 MAP(UYVY, YUV422, UYVY422, 0),
117 MAP(YUY2, YUV422, YUYV422, 0),
118 MAP(411
P, YUV411, YUV411P, 0),
119 MAP(422
V, YUV422, YUV440P, 0),
120 MAP(444
P, YUV444, YUV444P, 0),
121 MAP(Y800, YUV400, GRAY8, 0),
122 #ifdef VA_FOURCC_P010
123 MAP(P010, YUV420_10BPP, P010, 0),
125 MAP(BGRA, RGB32, BGRA, 0),
126 MAP(BGRX, RGB32, BGR0, 0),
128 MAP(RGBX, RGB32, RGB0, 0),
129 #ifdef VA_FOURCC_ABGR
130 MAP(ABGR, RGB32, ABGR, 0),
131 MAP(XBGR, RGB32, 0BGR, 0),
133 MAP(ARGB, RGB32, ARGB, 0),
134 MAP(XRGB, RGB32, 0RGB, 0),
143 if (vaapi_format_map[i].fourcc == fourcc)
144 return &vaapi_format_map[i];
153 if (vaapi_format_map[i].pix_fmt == pix_fmt)
154 return &vaapi_format_map[i];
170 VAImageFormat **image_format)
186 const void *hwconfig,
192 VASurfaceAttrib *attr_list =
NULL;
196 int err, i, j, attr_count, pix_fmt_count;
203 if (vas != VA_STATUS_SUCCESS) {
205 "%d (%s).\n", vas, vaErrorStr(vas));
210 attr_list =
av_malloc(attr_count *
sizeof(*attr_list));
217 attr_list, &attr_count);
218 if (vas != VA_STATUS_SUCCESS) {
220 "%d (%s).\n", vas, vaErrorStr(vas));
226 for (i = 0; i < attr_count; i++) {
227 switch (attr_list[i].
type) {
228 case VASurfaceAttribPixelFormat:
229 fourcc = attr_list[i].value.value.i;
237 case VASurfaceAttribMinWidth:
238 constraints->
min_width = attr_list[i].value.value.i;
240 case VASurfaceAttribMinHeight:
241 constraints->
min_height = attr_list[i].value.value.i;
243 case VASurfaceAttribMaxWidth:
244 constraints->
max_width = attr_list[i].value.value.i;
246 case VASurfaceAttribMaxHeight:
247 constraints->
max_height = attr_list[i].value.value.i;
251 if (pix_fmt_count == 0) {
263 for (i = j = 0; i < attr_count; i++) {
264 if (attr_list[i].
type != VASurfaceAttribPixelFormat)
266 fourcc = attr_list[i].value.value.i;
302 static const struct {
307 #if !VA_CHECK_VERSION(1, 0, 0)
310 "Intel i965 (Quick Sync)",
322 "Splitted-Desktop Systems VDPAU backend for VA-API",
331 VAImageFormat *image_list =
NULL;
333 const char *vendor_string;
334 int err, i, image_count;
338 image_count = vaMaxNumImageFormats(hwctx->
display);
339 if (image_count <= 0) {
343 image_list =
av_malloc(image_count *
sizeof(*image_list));
348 vas = vaQueryImageFormats(hwctx->
display, image_list, &image_count);
349 if (vas != VA_STATUS_SUCCESS) {
360 for (i = 0; i < image_count; i++) {
361 fourcc = image_list[i].fourcc;
375 vendor_string = vaQueryVendorString(hwctx->
display);
387 if (strstr(vendor_string,
390 "as known nonstandard driver \"%s\", setting "
401 "nonstandard list, using standard behaviour.\n");
405 "assuming standard behaviour.\n");
428 VASurfaceID surface_id;
431 surface_id = (VASurfaceID)(uintptr_t)
data;
433 vas = vaDestroySurfaces(hwctx->
display, &surface_id, 1);
434 if (vas != VA_STATUS_SUCCESS) {
436 "%d (%s).\n", surface_id, vas, vaErrorStr(vas));
446 VASurfaceID surface_id;
458 if (vas != VA_STATUS_SUCCESS) {
460 "%d (%s).\n", vas, vaErrorStr(vas));
469 vaDestroySurfaces(hwctx->
display, &surface_id, 1);
490 VAImageFormat *expected_format;
492 VASurfaceID test_surface_id;
507 int need_pixel_format = 1;
509 if (avfc->
attributes[i].type == VASurfaceAttribMemoryType)
510 need_memory_type = 0;
511 if (avfc->
attributes[i].type == VASurfaceAttribPixelFormat)
512 need_pixel_format = 0;
526 if (need_memory_type) {
528 .type = VASurfaceAttribMemoryType,
529 .flags = VA_SURFACE_ATTRIB_SETTABLE,
530 .value.type = VAGenericValueTypeInteger,
531 .value.value.i = VA_SURFACE_ATTRIB_MEM_TYPE_VA,
534 if (need_pixel_format) {
536 .type = VASurfaceAttribPixelFormat,
537 .flags = VA_SURFACE_ATTRIB_SETTABLE,
538 .value.type = VAGenericValueTypeInteger,
539 .value.value.i = desc->
fourcc,
584 "user-configured buffer pool.\n");
592 "internal buffer pool.\n");
597 test_surface_id = (VASurfaceID)(uintptr_t)test_surface->
data;
604 vas = vaDeriveImage(hwctx->
display, test_surface_id, &test_image);
605 if (vas == VA_STATUS_SUCCESS) {
606 if (expected_format->fourcc == test_image.format.fourcc) {
611 "derived image format %08x does not match "
612 "expected format %08x.\n",
613 expected_format->fourcc, test_image.format.fourcc);
615 vaDestroyImage(hwctx->
display, test_image.image_id);
618 "deriving image does not work: "
619 "%d (%s).\n", vas, vaErrorStr(vas));
623 "image format is not supported.\n");
665 int i, k, sw_format_available;
667 sw_format_available = 0;
670 sw_format_available = 1;
677 if (sw_format_available) {
700 VASurfaceID surface_id;
703 surface_id = (VASurfaceID)(uintptr_t)hwmap->
source->
data[3];
707 if (vas != VA_STATUS_SUCCESS) {
709 "%#x: %d (%s).\n", surface_id, vas, vaErrorStr(vas));
714 vas = vaPutImage(hwctx->
display, surface_id, map->
image.image_id,
717 if (vas != VA_STATUS_SUCCESS) {
719 "%#x: %d (%s).\n", surface_id, vas, vaErrorStr(vas));
723 vas = vaDestroyImage(hwctx->
display, map->
image.image_id);
724 if (vas != VA_STATUS_SUCCESS) {
726 "%#x: %d (%s).\n", surface_id, vas, vaErrorStr(vas));
737 VASurfaceID surface_id;
739 VAImageFormat *image_format;
742 void *address =
NULL;
745 surface_id = (VASurfaceID)(uintptr_t)src->
data[3];
754 if (dst->
format != hwfc->
sw_format && (flags & AV_HWFRAME_MAP_DIRECT)) {
769 map->
image.image_id = VA_INVALID_ID;
771 vas = vaSyncSurface(hwctx->
display, surface_id);
772 if (vas != VA_STATUS_SUCCESS) {
774 "%#x: %d (%s).\n", surface_id, vas, vaErrorStr(vas));
788 vas = vaDeriveImage(hwctx->
display, surface_id, &map->
image);
789 if (vas != VA_STATUS_SUCCESS) {
791 "surface %#x: %d (%s).\n",
792 surface_id, vas, vaErrorStr(vas));
796 if (map->
image.format.fourcc != image_format->fourcc) {
798 "is in wrong format: expected %#08x, got %#08x.\n",
799 surface_id, image_format->fourcc, map->
image.format.fourcc);
805 vas = vaCreateImage(hwctx->
display, image_format,
807 if (vas != VA_STATUS_SUCCESS) {
809 "surface %#x: %d (%s).\n",
810 surface_id, vas, vaErrorStr(vas));
815 vas = vaGetImage(hwctx->
display, surface_id, 0, 0,
817 if (vas != VA_STATUS_SUCCESS) {
819 "surface %#x: %d (%s).\n",
820 surface_id, vas, vaErrorStr(vas));
827 vas = vaMapBuffer(hwctx->
display, map->
image.buf, &address);
828 if (vas != VA_STATUS_SUCCESS) {
830 "%#x: %d (%s).\n", surface_id, vas, vaErrorStr(vas));
843 for (i = 0; i < map->
image.num_planes; i++) {
860 if (map->
image.image_id != VA_INVALID_ID)
953 #define DRM_MAP(va, layers, ...) { \
958 static const struct {
960 int nb_layer_formats;
962 } vaapi_drm_format_map[] = {
964 DRM_MAP(NV12, 2, DRM_FORMAT_R8, DRM_FORMAT_RG88),
966 DRM_MAP(NV12, 1, DRM_FORMAT_NV12),
967 #if defined(VA_FOURCC_P010) && defined(DRM_FORMAT_R16)
968 DRM_MAP(P010, 2, DRM_FORMAT_R16, DRM_FORMAT_RG1616),
970 DRM_MAP(BGRA, 1, DRM_FORMAT_ARGB8888),
971 DRM_MAP(BGRX, 1, DRM_FORMAT_XRGB8888),
972 DRM_MAP(
RGBA, 1, DRM_FORMAT_ABGR8888),
973 DRM_MAP(RGBX, 1, DRM_FORMAT_XBGR8888),
974 #ifdef VA_FOURCC_ABGR
975 DRM_MAP(ABGR, 1, DRM_FORMAT_RGBA8888),
976 DRM_MAP(XBGR, 1, DRM_FORMAT_RGBX8888),
978 DRM_MAP(ARGB, 1, DRM_FORMAT_BGRA8888),
979 DRM_MAP(XRGB, 1, DRM_FORMAT_BGRX8888),
988 VASurfaceID surface_id = (VASurfaceID)(uintptr_t)hwmap->
priv;
992 vaDestroySurfaces(dst_dev->
display, &surface_id, 1);
1003 VASurfaceID surface_id;
1008 unsigned long buffer_handle;
1009 VASurfaceAttribExternalBuffers buffer_desc;
1010 VASurfaceAttrib attrs[2] = {
1012 .type = VASurfaceAttribMemoryType,
1013 .flags = VA_SURFACE_ATTRIB_SETTABLE,
1014 .value.type = VAGenericValueTypeInteger,
1015 .value.value.i = VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME,
1018 .type = VASurfaceAttribExternalBufferDescriptor,
1019 .flags = VA_SURFACE_ATTRIB_SETTABLE,
1020 .value.type = VAGenericValueTypePointer,
1021 .value.value.p = &buffer_desc,
1027 if (
desc->nb_objects != 1) {
1029 "made from a single DRM object.\n");
1035 if (
desc->nb_layers != vaapi_drm_format_map[i].nb_layer_formats)
1037 for (j = 0; j <
desc->nb_layers; j++) {
1038 if (
desc->layers[j].format !=
1039 vaapi_drm_format_map[i].layer_formats[j])
1042 if (j !=
desc->nb_layers)
1044 va_fourcc = vaapi_drm_format_map[i].va_fourcc;
1054 "%08x.\n",
desc->objects[0].fd, va_fourcc);
1059 buffer_handle =
desc->objects[0].fd;
1060 buffer_desc.pixel_format = va_fourcc;
1061 buffer_desc.width = src_fc->width;
1062 buffer_desc.height = src_fc->height;
1063 buffer_desc.data_size =
desc->objects[0].size;
1064 buffer_desc.buffers = &buffer_handle;
1065 buffer_desc.num_buffers = 1;
1066 buffer_desc.flags = 0;
1069 for (i = 0; i <
desc->nb_layers; i++) {
1070 for (j = 0; j <
desc->layers[i].nb_planes; j++) {
1071 buffer_desc.pitches[k] =
desc->layers[i].planes[j].pitch;
1072 buffer_desc.offsets[k] =
desc->layers[i].planes[j].offset;
1076 buffer_desc.num_planes = k;
1078 if (format_desc->chroma_planes_swapped &&
1079 buffer_desc.num_planes == 3) {
1080 FFSWAP(uint32_t, buffer_desc.pitches[1], buffer_desc.pitches[2]);
1081 FFSWAP(uint32_t, buffer_desc.offsets[1], buffer_desc.offsets[2]);
1084 vas = vaCreateSurfaces(dst_dev->display, format_desc->rt_format,
1088 if (vas != VA_STATUS_SUCCESS) {
1090 "object: %d (%s).\n", vas, vaErrorStr(vas));
1096 &vaapi_unmap_from_drm,
1097 (
void*)(uintptr_t)surface_id);
1101 dst->width =
src->width;
1102 dst->height =
src->height;
1103 dst->data[3] = (
uint8_t*)(uintptr_t)surface_id;
1106 "surface %#x.\n",
desc->objects[0].fd, surface_id);
1111 #if VA_CHECK_VERSION(1, 1, 0)
1128 VASurfaceID surface_id;
1130 VADRMPRIMESurfaceDescriptor va_desc;
1132 uint32_t export_flags;
1135 surface_id = (VASurfaceID)(uintptr_t)src->
data[3];
1137 export_flags = VA_EXPORT_SURFACE_SEPARATE_LAYERS;
1139 export_flags |= VA_EXPORT_SURFACE_READ_ONLY;
1141 export_flags |= VA_EXPORT_SURFACE_WRITE_ONLY;
1143 vas = vaExportSurfaceHandle(hwctx->
display, surface_id,
1144 VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME_2,
1145 export_flags, &va_desc);
1146 if (vas != VA_STATUS_SUCCESS) {
1147 if (vas == VA_STATUS_ERROR_UNIMPLEMENTED)
1150 "%d (%s).\n", surface_id, vas, vaErrorStr(vas));
1162 for (i = 0; i < va_desc.num_objects; i++) {
1163 drm_desc->
objects[i].
fd = va_desc.objects[i].fd;
1164 drm_desc->
objects[i].
size = va_desc.objects[i].size;
1166 va_desc.objects[i].drm_format_modifier;
1168 drm_desc->
nb_layers = va_desc.num_layers;
1169 for (i = 0; i < va_desc.num_layers; i++) {
1170 drm_desc->
layers[i].
format = va_desc.layers[i].drm_format;
1172 for (j = 0; j < va_desc.layers[i].num_planes; j++) {
1174 va_desc.layers[i].object_index[j];
1176 va_desc.layers[i].offset[j];
1178 va_desc.layers[i].pitch[j];
1183 &vaapi_unmap_to_drm_esh, drm_desc);
1194 for (i = 0; i < va_desc.num_objects; i++)
1195 close(va_desc.objects[i].fd);
1201 #if VA_CHECK_VERSION(0, 36, 0)
1202 typedef struct VAAPIDRMImageBufferMapping {
1204 VABufferInfo buffer_info;
1207 } VAAPIDRMImageBufferMapping;
1213 VAAPIDRMImageBufferMapping *mapping = hwmap->
priv;
1214 VASurfaceID surface_id;
1217 surface_id = (VASurfaceID)(uintptr_t)hwmap->
source->
data[3];
1224 vas = vaReleaseBufferHandle(hwctx->
display, mapping->image.buf);
1225 if (vas != VA_STATUS_SUCCESS) {
1227 "handle of image %#x (derived from surface %#x): "
1228 "%d (%s).\n", mapping->image.buf, surface_id,
1229 vas, vaErrorStr(vas));
1232 vas = vaDestroyImage(hwctx->
display, mapping->image.image_id);
1233 if (vas != VA_STATUS_SUCCESS) {
1235 "derived from surface %#x: %d (%s).\n",
1236 surface_id, vas, vaErrorStr(vas));
1243 const AVFrame *src,
int flags)
1246 VAAPIDRMImageBufferMapping *mapping =
NULL;
1247 VASurfaceID surface_id;
1251 surface_id = (VASurfaceID)(uintptr_t)src->
data[3];
1259 vas = vaDeriveImage(hwctx->
display, surface_id,
1261 if (vas != VA_STATUS_SUCCESS) {
1263 "surface %#x: %d (%s).\n",
1264 surface_id, vas, vaErrorStr(vas));
1270 if (vaapi_drm_format_map[i].va_fourcc ==
1271 mapping->image.format.fourcc)
1276 "VAAPI format %#x.\n", mapping->image.format.fourcc);
1281 mapping->buffer_info.mem_type =
1282 VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME;
1284 mapping->drm_desc.nb_layers =
1285 vaapi_drm_format_map[i].nb_layer_formats;
1286 if (mapping->drm_desc.nb_layers > 1) {
1287 if (mapping->drm_desc.nb_layers != mapping->image.num_planes) {
1289 "expected format: got %d planes, but expected %d.\n",
1290 mapping->image.num_planes, mapping->drm_desc.nb_layers);
1295 for(p = 0; p < mapping->drm_desc.nb_layers; p++) {
1297 .format = vaapi_drm_format_map[i].layer_formats[p],
1301 .offset = mapping->image.offsets[p],
1302 .pitch = mapping->image.pitches[p],
1307 mapping->drm_desc.layers[0].format =
1308 vaapi_drm_format_map[i].layer_formats[0];
1309 mapping->drm_desc.layers[0].nb_planes = mapping->image.num_planes;
1310 for (p = 0; p < mapping->image.num_planes; p++) {
1313 .offset = mapping->image.offsets[p],
1314 .pitch = mapping->image.pitches[p],
1319 vas = vaAcquireBufferHandle(hwctx->
display, mapping->image.buf,
1320 &mapping->buffer_info);
1321 if (vas != VA_STATUS_SUCCESS) {
1323 "handle from image %#x (derived from surface %#x): "
1324 "%d (%s).\n", mapping->image.buf, surface_id,
1325 vas, vaErrorStr(vas));
1331 mapping->buffer_info.handle);
1333 mapping->drm_desc.nb_objects = 1;
1335 .fd = mapping->buffer_info.handle,
1336 .size = mapping->image.data_size,
1338 .format_modifier = DRM_FORMAT_MOD_INVALID,
1342 dst, src, &vaapi_unmap_to_drm_abh,
1354 vaReleaseBufferHandle(hwctx->
display, mapping->image.buf);
1356 vaDestroyImage(hwctx->
display, mapping->image.image_id);
1364 const AVFrame *src,
int flags)
1366 #if VA_CHECK_VERSION(1, 1, 0)
1368 err = vaapi_map_to_drm_esh(hwfc, dst, src, flags);
1372 #if VA_CHECK_VERSION(0, 36, 0)
1373 return vaapi_map_to_drm_abh(hwfc, dst, src, flags);
1381 const AVFrame *src,
int flags)
1386 return vaapi_map_from_drm(hwfc, dst, src, flags);
1394 const AVFrame *src,
int flags)
1399 return vaapi_map_to_drm(hwfc, dst, src, flags);
1415 if (priv->x11_display)
1416 XCloseDisplay(priv->x11_display);
1426 static void vaapi_device_log_error(
void *context,
const char *
message)
1433 static void vaapi_device_log_info(
void *context,
const char *
message)
1449 vaSetErrorCallback(display, &vaapi_device_log_error, ctx);
1450 vaSetInfoCallback (display, &vaapi_device_log_info, ctx);
1455 vas = vaInitialize(display, &major, &minor);
1456 if (vas != VA_STATUS_SUCCESS) {
1458 "connection: %d (%s).\n", vas, vaErrorStr(vas));
1462 "version %d.%d\n", major, minor);
1471 VADisplay display =
NULL;
1483 if (!display && !(device && device[0] ==
'/')) {
1485 priv->x11_display = XOpenDisplay(device);
1486 if (!priv->x11_display) {
1488 "%s.\n", XDisplayName(device));
1490 display = vaGetDisplay(priv->x11_display);
1493 "from X11 display %s.\n", XDisplayName(device));
1498 "X11 display %s.\n", XDisplayName(device));
1508 const char *path = device ? device :
"/dev/dri/renderD128";
1509 priv->
drm_fd = open(path, O_RDWR);
1514 display = vaGetDisplayDRM(priv->
drm_fd);
1517 "from DRM device %s.\n", path);
1522 "DRM device %s.\n", path);
1529 "device: %s.\n", device ? device :
"");
1545 if (src_hwctx->
fd < 0) {
1547 "device to derive a VA display from.\n");
1561 display = vaGetDisplayDRM(src_hwctx->
fd);
This struct aggregates all the (hardware/vendor-specific) "high-level" state, i.e.
The driver does not support the VASurfaceAttribMemoryType attribute, so the surface allocation code w...
static enum AVPixelFormat pix_fmt
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.
ptrdiff_t const GLvoid * 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.
The driver does not destroy parameter buffers when they are used by vaRenderPicture().
int width
The allocated dimensions of the frames in this pool.
static int vaapi_get_buffer(AVHWFramesContext *hwfc, AVFrame *frame)
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
static const VAAPIFormatDescriptor * vaapi_format_from_pix_fmt(enum AVPixelFormat pix_fmt)
int max_width
The maximum size of frames in this hw_frames_ctx.
int nb_objects
Number of DRM objects making up this frame.
static const VAAPIFormatDescriptor * vaapi_format_from_fourcc(unsigned int fourcc)
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 const VAAPIFormatDescriptor vaapi_format_map[]
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)
void * hwctx
The format-specific data, allocated and freed by libavutil along with this context.
AVDRMLayerDescriptor layers[AV_DRM_MAX_PLANES]
Array of layers in the frame.
The mapping must be direct.
#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)
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.
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(* 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.
The driver does not support surface attributes at all.
#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().
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.
#define MAP(va, rt, av, swap_uv)
static const struct @290 vaapi_driver_quirks_table[]
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)
The mapping must be writeable.
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.
The mapped frame will be overwritten completely in subsequent operations, so the current frame data n...
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.
The mapping must be readable.
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.
The quirks field has been set by the user and should not be detected automatically by av_hwdevice_ctx...
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.
The maximum number of layers/planes in a DRM frame.
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)
#define flags(name, subs,...)
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.
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.
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.