]> git.sesse.net Git - ffmpeg/commitdiff
hwcontext_vaapi: allow transfers to/from any size of sw frame
authorMark Thompson <sw@jkqxz.net>
Fri, 15 Apr 2016 09:58:51 +0000 (10:58 +0100)
committerAnton Khirnov <anton@khirnov.net>
Tue, 28 Jun 2016 06:32:11 +0000 (08:32 +0200)
The hw frame used as reference has an attached size but it need not
match the actual size of the surface, so enforcing that the sw frame
used in copying matches its size exactly is not useful.

Signed-off-by: Anton Khirnov <anton@khirnov.net>
libavutil/hwcontext_vaapi.c

index 1bdc4cbc1aed38143b1fdf0afe6aea18e8dfd996..ee5ce5d07533dc3df222b8f14e4ceff7c521efc2 100644 (file)
@@ -770,6 +770,9 @@ static int vaapi_transfer_data_from(AVHWFramesContext *hwfc,
     AVFrame *map;
     int err;
 
+    if (dst->width > hwfc->width || dst->height > hwfc->height)
+        return AVERROR(EINVAL);
+
     map = av_frame_alloc();
     if (!map)
         return AVERROR(ENOMEM);
@@ -779,6 +782,9 @@ static int vaapi_transfer_data_from(AVHWFramesContext *hwfc,
     if (err)
         goto fail;
 
+    map->width  = dst->width;
+    map->height = dst->height;
+
     err = av_frame_copy(dst, map);
     if (err)
         goto fail;
@@ -795,6 +801,9 @@ static int vaapi_transfer_data_to(AVHWFramesContext *hwfc,
     AVFrame *map;
     int err;
 
+    if (src->width > hwfc->width || src->height > hwfc->height)
+        return AVERROR(EINVAL);
+
     map = av_frame_alloc();
     if (!map)
         return AVERROR(ENOMEM);
@@ -804,6 +813,9 @@ static int vaapi_transfer_data_to(AVHWFramesContext *hwfc,
     if (err)
         goto fail;
 
+    map->width  = src->width;
+    map->height = src->height;
+
     err = av_frame_copy(map, src);
     if (err)
         goto fail;