2010-03-04 17:39:58 +00:00
|
|
|
/*
|
|
|
|
* gstvaapisubpicture.c - VA subpicture abstraction
|
|
|
|
*
|
2012-01-16 09:41:10 +00:00
|
|
|
* Copyright (C) 2010-2011 Splitted-Desktop Systems
|
2013-11-22 04:57:18 +00:00
|
|
|
* Author: Gwenole Beauchesne <gwenole.beauchesne@splitted-desktop.com>
|
2013-01-29 13:14:45 +00:00
|
|
|
* Copyright (C) 2011-2013 Intel Corporation
|
2013-11-22 04:57:18 +00:00
|
|
|
* Author: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
|
2010-03-04 17:39:58 +00:00
|
|
|
*
|
2011-06-14 11:51:41 +00:00
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2.1
|
|
|
|
* of the License, or (at your option) any later version.
|
2010-03-04 17:39:58 +00:00
|
|
|
*
|
2011-06-14 11:51:41 +00:00
|
|
|
* This library is distributed in the hope that it will be useful,
|
2010-03-04 17:39:58 +00:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2011-06-14 11:51:41 +00:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
2010-03-04 17:39:58 +00:00
|
|
|
*
|
2011-06-14 11:51:41 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free
|
|
|
|
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301 USA
|
2010-03-04 17:39:58 +00:00
|
|
|
*/
|
|
|
|
|
2010-03-19 15:45:21 +00:00
|
|
|
/**
|
2010-03-24 08:16:32 +00:00
|
|
|
* SECTION:gstvaapisubpicture
|
|
|
|
* @short_description: VA subpicture abstraction
|
2010-03-19 15:45:21 +00:00
|
|
|
*/
|
|
|
|
|
2012-01-30 17:12:59 +00:00
|
|
|
#include "sysdeps.h"
|
2010-03-24 16:25:56 +00:00
|
|
|
#include "gstvaapicompat.h"
|
2010-03-16 09:15:48 +00:00
|
|
|
#include "gstvaapiutils.h"
|
2010-03-04 17:39:58 +00:00
|
|
|
#include "gstvaapisubpicture.h"
|
2013-04-30 15:22:15 +00:00
|
|
|
#include "gstvaapiobject_priv.h"
|
2013-07-26 10:57:19 +00:00
|
|
|
#include "gstvaapiimage_priv.h"
|
2010-03-04 17:39:58 +00:00
|
|
|
|
|
|
|
#define DEBUG 1
|
2010-03-16 09:17:41 +00:00
|
|
|
#include "gstvaapidebug.h"
|
2010-03-04 17:39:58 +00:00
|
|
|
|
2016-02-03 10:50:13 +00:00
|
|
|
typedef struct _GstVaapiSubpictureClass GstVaapiSubpictureClass;
|
2010-03-04 17:39:58 +00:00
|
|
|
|
2013-04-30 15:22:15 +00:00
|
|
|
/**
|
|
|
|
* GstVaapiSubpicture:
|
|
|
|
*
|
|
|
|
* A VA subpicture wrapper
|
|
|
|
*/
|
2016-02-03 10:50:13 +00:00
|
|
|
struct _GstVaapiSubpicture
|
|
|
|
{
|
|
|
|
/*< private > */
|
|
|
|
GstVaapiObject parent_instance;
|
2010-03-04 17:39:58 +00:00
|
|
|
|
2016-02-03 10:50:13 +00:00
|
|
|
GstVaapiImage *image;
|
|
|
|
guint flags;
|
|
|
|
gfloat global_alpha;
|
2010-03-04 17:39:58 +00:00
|
|
|
};
|
|
|
|
|
2013-04-30 15:22:15 +00:00
|
|
|
/**
|
|
|
|
* GstVaapiSubpictureClass:
|
|
|
|
*
|
|
|
|
* A VA subpicture wrapper class
|
|
|
|
*/
|
2016-02-03 10:50:13 +00:00
|
|
|
struct _GstVaapiSubpictureClass
|
|
|
|
{
|
|
|
|
/*< private > */
|
|
|
|
GstVaapiObjectClass parent_class;
|
2010-03-04 17:39:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
2016-02-03 10:50:13 +00:00
|
|
|
gst_vaapi_subpicture_destroy (GstVaapiSubpicture * subpicture)
|
2010-03-04 17:39:58 +00:00
|
|
|
{
|
2016-02-03 10:50:13 +00:00
|
|
|
GstVaapiDisplay *const display = GST_VAAPI_OBJECT_DISPLAY (subpicture);
|
|
|
|
VASubpictureID subpicture_id;
|
|
|
|
VAStatus status;
|
|
|
|
|
|
|
|
subpicture_id = GST_VAAPI_OBJECT_ID (subpicture);
|
|
|
|
GST_DEBUG ("subpicture %" GST_VAAPI_ID_FORMAT,
|
|
|
|
GST_VAAPI_ID_ARGS (subpicture_id));
|
|
|
|
|
|
|
|
if (subpicture_id != VA_INVALID_ID) {
|
|
|
|
if (display) {
|
|
|
|
GST_VAAPI_DISPLAY_LOCK (display);
|
|
|
|
status = vaDestroySubpicture (GST_VAAPI_DISPLAY_VADISPLAY (display),
|
|
|
|
subpicture_id);
|
|
|
|
GST_VAAPI_DISPLAY_UNLOCK (display);
|
|
|
|
if (!vaapi_check_status (status, "vaDestroySubpicture()"))
|
2018-10-09 15:23:30 +00:00
|
|
|
GST_WARNING ("failed to destroy subpicture %" GST_VAAPI_ID_FORMAT,
|
2016-02-03 10:50:13 +00:00
|
|
|
GST_VAAPI_ID_ARGS (subpicture_id));
|
2010-03-04 17:39:58 +00:00
|
|
|
}
|
2016-02-03 10:50:13 +00:00
|
|
|
GST_VAAPI_OBJECT_ID (subpicture) = VA_INVALID_ID;
|
|
|
|
}
|
2019-12-18 11:57:01 +00:00
|
|
|
gst_mini_object_replace ((GstMiniObject **) & subpicture->image, NULL);
|
2010-03-04 17:39:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2016-02-03 10:50:13 +00:00
|
|
|
gst_vaapi_subpicture_create (GstVaapiSubpicture * subpicture,
|
|
|
|
GstVaapiImage * image)
|
2010-03-04 17:39:58 +00:00
|
|
|
{
|
2016-02-03 10:50:13 +00:00
|
|
|
GstVaapiDisplay *const display = GST_VAAPI_OBJECT_DISPLAY (subpicture);
|
|
|
|
VASubpictureID subpicture_id;
|
|
|
|
VAStatus status;
|
|
|
|
|
|
|
|
GST_VAAPI_DISPLAY_LOCK (display);
|
|
|
|
status = vaCreateSubpicture (GST_VAAPI_DISPLAY_VADISPLAY (display),
|
2019-12-18 11:57:01 +00:00
|
|
|
GST_VAAPI_IMAGE_ID (image), &subpicture_id);
|
2016-02-03 10:50:13 +00:00
|
|
|
GST_VAAPI_DISPLAY_UNLOCK (display);
|
|
|
|
if (!vaapi_check_status (status, "vaCreateSubpicture()"))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
GST_DEBUG ("subpicture %" GST_VAAPI_ID_FORMAT,
|
|
|
|
GST_VAAPI_ID_ARGS (subpicture_id));
|
|
|
|
GST_VAAPI_OBJECT_ID (subpicture) = subpicture_id;
|
2019-12-18 11:57:01 +00:00
|
|
|
subpicture->image =
|
|
|
|
(GstVaapiImage *) gst_mini_object_ref (GST_MINI_OBJECT_CAST (image));
|
2016-02-03 10:50:13 +00:00
|
|
|
return TRUE;
|
2010-03-04 17:39:58 +00:00
|
|
|
}
|
|
|
|
|
2013-04-30 15:22:15 +00:00
|
|
|
#define gst_vaapi_subpicture_finalize gst_vaapi_subpicture_destroy
|
2016-02-03 10:50:13 +00:00
|
|
|
GST_VAAPI_OBJECT_DEFINE_CLASS (GstVaapiSubpicture, gst_vaapi_subpicture)
|
2010-03-04 17:39:58 +00:00
|
|
|
|
2010-03-19 15:45:21 +00:00
|
|
|
/**
|
|
|
|
* gst_vaapi_subpicture_new:
|
|
|
|
* @image: a #GstVaapiImage
|
2012-05-15 08:24:08 +00:00
|
|
|
* @flags: #GstVaapiSubpictureFlags, or zero
|
2010-03-19 15:45:21 +00:00
|
|
|
*
|
|
|
|
* Creates a new #GstVaapiSubpicture with @image as source pixels. The
|
|
|
|
* newly created object holds a reference on @image.
|
|
|
|
*
|
|
|
|
* Return value: the newly allocated #GstVaapiSubpicture object
|
|
|
|
*/
|
2016-02-03 10:50:13 +00:00
|
|
|
GstVaapiSubpicture *gst_vaapi_subpicture_new (GstVaapiImage * image,
|
|
|
|
guint flags)
|
2010-03-04 17:39:58 +00:00
|
|
|
{
|
2016-02-03 10:50:13 +00:00
|
|
|
GstVaapiSubpicture *subpicture;
|
|
|
|
GstVaapiDisplay *display;
|
|
|
|
GstVideoFormat format;
|
|
|
|
guint va_flags;
|
2012-05-15 08:24:08 +00:00
|
|
|
|
2016-02-03 10:50:13 +00:00
|
|
|
g_return_val_if_fail (image != NULL, NULL);
|
2010-03-10 13:13:51 +00:00
|
|
|
|
2016-02-03 10:50:13 +00:00
|
|
|
GST_DEBUG ("create from image %" GST_VAAPI_ID_FORMAT,
|
2019-12-18 11:57:01 +00:00
|
|
|
GST_VAAPI_ID_ARGS (GST_VAAPI_IMAGE_ID (image)));
|
2010-03-04 17:39:58 +00:00
|
|
|
|
2019-12-18 11:57:01 +00:00
|
|
|
display = GST_VAAPI_IMAGE_DISPLAY (image);
|
2016-02-03 10:50:13 +00:00
|
|
|
format = GST_VAAPI_IMAGE_FORMAT (image);
|
|
|
|
if (!gst_vaapi_display_has_subpicture_format (display, format, &va_flags))
|
|
|
|
return NULL;
|
|
|
|
if (flags & ~va_flags)
|
|
|
|
return NULL;
|
2012-05-15 08:24:08 +00:00
|
|
|
|
2016-02-03 10:50:13 +00:00
|
|
|
subpicture = gst_vaapi_object_new (gst_vaapi_subpicture_class (), display);
|
|
|
|
if (!subpicture)
|
|
|
|
return NULL;
|
2013-04-30 15:22:15 +00:00
|
|
|
|
2016-02-03 10:50:13 +00:00
|
|
|
subpicture->global_alpha = 1.0f;
|
|
|
|
if (!gst_vaapi_subpicture_set_image (subpicture, image))
|
|
|
|
goto error;
|
|
|
|
return subpicture;
|
2013-04-30 15:22:15 +00:00
|
|
|
|
2016-10-19 17:04:20 +00:00
|
|
|
/* ERRORS */
|
2013-04-30 15:22:15 +00:00
|
|
|
error:
|
2016-10-19 17:04:20 +00:00
|
|
|
{
|
|
|
|
gst_vaapi_object_unref (subpicture);
|
|
|
|
return NULL;
|
|
|
|
}
|
2010-03-04 17:39:58 +00:00
|
|
|
}
|
|
|
|
|
2011-12-14 12:16:21 +00:00
|
|
|
/**
|
|
|
|
* gst_vaapi_subpicture_new_from_overlay_rectangle:
|
|
|
|
* @display: a #GstVaapiDisplay
|
|
|
|
* @rect: a #GstVideoOverlayRectangle
|
|
|
|
*
|
|
|
|
* Helper function that creates a new #GstVaapiSubpicture from a
|
|
|
|
* #GstVideoOverlayRectangle. A new #GstVaapiImage is also created
|
|
|
|
* along the way and attached to the resulting subpicture. The
|
|
|
|
* subpicture holds a unique reference to the underlying image.
|
|
|
|
*
|
|
|
|
* Return value: the newly allocated #GstVaapiSubpicture object
|
|
|
|
*/
|
|
|
|
GstVaapiSubpicture *
|
2016-02-03 10:50:13 +00:00
|
|
|
gst_vaapi_subpicture_new_from_overlay_rectangle (GstVaapiDisplay * display,
|
|
|
|
GstVideoOverlayRectangle * rect)
|
2011-12-14 12:16:21 +00:00
|
|
|
{
|
2016-02-03 10:50:13 +00:00
|
|
|
GstVaapiSubpicture *subpicture;
|
|
|
|
GstVideoFormat format;
|
|
|
|
GstVaapiImage *image;
|
|
|
|
GstVaapiImageRaw raw_image;
|
|
|
|
GstBuffer *buffer;
|
|
|
|
guint8 *data;
|
|
|
|
gfloat global_alpha;
|
|
|
|
guint width, height, stride;
|
|
|
|
guint hw_flags, flags;
|
|
|
|
GstVideoMeta *vmeta;
|
|
|
|
GstMapInfo map_info;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GST_IS_VIDEO_OVERLAY_RECTANGLE (rect), NULL);
|
|
|
|
|
|
|
|
/* XXX: use gst_vaapi_image_format_from_video() */
|
2011-12-14 12:16:21 +00:00
|
|
|
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
|
2016-02-03 10:50:13 +00:00
|
|
|
format = GST_VIDEO_FORMAT_BGRA;
|
2011-12-14 12:16:21 +00:00
|
|
|
#else
|
2016-02-03 10:50:13 +00:00
|
|
|
format = GST_VIDEO_FORMAT_ARGB;
|
2011-12-14 12:16:21 +00:00
|
|
|
#endif
|
2016-02-03 10:50:13 +00:00
|
|
|
if (!gst_vaapi_display_has_subpicture_format (display, format, &hw_flags))
|
|
|
|
return NULL;
|
2011-12-14 12:16:21 +00:00
|
|
|
|
2016-02-03 10:50:13 +00:00
|
|
|
flags =
|
|
|
|
hw_flags &
|
|
|
|
from_GstVideoOverlayFormatFlags (gst_video_overlay_rectangle_get_flags
|
|
|
|
(rect));
|
2012-05-15 08:24:08 +00:00
|
|
|
|
2016-02-03 10:50:13 +00:00
|
|
|
buffer = gst_video_overlay_rectangle_get_pixels_unscaled_argb (rect,
|
|
|
|
to_GstVideoOverlayFormatFlags (flags));
|
|
|
|
if (!buffer)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
vmeta = gst_buffer_get_video_meta (buffer);
|
|
|
|
if (!vmeta)
|
|
|
|
return NULL;
|
|
|
|
width = vmeta->width;
|
|
|
|
height = vmeta->height;
|
|
|
|
|
|
|
|
if (!gst_video_meta_map (vmeta, 0, &map_info, (gpointer *) & data,
|
|
|
|
(gint *) & stride, GST_MAP_READ))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
image = gst_vaapi_image_new (display, format, width, height);
|
|
|
|
if (!image)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
raw_image.format = format;
|
|
|
|
raw_image.width = width;
|
|
|
|
raw_image.height = height;
|
|
|
|
raw_image.num_planes = 1;
|
|
|
|
raw_image.pixels[0] = data;
|
|
|
|
raw_image.stride[0] = stride;
|
|
|
|
if (!gst_vaapi_image_update_from_raw (image, &raw_image, NULL)) {
|
|
|
|
GST_WARNING ("could not update VA image with subtitle data");
|
|
|
|
gst_vaapi_object_unref (image);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
subpicture = gst_vaapi_subpicture_new (image, flags);
|
|
|
|
gst_vaapi_object_unref (image);
|
|
|
|
gst_video_meta_unmap (vmeta, 0, &map_info);
|
|
|
|
if (!subpicture)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if (flags & GST_VAAPI_SUBPICTURE_FLAG_GLOBAL_ALPHA) {
|
|
|
|
global_alpha = gst_video_overlay_rectangle_get_global_alpha (rect);
|
|
|
|
if (!gst_vaapi_subpicture_set_global_alpha (subpicture, global_alpha))
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return subpicture;
|
2011-12-14 12:16:21 +00:00
|
|
|
}
|
|
|
|
|
2010-03-25 09:49:17 +00:00
|
|
|
/**
|
|
|
|
* gst_vaapi_subpicture_get_id:
|
|
|
|
* @subpicture: a #GstVaapiSubpicture
|
|
|
|
*
|
|
|
|
* Returns the underlying VASubpictureID of the @subpicture.
|
|
|
|
*
|
|
|
|
* Return value: the underlying VA subpicture id
|
|
|
|
*/
|
2010-03-30 07:39:16 +00:00
|
|
|
GstVaapiID
|
2016-02-03 10:50:13 +00:00
|
|
|
gst_vaapi_subpicture_get_id (GstVaapiSubpicture * subpicture)
|
2010-03-25 09:49:17 +00:00
|
|
|
{
|
2016-02-03 10:50:13 +00:00
|
|
|
g_return_val_if_fail (subpicture != NULL, VA_INVALID_ID);
|
2010-03-25 09:49:17 +00:00
|
|
|
|
2016-02-03 10:50:13 +00:00
|
|
|
return GST_VAAPI_OBJECT_ID (subpicture);
|
2010-03-25 09:49:17 +00:00
|
|
|
}
|
|
|
|
|
2012-05-15 08:24:08 +00:00
|
|
|
/**
|
|
|
|
* gst_vaapi_subpicture_get_flags:
|
|
|
|
* @subpicture: a #GstVaapiSubpicture
|
|
|
|
*
|
|
|
|
* Returns the @subpicture flags.
|
|
|
|
*
|
|
|
|
* Return value: the @subpicture flags
|
|
|
|
*/
|
|
|
|
guint
|
2016-02-03 10:50:13 +00:00
|
|
|
gst_vaapi_subpicture_get_flags (GstVaapiSubpicture * subpicture)
|
2012-05-15 08:24:08 +00:00
|
|
|
{
|
2016-02-03 10:50:13 +00:00
|
|
|
g_return_val_if_fail (subpicture != NULL, 0);
|
2012-05-15 08:24:08 +00:00
|
|
|
|
2016-02-03 10:50:13 +00:00
|
|
|
return subpicture->flags;
|
2012-05-15 08:24:08 +00:00
|
|
|
}
|
|
|
|
|
2010-03-19 15:45:21 +00:00
|
|
|
/**
|
|
|
|
* gst_vaapi_subpicture_get_image:
|
|
|
|
* @subpicture: a #GstVaapiSubpicture
|
|
|
|
*
|
|
|
|
* Returns the #GstVaapiImage this @subpicture is bound to.
|
|
|
|
*
|
|
|
|
* Return value: the #GstVaapiImage this @subpicture is bound to
|
|
|
|
*/
|
2010-03-04 17:39:58 +00:00
|
|
|
GstVaapiImage *
|
2016-02-03 10:50:13 +00:00
|
|
|
gst_vaapi_subpicture_get_image (GstVaapiSubpicture * subpicture)
|
2010-03-04 17:39:58 +00:00
|
|
|
{
|
2016-02-03 10:50:13 +00:00
|
|
|
g_return_val_if_fail (subpicture != NULL, NULL);
|
2010-03-04 17:39:58 +00:00
|
|
|
|
2016-02-03 10:50:13 +00:00
|
|
|
return subpicture->image;
|
2010-03-04 17:39:58 +00:00
|
|
|
}
|
|
|
|
|
2010-03-19 15:45:21 +00:00
|
|
|
/**
|
|
|
|
* gst_vaapi_subpicture_set_image:
|
|
|
|
* @subpicture: a #GstVaapiSubpicture
|
|
|
|
* @image: a #GstVaapiImage
|
|
|
|
*
|
|
|
|
* Binds a new #GstVaapiImage to the @subpicture. The reference to the
|
2011-12-12 14:31:52 +00:00
|
|
|
* previous image is released and a new one is acquired on @image.
|
2013-04-30 15:22:15 +00:00
|
|
|
*
|
|
|
|
* Return value: %TRUE on success
|
2010-03-19 15:45:21 +00:00
|
|
|
*/
|
2013-04-30 15:22:15 +00:00
|
|
|
gboolean
|
2016-02-03 10:50:13 +00:00
|
|
|
gst_vaapi_subpicture_set_image (GstVaapiSubpicture * subpicture,
|
|
|
|
GstVaapiImage * image)
|
2010-03-04 17:39:58 +00:00
|
|
|
{
|
2016-02-03 10:50:13 +00:00
|
|
|
g_return_val_if_fail (subpicture != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (image != NULL, FALSE);
|
2010-03-04 17:39:58 +00:00
|
|
|
|
2016-02-03 10:50:13 +00:00
|
|
|
gst_vaapi_subpicture_destroy (subpicture);
|
|
|
|
return gst_vaapi_subpicture_create (subpicture, image);
|
2010-03-04 17:39:58 +00:00
|
|
|
}
|
2012-05-15 08:24:08 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_vaapi_subpicture_get_global_alpha:
|
|
|
|
* @subpicture: a #GstVaapiSubpicture
|
|
|
|
*
|
|
|
|
* Returns the value of global_alpha, set for this @subpicture.
|
|
|
|
*
|
|
|
|
* Return value: the global_alpha value of this @subpicture
|
|
|
|
*/
|
|
|
|
gfloat
|
2016-02-03 10:50:13 +00:00
|
|
|
gst_vaapi_subpicture_get_global_alpha (GstVaapiSubpicture * subpicture)
|
2012-05-15 08:24:08 +00:00
|
|
|
{
|
2016-02-03 10:50:13 +00:00
|
|
|
g_return_val_if_fail (subpicture != NULL, 1.0);
|
2012-05-15 08:24:08 +00:00
|
|
|
|
2016-02-03 10:50:13 +00:00
|
|
|
return subpicture->global_alpha;
|
2012-05-15 08:24:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_vaapi_subpicture_set_global_alpha:
|
|
|
|
* @subpicture: a #GstVaapiSubpicture
|
|
|
|
* @global_alpha: value for global-alpha (range: 0.0 to 1.0, inclusive)
|
|
|
|
*
|
|
|
|
* Sets the global_alpha value of @subpicture. This function calls
|
|
|
|
* vaSetSubpictureGlobalAlpha() if the format of @subpicture, i.e.
|
|
|
|
* the current VA driver supports it.
|
|
|
|
*
|
|
|
|
* Return value: %TRUE if global_alpha could be set, %FALSE otherwise
|
|
|
|
*/
|
|
|
|
gboolean
|
2016-02-03 10:50:13 +00:00
|
|
|
gst_vaapi_subpicture_set_global_alpha (GstVaapiSubpicture * subpicture,
|
2012-05-15 08:24:08 +00:00
|
|
|
gfloat global_alpha)
|
|
|
|
{
|
2016-02-03 10:50:13 +00:00
|
|
|
GstVaapiDisplay *display;
|
|
|
|
VAStatus status;
|
2012-05-15 08:24:08 +00:00
|
|
|
|
2016-02-03 10:50:13 +00:00
|
|
|
g_return_val_if_fail (subpicture != NULL, FALSE);
|
2012-05-15 08:24:08 +00:00
|
|
|
|
2016-02-03 10:50:13 +00:00
|
|
|
if (!(subpicture->flags & GST_VAAPI_SUBPICTURE_FLAG_GLOBAL_ALPHA))
|
|
|
|
return FALSE;
|
2012-05-15 08:24:08 +00:00
|
|
|
|
2016-02-03 10:50:13 +00:00
|
|
|
if (subpicture->global_alpha == global_alpha)
|
|
|
|
return TRUE;
|
2012-05-15 08:24:08 +00:00
|
|
|
|
2016-02-03 10:50:13 +00:00
|
|
|
display = GST_VAAPI_OBJECT_DISPLAY (subpicture);
|
2012-05-15 08:24:08 +00:00
|
|
|
|
2016-02-03 10:50:13 +00:00
|
|
|
GST_VAAPI_DISPLAY_LOCK (display);
|
|
|
|
status = vaSetSubpictureGlobalAlpha (GST_VAAPI_DISPLAY_VADISPLAY (display),
|
|
|
|
GST_VAAPI_OBJECT_ID (subpicture), global_alpha);
|
|
|
|
GST_VAAPI_DISPLAY_UNLOCK (display);
|
|
|
|
if (!vaapi_check_status (status, "vaSetSubpictureGlobalAlpha()"))
|
|
|
|
return FALSE;
|
2012-05-15 08:24:08 +00:00
|
|
|
|
2016-02-03 10:50:13 +00:00
|
|
|
subpicture->global_alpha = global_alpha;
|
|
|
|
return TRUE;
|
2012-05-15 08:24:08 +00:00
|
|
|
}
|