From 1bc5f00dfea3c968d0086db21e7bd26c0b8d0344 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Manuel=20J=C3=A1quez=20Leal?= Date: Thu, 20 Oct 2016 18:09:59 +0200 Subject: [PATCH] vaapivideomemory: log in perf category when copy Log in performance category when the derive image handling fails, falling back to memory copy. --- gst/vaapi/gstvaapivideomemory.c | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/gst/vaapi/gstvaapivideomemory.c b/gst/vaapi/gstvaapivideomemory.c index b0d6fd13b5..468c6f612b 100644 --- a/gst/vaapi/gstvaapivideomemory.c +++ b/gst/vaapi/gstvaapivideomemory.c @@ -28,6 +28,7 @@ #include "gstvaapivideomemory.h" #include "gstvaapipluginutil.h" +GST_DEBUG_CATEGORY_STATIC (CAT_PERFORMANCE); GST_DEBUG_CATEGORY_STATIC (gst_debug_vaapivideomemory); #define GST_CAT_DEFAULT gst_debug_vaapivideomemory @@ -45,6 +46,27 @@ GST_DEBUG_CATEGORY_STATIC (gst_debug_vaapivideomemory); static void gst_vaapi_video_memory_reset_image (GstVaapiVideoMemory * mem); +static void +_init_performance_debug (void) +{ +#ifndef GST_DISABLE_GST_DEBUG + static volatile gsize _init = 0; + + if (g_once_init_enter (&_init)) { + GST_DEBUG_CATEGORY_GET (CAT_PERFORMANCE, "GST_PERFORMANCE"); + g_once_init_leave (&_init, 1); + } +#endif +} + +static inline void +reset_image_usage (gboolean * flag) +{ + _init_performance_debug (); + GST_CAT_INFO (CAT_PERFORMANCE, "derive image failed, fallbacking to copy"); + *flag = FALSE; +} + static guchar * get_image_data (GstVaapiImage * image) { @@ -74,12 +96,11 @@ ensure_image (GstVaapiVideoMemory * mem) if (!mem->image && mem->use_direct_rendering) { mem->image = gst_vaapi_surface_derive_image (mem->surface); if (!mem->image) { - GST_WARNING ("failed to derive image, fallbacking to copy"); - mem->use_direct_rendering = FALSE; + reset_image_usage (&mem->use_direct_rendering); } else if (gst_vaapi_surface_get_format (mem->surface) != GST_VIDEO_INFO_FORMAT (mem->image_info)) { gst_vaapi_object_replace (&mem->image, NULL); - mem->use_direct_rendering = FALSE; + reset_image_usage (&mem->use_direct_rendering); } }