[FFmpeg-devel] [PATCH] lavu/hwcontext_drm: don't fail mapping when dst format is unset

Cameron Gutman aicommander at gmail.com
Mon Jan 3 05:24:19 EET 2022


av_hwframe_map() is documented to work with a blank dst frame, but
hwcontext_drm currently fails if dst->format == AV_PIX_FMT_NONE.

Signed-off-by: Cameron Gutman <aicommander at gmail.com>
---
 libavutil/hwcontext_drm.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavutil/hwcontext_drm.c b/libavutil/hwcontext_drm.c
index 7a9fdbd263..85a9fd4984 100644
--- a/libavutil/hwcontext_drm.c
+++ b/libavutil/hwcontext_drm.c
@@ -287,7 +287,9 @@ static int drm_map_from(AVHWFramesContext *hwfc, AVFrame *dst,
 {
     int err;
 
-    if (hwfc->sw_format != dst->format)
+    if (dst->format == AV_PIX_FMT_NONE)
+        dst->format = hwfc->sw_format;
+    else if (hwfc->sw_format != dst->format)
         return AVERROR(ENOSYS);
 
     err = drm_map_frame(hwfc, dst, src, flags);
-- 
2.25.1



More information about the ffmpeg-devel mailing list