vaapioverlay: use vpp blend state iif using alpha
authorU. Artie Eoff <ullysses.a.eoff@intel.com>
Fri, 19 Nov 2021 22:46:34 +0000 (14:46 -0800)
committerU. Artie Eoff <ullysses.a.eoff@intel.com>
Thu, 17 Feb 2022 03:19:56 +0000 (19:19 -0800)
Don't set VAAPI vpp blend flags if alpha == 1.0,
i.e. fully opaque.  This can avoid extra processing
overhead on some drivers that apply blending
unconditionally when flags are present, even if the
end result is the same without blend flags (i.e. all
opaque alpha channels).

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1380>

subprojects/gstreamer-vaapi/gst-libs/gst/vaapi/gstvaapiblend.c

index 07a1ab6..9f7cf94 100644 (file)
@@ -275,9 +275,11 @@ gst_vaapi_blend_process_unlocked (GstVaapiBlend * blend,
     param->output_background_color = 0xff000000;
 
 #if VA_CHECK_VERSION(1,1,0)
-    blend_state.flags = VA_BLEND_GLOBAL_ALPHA;
-    blend_state.global_alpha = current->alpha;
-    param->blend_state = &blend_state;
+    if (current->alpha < 1.0) {
+      blend_state.flags = VA_BLEND_GLOBAL_ALPHA;
+      blend_state.global_alpha = current->alpha;
+      param->blend_state = &blend_state;
+    }
 #endif
 
     vaapi_unmap_buffer (va_display, id, NULL);