plugins: improve video memory flags safety checks.
authorGwenole Beauchesne <gwenole.beauchesne@intel.com>
Mon, 3 Jun 2013 08:06:29 +0000 (10:06 +0200)
committerGwenole Beauchesne <gwenole.beauchesne@intel.com>
Wed, 5 Jun 2013 09:09:37 +0000 (11:09 +0200)
On map, ensure we have GST_MAP_WRITE flags since this is only what we
support for now. Likewise, on unmap, make sure that the VA image is
unmapped for either read or write, while still committing it to the
VA surface if write was requested.

gst/vaapi/gstvaapivideomemory.c

index d6a5208..f8db2e2 100644 (file)
@@ -107,9 +107,10 @@ gst_video_meta_map_vaapi_memory(GstVideoMeta *meta, guint plane,
                              allocator), FALSE);
     g_return_val_if_fail(mem->meta, FALSE);
 
-    if ((flags & GST_MAP_READWRITE) == GST_MAP_READ)
+    if ((flags & GST_MAP_READWRITE) != GST_MAP_WRITE)
         goto error_unsupported_map;
 
+    /* Map for writing */
     if (++mem->map_count == 1) {
         if (!ensure_surface(mem))
             goto error_ensure_surface;
@@ -169,7 +170,9 @@ gst_video_meta_unmap_vaapi_memory(GstVideoMeta *meta, guint plane,
     g_return_val_if_fail(mem->image, FALSE);
 
     if (--mem->map_count == 0) {
-        gst_vaapi_image_unmap(mem->image);
+        /* Unmap VA image used for read/writes */
+        if (info->flags & GST_MAP_READWRITE)
+            gst_vaapi_image_unmap(mem->image);
 
         /* Commit VA image to surface */
         if ((info->flags & GST_MAP_WRITE) && !mem->use_direct_rendering) {