History

lavu/hwcontext_vaapi: Use vaMapBuffer2 for mapping image buffers

This allows some optimizations in driver, such as not having to read back the data if write-only mapping is requested.

David Rosca committed 3 years ago

Commit 1e2ac481 parent 578ac591 file · +12 −0Browse files

Unified · Split

libavutil/hwcontext_vaapi.c+12−0
@@ -809,6 +809,9 @@ static int vaapi_map_frame(AVHWFramesContext *hwfc, · 808 unmodified lines
809809 VAStatus vas;
810810 void *address = NULL;
811811 int err, i;
812+#if VA_CHECK_VERSION(1, 21, 0)
813+ uint32_t vaflags = 0;
814+#endif
812815
813816 surface_id = (VASurfaceID)(uintptr_t)src->data[3];
814817 av_log(hwfc, AV_LOG_DEBUG, "Map surface %#x.\n", surface_id);
@@ -892,7 +895,16 @@ static int vaapi_map_frame(AVHWFramesContext *hwfc, · 77 unmodified lines
892895 }
893896 }
894897
898+#if VA_CHECK_VERSION(1, 21, 0)
899+ if (flags & AV_HWFRAME_MAP_READ)
900+ vaflags |= VA_MAPBUFFER_FLAG_READ;
901+ if (flags & AV_HWFRAME_MAP_WRITE)
902+ vaflags |= VA_MAPBUFFER_FLAG_WRITE;
903+ // On drivers not implementing vaMapBuffer2 libva calls vaMapBuffer instead.
904+ vas = vaMapBuffer2(hwctx->display, map->image.buf, &address, vaflags);
905+#else
895906 vas = vaMapBuffer(hwctx->display, map->image.buf, &address);
907+#endif
896908 if (vas != VA_STATUS_SUCCESS) {
897909 av_log(hwfc, AV_LOG_ERROR, "Failed to map image from surface "
898910 "%#x: %d (%s).\n", surface_id, vas, vaErrorStr(vas));

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t