[FFmpeg-cvslog] lavu/hwcontext_vaapi: sync surface before export its DRM handle

Fei Wang git at videolan.org
Mon Feb 27 07:56:24 EET 2023


ffmpeg | branch: master | Fei Wang <fei.w.wang-at-intel.com at ffmpeg.org> | Fri Feb 24 13:45:49 2023 +0800| [15992a040dd017d6897131373321522fe2867a6d] | committer: Haihao Xiang

lavu/hwcontext_vaapi: sync surface before export its DRM handle

According to description of vaExportSurfaceHandle in libva, vaSyncSurface
must be called if the contents of the surface will be read.

Fixes ticket #9967.

Reviewed-by: Zhao Zhili <zhilizhao at tencent.com>
Signed-off-by: Fei Wang <fei.w.wang at intel.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=15992a040dd017d6897131373321522fe2867a6d
---

 libavutil/hwcontext_vaapi.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c
index 938bd5447d..90c2c191d9 100644
--- a/libavutil/hwcontext_vaapi.c
+++ b/libavutil/hwcontext_vaapi.c
@@ -1319,8 +1319,17 @@ static int vaapi_map_to_drm_esh(AVHWFramesContext *hwfc, AVFrame *dst,
     surface_id = (VASurfaceID)(uintptr_t)src->data[3];
 
     export_flags = VA_EXPORT_SURFACE_SEPARATE_LAYERS;
-    if (flags & AV_HWFRAME_MAP_READ)
+    if (flags & AV_HWFRAME_MAP_READ) {
         export_flags |= VA_EXPORT_SURFACE_READ_ONLY;
+
+        vas = vaSyncSurface(hwctx->display, surface_id);
+        if (vas != VA_STATUS_SUCCESS) {
+            av_log(hwfc, AV_LOG_ERROR, "Failed to sync surface "
+                   "%#x: %d (%s).\n", surface_id, vas, vaErrorStr(vas));
+            return AVERROR(EIO);
+        }
+    }
+
     if (flags & AV_HWFRAME_MAP_WRITE)
         export_flags |= VA_EXPORT_SURFACE_WRITE_ONLY;
 



More information about the ffmpeg-cvslog mailing list