The source frame may be cropped, so that its dimensions are smaller than
the pool dimensions. Since transfer_data might require the destination
sw frame to be the same size as the hw frames in the pool, it is safer
to allocate for the pool size.
---
 libavutil/hwcontext.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/libavutil/hwcontext.c b/libavutil/hwcontext.c
index 9ffc718..98d1a90 100644
--- a/libavutil/hwcontext.c
+++ b/libavutil/hwcontext.c
@@ -315,6 +315,7 @@ int av_hwframe_transfer_get_formats(AVBufferRef 
*hwframe_ref,
 
 static int transfer_data_alloc(AVFrame *dst, const AVFrame *src, int flags)
 {
+    AVHWFramesContext *ctx = (AVHWFramesContext*)src->hw_frames_ctx->data;
     AVFrame *frame_tmp;
     int ret = 0;
 
@@ -337,8 +338,8 @@ static int transfer_data_alloc(AVFrame *dst, const AVFrame 
*src, int flags)
         frame_tmp->format = formats[0];
         av_freep(&formats);
     }
-    frame_tmp->width  = src->width;
-    frame_tmp->height = src->height;
+    frame_tmp->width  = ctx->width;
+    frame_tmp->height = ctx->height;
 
     ret = av_frame_get_buffer(frame_tmp, 32);
     if (ret < 0)
@@ -348,6 +349,9 @@ static int transfer_data_alloc(AVFrame *dst, const AVFrame 
*src, int flags)
     if (ret < 0)
         goto fail;
 
+    frame_tmp->width  = src->width;
+    frame_tmp->height = src->height;
+
     av_frame_move_ref(dst, frame_tmp);
 
 fail:
-- 
2.0.0

_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to