2010-01-25 16:15:01 +00:00
|
|
|
/*
|
|
|
|
* gstvaapidisplay.c - VA display 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-01-25 16:15:01 +00:00
|
|
|
*
|
2010-05-03 07:07:27 +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-01-25 16:15:01 +00:00
|
|
|
*
|
2010-05-03 07:07:27 +00:00
|
|
|
* This library is distributed in the hope that it will be useful,
|
2010-01-25 16:15:01 +00:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2010-05-03 07:07:27 +00:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
2010-01-25 16:15:01 +00:00
|
|
|
*
|
2010-05-03 07:07:27 +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-01-25 16:15:01 +00:00
|
|
|
*/
|
|
|
|
|
2010-03-19 15:45:21 +00:00
|
|
|
/**
|
2010-03-24 08:16:32 +00:00
|
|
|
* SECTION:gstvaapidisplay
|
|
|
|
* @short_description: VA display abstraction
|
2010-03-19 15:45:21 +00:00
|
|
|
*/
|
|
|
|
|
2012-01-30 17:12:59 +00:00
|
|
|
#include "sysdeps.h"
|
2012-01-12 14:03:04 +00:00
|
|
|
#include <string.h>
|
2010-03-16 09:15:48 +00:00
|
|
|
#include "gstvaapiutils.h"
|
2012-08-28 08:55:59 +00:00
|
|
|
#include "gstvaapivalue.h"
|
2010-01-25 16:15:01 +00:00
|
|
|
#include "gstvaapidisplay.h"
|
2016-09-22 07:34:38 +00:00
|
|
|
#include "gstvaapitexturemap.h"
|
2010-04-01 09:47:59 +00:00
|
|
|
#include "gstvaapidisplay_priv.h"
|
2012-01-18 09:22:58 +00:00
|
|
|
#include "gstvaapiworkarounds.h"
|
2010-01-25 16:15:01 +00:00
|
|
|
|
2016-10-13 03:53:17 +00:00
|
|
|
/* Debug category for all vaapi libs */
|
2013-12-20 12:27:07 +00:00
|
|
|
GST_DEBUG_CATEGORY (gst_debug_vaapi);
|
2010-03-10 13:13:51 +00:00
|
|
|
|
2016-10-13 03:53:17 +00:00
|
|
|
/* Debug category for VaapiDisplay */
|
|
|
|
GST_DEBUG_CATEGORY (gst_debug_vaapi_display);
|
|
|
|
#define GST_CAT_DEFAULT gst_debug_vaapi_display
|
|
|
|
|
2017-09-22 13:12:05 +00:00
|
|
|
#define _do_init \
|
|
|
|
G_ADD_PRIVATE (GstVaapiDisplay); \
|
|
|
|
GST_DEBUG_CATEGORY_INIT (gst_debug_vaapi_display, \
|
|
|
|
"vaapidisplay", 0, "VA-API Display"); \
|
|
|
|
GST_DEBUG_CATEGORY_INIT (gst_debug_vaapi, "vaapi", 0, "VA-API helper");
|
2016-10-13 03:53:17 +00:00
|
|
|
|
|
|
|
G_DEFINE_TYPE_WITH_CODE (GstVaapiDisplay, gst_vaapi_display, GST_TYPE_OBJECT,
|
|
|
|
_do_init);
|
|
|
|
|
2013-05-07 09:39:34 +00:00
|
|
|
/* Ensure those symbols are actually defined in the resulting libraries */
|
|
|
|
#undef gst_vaapi_display_ref
|
|
|
|
#undef gst_vaapi_display_unref
|
|
|
|
#undef gst_vaapi_display_replace
|
2010-01-25 16:15:01 +00:00
|
|
|
|
2010-04-30 09:52:29 +00:00
|
|
|
typedef struct _GstVaapiConfig GstVaapiConfig;
|
2013-12-20 12:27:07 +00:00
|
|
|
struct _GstVaapiConfig
|
|
|
|
{
|
|
|
|
GstVaapiProfile profile;
|
|
|
|
GstVaapiEntrypoint entrypoint;
|
2010-04-30 09:52:29 +00:00
|
|
|
};
|
|
|
|
|
2012-08-27 14:02:49 +00:00
|
|
|
typedef struct _GstVaapiProperty GstVaapiProperty;
|
2013-12-20 12:27:07 +00:00
|
|
|
struct _GstVaapiProperty
|
|
|
|
{
|
|
|
|
const gchar *name;
|
|
|
|
VADisplayAttribute attribute;
|
|
|
|
gint old_value;
|
2012-08-27 14:02:49 +00:00
|
|
|
};
|
|
|
|
|
2013-01-03 17:02:49 +00:00
|
|
|
typedef struct _GstVaapiFormatInfo GstVaapiFormatInfo;
|
2013-12-20 12:27:07 +00:00
|
|
|
struct _GstVaapiFormatInfo
|
|
|
|
{
|
|
|
|
GstVideoFormat format;
|
|
|
|
guint flags;
|
2013-01-03 17:02:49 +00:00
|
|
|
};
|
|
|
|
|
2012-08-28 08:55:59 +00:00
|
|
|
#define DEFAULT_RENDER_MODE GST_VAAPI_RENDER_MODE_TEXTURE
|
|
|
|
#define DEFAULT_ROTATION GST_VAAPI_ROTATION_0
|
2012-08-27 17:00:37 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
enum
|
|
|
|
{
|
2017-09-22 13:16:34 +00:00
|
|
|
PROP_RENDER_MODE = 1,
|
2013-12-20 12:27:07 +00:00
|
|
|
PROP_ROTATION,
|
|
|
|
PROP_HUE,
|
|
|
|
PROP_SATURATION,
|
|
|
|
PROP_BRIGHTNESS,
|
|
|
|
PROP_CONTRAST,
|
2012-08-28 14:24:15 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
N_PROPERTIES
|
2010-01-25 16:15:01 +00:00
|
|
|
};
|
|
|
|
|
2012-08-28 14:24:15 +00:00
|
|
|
static GParamSpec *g_properties[N_PROPERTIES] = { NULL, };
|
|
|
|
|
2012-08-28 12:05:16 +00:00
|
|
|
static gboolean
|
2013-12-20 12:27:07 +00:00
|
|
|
get_attribute (GstVaapiDisplay * display, VADisplayAttribType type,
|
|
|
|
gint * value);
|
2012-08-28 12:05:16 +00:00
|
|
|
|
|
|
|
static gboolean
|
2013-12-20 12:27:07 +00:00
|
|
|
set_attribute (GstVaapiDisplay * display, VADisplayAttribType type, gint value);
|
2012-08-28 12:05:16 +00:00
|
|
|
|
2012-08-28 11:59:50 +00:00
|
|
|
static gboolean
|
2013-12-20 12:27:07 +00:00
|
|
|
get_color_balance (GstVaapiDisplay * display, guint prop_id, gfloat * v);
|
2012-08-28 11:59:50 +00:00
|
|
|
|
|
|
|
static gboolean
|
2013-12-20 12:27:07 +00:00
|
|
|
set_color_balance (GstVaapiDisplay * display, guint prop_id, gfloat v);
|
2012-08-28 11:59:50 +00:00
|
|
|
|
2012-07-25 07:16:02 +00:00
|
|
|
/* GstVaapiDisplayType enumerations */
|
|
|
|
GType
|
2013-12-20 12:27:07 +00:00
|
|
|
gst_vaapi_display_type_get_type (void)
|
2012-07-25 07:16:02 +00:00
|
|
|
{
|
2013-12-20 12:27:07 +00:00
|
|
|
static GType g_type = 0;
|
2012-07-25 07:16:02 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
static const GEnumValue display_types[] = {
|
|
|
|
{GST_VAAPI_DISPLAY_TYPE_ANY,
|
|
|
|
"Auto detection", "any"},
|
2012-07-24 13:07:48 +00:00
|
|
|
#if USE_X11
|
2013-12-20 12:27:07 +00:00
|
|
|
{GST_VAAPI_DISPLAY_TYPE_X11,
|
|
|
|
"VA/X11 display", "x11"},
|
2012-07-24 13:07:48 +00:00
|
|
|
#endif
|
2012-07-25 07:16:02 +00:00
|
|
|
#if USE_GLX
|
2013-12-20 12:27:07 +00:00
|
|
|
{GST_VAAPI_DISPLAY_TYPE_GLX,
|
|
|
|
"VA/GLX display", "glx"},
|
2012-07-24 07:45:25 +00:00
|
|
|
#endif
|
2015-02-20 14:27:53 +00:00
|
|
|
#if USE_EGL
|
|
|
|
{GST_VAAPI_DISPLAY_TYPE_EGL,
|
|
|
|
"VA/EGL display", "egl"},
|
|
|
|
#endif
|
2012-07-24 07:45:25 +00:00
|
|
|
#if USE_WAYLAND
|
2013-12-20 12:27:07 +00:00
|
|
|
{GST_VAAPI_DISPLAY_TYPE_WAYLAND,
|
|
|
|
"VA/Wayland display", "wayland"},
|
2012-08-01 13:44:02 +00:00
|
|
|
#endif
|
|
|
|
#if USE_DRM
|
2013-12-20 12:27:07 +00:00
|
|
|
{GST_VAAPI_DISPLAY_TYPE_DRM,
|
|
|
|
"VA/DRM display", "drm"},
|
2012-07-25 07:16:02 +00:00
|
|
|
#endif
|
2013-12-20 12:27:07 +00:00
|
|
|
{0, NULL, NULL},
|
|
|
|
};
|
2012-07-25 07:16:02 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
if (!g_type)
|
|
|
|
g_type = g_enum_register_static ("GstVaapiDisplayType", display_types);
|
|
|
|
return g_type;
|
2012-07-25 07:16:02 +00:00
|
|
|
}
|
|
|
|
|
2013-12-13 11:00:35 +00:00
|
|
|
/**
|
|
|
|
* gst_vaapi_display_type_is_compatible:
|
|
|
|
* @type1: the #GstVaapiDisplayType to test
|
|
|
|
* @type2: the reference #GstVaapiDisplayType
|
|
|
|
*
|
|
|
|
* Compares whether #GstVaapiDisplay @type1 is compatible with @type2.
|
|
|
|
* That is, if @type2 is in "any" category, or derived from @type1.
|
|
|
|
*
|
|
|
|
* Returns: %TRUE if @type1 is compatible with @type2, %FALSE otherwise.
|
|
|
|
*/
|
|
|
|
gboolean
|
2013-12-20 12:27:07 +00:00
|
|
|
gst_vaapi_display_type_is_compatible (GstVaapiDisplayType type1,
|
2013-12-13 11:00:35 +00:00
|
|
|
GstVaapiDisplayType type2)
|
|
|
|
{
|
2013-12-20 12:27:07 +00:00
|
|
|
if (type1 == type2)
|
|
|
|
return TRUE;
|
2013-12-13 11:00:35 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
switch (type1) {
|
2013-12-13 11:00:35 +00:00
|
|
|
case GST_VAAPI_DISPLAY_TYPE_GLX:
|
2013-12-20 12:27:07 +00:00
|
|
|
if (type2 == GST_VAAPI_DISPLAY_TYPE_X11)
|
|
|
|
return TRUE;
|
|
|
|
break;
|
2013-12-13 11:00:35 +00:00
|
|
|
default:
|
2013-12-20 12:27:07 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
return type2 == GST_VAAPI_DISPLAY_TYPE_ANY;
|
2013-12-13 11:00:35 +00:00
|
|
|
}
|
|
|
|
|
2013-07-09 12:03:01 +00:00
|
|
|
/* Append GstVideoFormat to formats array */
|
2010-03-19 10:42:11 +00:00
|
|
|
static inline void
|
2013-12-20 12:27:07 +00:00
|
|
|
append_format (GArray * formats, GstVideoFormat format, guint flags)
|
2010-03-19 10:42:11 +00:00
|
|
|
{
|
2013-12-20 12:27:07 +00:00
|
|
|
GstVaapiFormatInfo fi;
|
2013-01-03 17:02:49 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
fi.format = format;
|
|
|
|
fi.flags = flags;
|
|
|
|
g_array_append_val (formats, fi);
|
2010-03-19 10:42:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Append VAImageFormats to formats array */
|
2010-03-11 12:11:36 +00:00
|
|
|
static void
|
2013-12-20 12:27:07 +00:00
|
|
|
append_formats (GArray * formats, const VAImageFormat * va_formats,
|
|
|
|
guint * flags, guint n)
|
|
|
|
{
|
|
|
|
GstVideoFormat format;
|
2017-07-27 10:54:00 +00:00
|
|
|
int YV12_idx = -1;
|
|
|
|
int I420_idx = -1;
|
|
|
|
const GstVaapiFormatInfo *fip;
|
2013-12-20 12:27:07 +00:00
|
|
|
guint i;
|
|
|
|
|
|
|
|
for (i = 0; i < n; i++) {
|
|
|
|
const VAImageFormat *const va_format = &va_formats[i];
|
|
|
|
|
|
|
|
format = gst_vaapi_video_format_from_va_format (va_format);
|
|
|
|
if (format == GST_VIDEO_FORMAT_UNKNOWN) {
|
|
|
|
GST_DEBUG ("unsupported format %" GST_FOURCC_FORMAT,
|
|
|
|
GST_FOURCC_ARGS (va_format->fourcc));
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
append_format (formats, format, flags ? flags[i] : 0);
|
|
|
|
|
|
|
|
switch (format) {
|
|
|
|
case GST_VIDEO_FORMAT_YV12:
|
2017-07-27 10:54:00 +00:00
|
|
|
YV12_idx = formats->len - 1;
|
2013-12-20 12:27:07 +00:00
|
|
|
break;
|
|
|
|
case GST_VIDEO_FORMAT_I420:
|
2017-07-27 10:54:00 +00:00
|
|
|
I420_idx = formats->len - 1;
|
2013-12-20 12:27:07 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2010-03-11 12:11:36 +00:00
|
|
|
}
|
2013-12-20 12:27:07 +00:00
|
|
|
}
|
2010-03-16 08:43:16 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
/* Append I420 (resp. YV12) format if YV12 (resp. I420) is not
|
|
|
|
supported by the underlying driver */
|
2017-07-27 10:54:00 +00:00
|
|
|
if ((YV12_idx != -1) && (I420_idx == -1)) {
|
|
|
|
fip = &g_array_index (formats, GstVaapiFormatInfo, YV12_idx);
|
|
|
|
append_format (formats, GST_VIDEO_FORMAT_I420, fip->flags);
|
|
|
|
} else if ((I420_idx != -1) && (YV12_idx == -1)) {
|
|
|
|
fip = &g_array_index (formats, GstVaapiFormatInfo, I420_idx);
|
|
|
|
append_format (formats, GST_VIDEO_FORMAT_YV12, fip->flags);
|
|
|
|
}
|
2010-03-11 12:11:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Sort image formats. Prefer YUV formats first */
|
2010-03-19 10:38:45 +00:00
|
|
|
static gint
|
2013-12-20 12:27:07 +00:00
|
|
|
compare_yuv_formats (gconstpointer a, gconstpointer b)
|
2010-03-11 12:11:36 +00:00
|
|
|
{
|
2013-12-20 12:27:07 +00:00
|
|
|
const GstVideoFormat fmt1 = ((GstVaapiFormatInfo *) a)->format;
|
|
|
|
const GstVideoFormat fmt2 = ((GstVaapiFormatInfo *) b)->format;
|
2010-03-11 12:11:36 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
const gboolean is_fmt1_yuv = gst_vaapi_video_format_is_yuv (fmt1);
|
|
|
|
const gboolean is_fmt2_yuv = gst_vaapi_video_format_is_yuv (fmt2);
|
2010-03-11 12:11:36 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
if (is_fmt1_yuv != is_fmt2_yuv)
|
|
|
|
return is_fmt1_yuv ? -1 : 1;
|
2010-03-11 12:11:36 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
return ((gint) gst_vaapi_video_format_get_score (fmt1) -
|
|
|
|
(gint) gst_vaapi_video_format_get_score (fmt2));
|
2010-03-11 12:11:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Sort subpicture formats. Prefer RGB formats first */
|
2010-03-19 10:38:45 +00:00
|
|
|
static gint
|
2013-12-20 12:27:07 +00:00
|
|
|
compare_rgb_formats (gconstpointer a, gconstpointer b)
|
2010-03-11 12:11:36 +00:00
|
|
|
{
|
2013-12-20 12:27:07 +00:00
|
|
|
const GstVideoFormat fmt1 = ((GstVaapiFormatInfo *) a)->format;
|
|
|
|
const GstVideoFormat fmt2 = ((GstVaapiFormatInfo *) b)->format;
|
2010-03-11 12:11:36 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
const gboolean is_fmt1_rgb = gst_vaapi_video_format_is_rgb (fmt1);
|
|
|
|
const gboolean is_fmt2_rgb = gst_vaapi_video_format_is_rgb (fmt2);
|
2010-03-11 12:11:36 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
if (is_fmt1_rgb != is_fmt2_rgb)
|
|
|
|
return is_fmt1_rgb ? -1 : 1;
|
2010-03-11 12:11:36 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
return ((gint) gst_vaapi_video_format_get_score (fmt1) -
|
|
|
|
(gint) gst_vaapi_video_format_get_score (fmt2));
|
2010-03-19 10:38:45 +00:00
|
|
|
}
|
|
|
|
|
2010-04-30 09:52:29 +00:00
|
|
|
/* Check if configs array contains profile at entrypoint */
|
2010-03-19 10:38:45 +00:00
|
|
|
static inline gboolean
|
2013-12-20 12:27:07 +00:00
|
|
|
find_config (GArray * configs,
|
|
|
|
GstVaapiProfile profile, GstVaapiEntrypoint entrypoint)
|
2010-03-19 10:38:45 +00:00
|
|
|
{
|
2013-12-20 12:27:07 +00:00
|
|
|
GstVaapiConfig *config;
|
|
|
|
guint i;
|
2011-10-13 21:07:35 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
if (!configs)
|
2010-03-19 10:38:45 +00:00
|
|
|
return FALSE;
|
2013-12-20 12:27:07 +00:00
|
|
|
|
|
|
|
for (i = 0; i < configs->len; i++) {
|
|
|
|
config = &g_array_index (configs, GstVaapiConfig, i);
|
|
|
|
if (config->profile == profile && config->entrypoint == entrypoint)
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
2010-03-19 10:38:45 +00:00
|
|
|
}
|
|
|
|
|
2012-01-18 09:22:58 +00:00
|
|
|
/* HACK: append H.263 Baseline profile if MPEG-4:2 Simple profile is supported */
|
|
|
|
static void
|
2013-12-20 12:27:07 +00:00
|
|
|
append_h263_config (GArray * configs)
|
2012-01-18 09:22:58 +00:00
|
|
|
{
|
2013-12-20 12:27:07 +00:00
|
|
|
GstVaapiConfig *config, tmp_config;
|
|
|
|
GstVaapiConfig *mpeg4_simple_config = NULL;
|
|
|
|
GstVaapiConfig *h263_baseline_config = NULL;
|
|
|
|
guint i;
|
2012-01-18 09:22:58 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
if (!WORKAROUND_H263_BASELINE_DECODE_PROFILE)
|
|
|
|
return;
|
2012-01-18 09:22:58 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
if (!configs)
|
|
|
|
return;
|
2012-01-18 09:22:58 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
for (i = 0; i < configs->len; i++) {
|
|
|
|
config = &g_array_index (configs, GstVaapiConfig, i);
|
|
|
|
if (config->profile == GST_VAAPI_PROFILE_MPEG4_SIMPLE)
|
|
|
|
mpeg4_simple_config = config;
|
|
|
|
else if (config->profile == GST_VAAPI_PROFILE_H263_BASELINE)
|
|
|
|
h263_baseline_config = config;
|
|
|
|
}
|
2012-01-18 09:22:58 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
if (mpeg4_simple_config && !h263_baseline_config) {
|
|
|
|
tmp_config = *mpeg4_simple_config;
|
|
|
|
tmp_config.profile = GST_VAAPI_PROFILE_H263_BASELINE;
|
|
|
|
g_array_append_val (configs, tmp_config);
|
|
|
|
}
|
2012-01-18 09:22:58 +00:00
|
|
|
}
|
|
|
|
|
2013-12-20 14:31:14 +00:00
|
|
|
/* Sort profiles. Group per codec */
|
|
|
|
static gint
|
|
|
|
compare_profiles (gconstpointer a, gconstpointer b)
|
|
|
|
{
|
|
|
|
const GstVaapiConfig *const config1 = (GstVaapiConfig *) a;
|
|
|
|
const GstVaapiConfig *const config2 = (GstVaapiConfig *) b;
|
|
|
|
|
|
|
|
if (config1->profile == config2->profile)
|
|
|
|
return config1->entrypoint - config2->entrypoint;
|
|
|
|
|
|
|
|
return config1->profile - config2->profile;
|
|
|
|
}
|
|
|
|
|
2010-04-30 09:52:29 +00:00
|
|
|
/* Convert configs array to profiles as GstCaps */
|
2013-12-20 14:31:14 +00:00
|
|
|
static GArray *
|
|
|
|
get_profiles (GArray * configs)
|
2010-04-20 13:36:04 +00:00
|
|
|
{
|
2013-12-20 12:27:07 +00:00
|
|
|
GstVaapiConfig *config;
|
2013-12-20 14:31:14 +00:00
|
|
|
GArray *out_profiles;
|
2013-12-20 12:27:07 +00:00
|
|
|
guint i;
|
2010-04-20 13:36:04 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
if (!configs)
|
|
|
|
return NULL;
|
2011-10-13 21:07:35 +00:00
|
|
|
|
2013-12-20 14:31:14 +00:00
|
|
|
out_profiles = g_array_new (FALSE, FALSE, sizeof (GstVaapiProfile));
|
|
|
|
if (!out_profiles)
|
2013-12-20 12:27:07 +00:00
|
|
|
return NULL;
|
2010-04-20 13:36:04 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
for (i = 0; i < configs->len; i++) {
|
|
|
|
config = &g_array_index (configs, GstVaapiConfig, i);
|
2013-12-20 14:31:14 +00:00
|
|
|
g_array_append_val (out_profiles, config->profile);
|
2013-12-20 12:27:07 +00:00
|
|
|
}
|
2013-12-20 14:31:14 +00:00
|
|
|
return out_profiles;
|
2010-04-20 13:36:04 +00:00
|
|
|
}
|
|
|
|
|
2013-01-03 17:02:49 +00:00
|
|
|
/* Find format info */
|
|
|
|
static const GstVaapiFormatInfo *
|
2013-12-20 12:27:07 +00:00
|
|
|
find_format_info (GArray * formats, GstVideoFormat format)
|
2013-01-03 17:02:49 +00:00
|
|
|
{
|
2013-12-20 12:27:07 +00:00
|
|
|
const GstVaapiFormatInfo *fip;
|
|
|
|
guint i;
|
2013-01-03 17:02:49 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
for (i = 0; i < formats->len; i++) {
|
|
|
|
fip = &g_array_index (formats, GstVaapiFormatInfo, i);
|
|
|
|
if (fip->format == format)
|
|
|
|
return fip;
|
|
|
|
}
|
|
|
|
return NULL;
|
2013-01-03 17:02:49 +00:00
|
|
|
}
|
|
|
|
|
2010-03-19 10:38:45 +00:00
|
|
|
/* Check if formats array contains format */
|
|
|
|
static inline gboolean
|
2013-12-20 12:27:07 +00:00
|
|
|
find_format (GArray * formats, GstVideoFormat format)
|
2010-03-19 10:38:45 +00:00
|
|
|
{
|
2013-12-20 12:27:07 +00:00
|
|
|
return find_format_info (formats, format) != NULL;
|
2010-03-19 10:38:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Convert formats array to GstCaps */
|
2013-12-20 14:15:05 +00:00
|
|
|
static GArray *
|
|
|
|
get_formats (GArray * formats)
|
2010-03-19 10:38:45 +00:00
|
|
|
{
|
2013-12-20 12:27:07 +00:00
|
|
|
const GstVaapiFormatInfo *fip;
|
2013-12-20 14:15:05 +00:00
|
|
|
GArray *out_formats;
|
2013-12-20 12:27:07 +00:00
|
|
|
guint i;
|
2010-03-19 10:38:45 +00:00
|
|
|
|
2013-12-20 14:15:05 +00:00
|
|
|
out_formats = g_array_new (FALSE, FALSE, sizeof (GstVideoFormat));
|
|
|
|
if (!out_formats)
|
2013-12-20 12:27:07 +00:00
|
|
|
return NULL;
|
2010-03-19 10:38:45 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
for (i = 0; i < formats->len; i++) {
|
|
|
|
fip = &g_array_index (formats, GstVaapiFormatInfo, i);
|
2013-12-20 14:15:05 +00:00
|
|
|
g_array_append_val (out_formats, fip->format);
|
2013-12-20 12:27:07 +00:00
|
|
|
}
|
2013-12-20 14:15:05 +00:00
|
|
|
return out_formats;
|
2010-03-11 12:11:36 +00:00
|
|
|
}
|
|
|
|
|
2012-08-27 14:02:49 +00:00
|
|
|
/* Find display attribute */
|
|
|
|
static const GstVaapiProperty *
|
2013-12-20 12:27:07 +00:00
|
|
|
find_property (GArray * properties, const gchar * name)
|
2012-08-27 14:02:49 +00:00
|
|
|
{
|
2013-12-20 12:27:07 +00:00
|
|
|
GstVaapiProperty *prop;
|
|
|
|
guint i;
|
2012-08-27 14:02:49 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
if (!name)
|
2012-08-27 14:02:49 +00:00
|
|
|
return NULL;
|
2013-12-20 12:27:07 +00:00
|
|
|
|
|
|
|
for (i = 0; i < properties->len; i++) {
|
|
|
|
prop = &g_array_index (properties, GstVaapiProperty, i);
|
|
|
|
if (strcmp (prop->name, name) == 0)
|
|
|
|
return prop;
|
|
|
|
}
|
|
|
|
return NULL;
|
2012-08-27 14:02:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
static const GstVaapiProperty *
|
2013-12-20 12:27:07 +00:00
|
|
|
find_property_by_type (GArray * properties, VADisplayAttribType type)
|
2012-08-27 14:02:49 +00:00
|
|
|
{
|
2013-12-20 12:27:07 +00:00
|
|
|
GstVaapiProperty *prop;
|
|
|
|
guint i;
|
2012-08-27 14:02:49 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
for (i = 0; i < properties->len; i++) {
|
|
|
|
prop = &g_array_index (properties, GstVaapiProperty, i);
|
|
|
|
if (prop->attribute.type == type)
|
|
|
|
return prop;
|
|
|
|
}
|
|
|
|
return NULL;
|
2012-08-27 14:02:49 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-08-28 11:59:50 +00:00
|
|
|
static inline const GstVaapiProperty *
|
2013-12-20 12:27:07 +00:00
|
|
|
find_property_by_pspec (GstVaapiDisplay * display, GParamSpec * pspec)
|
2012-08-28 11:59:50 +00:00
|
|
|
{
|
2013-12-20 12:27:07 +00:00
|
|
|
GstVaapiDisplayPrivate *const priv = GST_VAAPI_DISPLAY_GET_PRIVATE (display);
|
2013-05-07 09:39:34 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
return find_property (priv->properties, pspec->name);
|
2013-05-07 09:39:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static guint
|
2013-12-20 12:27:07 +00:00
|
|
|
find_property_id (const gchar * name)
|
|
|
|
{
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
const gchar *name;
|
|
|
|
guint id;
|
|
|
|
} property_map;
|
|
|
|
|
|
|
|
static const property_map g_property_map[] = {
|
|
|
|
{GST_VAAPI_DISPLAY_PROP_RENDER_MODE, PROP_RENDER_MODE},
|
|
|
|
{GST_VAAPI_DISPLAY_PROP_ROTATION, PROP_ROTATION},
|
|
|
|
{GST_VAAPI_DISPLAY_PROP_HUE, PROP_HUE},
|
|
|
|
{GST_VAAPI_DISPLAY_PROP_SATURATION, PROP_SATURATION},
|
|
|
|
{GST_VAAPI_DISPLAY_PROP_BRIGHTNESS, PROP_BRIGHTNESS},
|
|
|
|
{GST_VAAPI_DISPLAY_PROP_CONTRAST, PROP_CONTRAST},
|
|
|
|
{NULL,}
|
|
|
|
};
|
|
|
|
|
|
|
|
const property_map *m;
|
|
|
|
for (m = g_property_map; m->name != NULL; m++) {
|
|
|
|
if (strcmp (m->name, name) == 0)
|
|
|
|
return m->id;
|
|
|
|
}
|
|
|
|
return 0;
|
2012-08-28 11:59:50 +00:00
|
|
|
}
|
|
|
|
|
2013-12-20 13:01:45 +00:00
|
|
|
/* Initialize VA profiles (decoders, encoders) */
|
|
|
|
static gboolean
|
|
|
|
ensure_profiles (GstVaapiDisplay * display)
|
|
|
|
{
|
|
|
|
GstVaapiDisplayPrivate *const priv = GST_VAAPI_DISPLAY_GET_PRIVATE (display);
|
|
|
|
VAProfile *profiles = NULL;
|
|
|
|
VAEntrypoint *entrypoints = NULL;
|
|
|
|
gint i, j, n, num_entrypoints;
|
|
|
|
VAStatus status;
|
|
|
|
gboolean success = FALSE;
|
|
|
|
|
|
|
|
if (priv->has_profiles)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
priv->decoders = g_array_new (FALSE, FALSE, sizeof (GstVaapiConfig));
|
|
|
|
if (!priv->decoders)
|
|
|
|
goto cleanup;
|
|
|
|
priv->encoders = g_array_new (FALSE, FALSE, sizeof (GstVaapiConfig));
|
|
|
|
if (!priv->encoders)
|
|
|
|
goto cleanup;
|
|
|
|
priv->has_profiles = TRUE;
|
|
|
|
|
|
|
|
/* VA profiles */
|
|
|
|
profiles = g_new (VAProfile, vaMaxNumProfiles (priv->display));
|
|
|
|
if (!profiles)
|
|
|
|
goto cleanup;
|
|
|
|
entrypoints = g_new (VAEntrypoint, vaMaxNumEntrypoints (priv->display));
|
|
|
|
if (!entrypoints)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
n = 0;
|
|
|
|
status = vaQueryConfigProfiles (priv->display, profiles, &n);
|
|
|
|
if (!vaapi_check_status (status, "vaQueryConfigProfiles()"))
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
GST_DEBUG ("%d profiles", n);
|
|
|
|
for (i = 0; i < n; i++) {
|
|
|
|
#if VA_CHECK_VERSION(0,34,0)
|
|
|
|
/* Introduced in VA/VPP API */
|
|
|
|
if (profiles[i] == VAProfileNone)
|
|
|
|
continue;
|
|
|
|
#endif
|
|
|
|
GST_DEBUG (" %s", string_of_VAProfile (profiles[i]));
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < n; i++) {
|
|
|
|
GstVaapiConfig config;
|
|
|
|
|
|
|
|
config.profile = gst_vaapi_profile (profiles[i]);
|
|
|
|
if (!config.profile)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
status = vaQueryConfigEntrypoints (priv->display,
|
|
|
|
profiles[i], entrypoints, &num_entrypoints);
|
|
|
|
if (!vaapi_check_status (status, "vaQueryConfigEntrypoints()"))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
for (j = 0; j < num_entrypoints; j++) {
|
|
|
|
config.entrypoint = gst_vaapi_entrypoint (entrypoints[j]);
|
|
|
|
switch (config.entrypoint) {
|
|
|
|
case GST_VAAPI_ENTRYPOINT_VLD:
|
|
|
|
case GST_VAAPI_ENTRYPOINT_IDCT:
|
|
|
|
case GST_VAAPI_ENTRYPOINT_MOCO:
|
|
|
|
g_array_append_val (priv->decoders, config);
|
|
|
|
break;
|
|
|
|
case GST_VAAPI_ENTRYPOINT_SLICE_ENCODE:
|
2015-02-04 09:15:00 +00:00
|
|
|
case GST_VAAPI_ENTRYPOINT_PICTURE_ENCODE:
|
2016-05-11 09:03:08 +00:00
|
|
|
case GST_VAAPI_ENTRYPOINT_SLICE_ENCODE_LP:
|
2017-08-09 20:02:24 +00:00
|
|
|
case GST_VAAPI_ENTRYPOINT_SLICE_ENCODE_FEI:
|
2013-12-20 13:01:45 +00:00
|
|
|
g_array_append_val (priv->encoders, config);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
append_h263_config (priv->decoders);
|
|
|
|
|
2013-12-20 14:31:14 +00:00
|
|
|
g_array_sort (priv->decoders, compare_profiles);
|
|
|
|
g_array_sort (priv->encoders, compare_profiles);
|
|
|
|
|
2013-12-20 13:01:45 +00:00
|
|
|
/* Video processing API */
|
|
|
|
#if USE_VA_VPP
|
|
|
|
status = vaQueryConfigEntrypoints (priv->display, VAProfileNone,
|
|
|
|
entrypoints, &num_entrypoints);
|
|
|
|
if (vaapi_check_status (status, "vaQueryEntrypoints() [VAProfileNone]")) {
|
|
|
|
for (j = 0; j < num_entrypoints; j++) {
|
|
|
|
if (entrypoints[j] == VAEntrypointVideoProc)
|
|
|
|
priv->has_vpp = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
success = TRUE;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
g_free (profiles);
|
|
|
|
g_free (entrypoints);
|
|
|
|
return success;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Initialize VA display attributes */
|
|
|
|
static gboolean
|
|
|
|
ensure_properties (GstVaapiDisplay * display)
|
|
|
|
{
|
|
|
|
GstVaapiDisplayPrivate *const priv = GST_VAAPI_DISPLAY_GET_PRIVATE (display);
|
|
|
|
VADisplayAttribute *display_attrs = NULL;
|
|
|
|
VAStatus status;
|
|
|
|
gint i, n;
|
|
|
|
gboolean success = FALSE;
|
|
|
|
|
|
|
|
if (priv->properties)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
priv->properties = g_array_new (FALSE, FALSE, sizeof (GstVaapiProperty));
|
|
|
|
if (!priv->properties)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
/* VA display attributes */
|
|
|
|
display_attrs =
|
|
|
|
g_new (VADisplayAttribute, vaMaxNumDisplayAttributes (priv->display));
|
|
|
|
if (!display_attrs)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
n = 0;
|
|
|
|
status = vaQueryDisplayAttributes (priv->display, display_attrs, &n);
|
|
|
|
if (!vaapi_check_status (status, "vaQueryDisplayAttributes()"))
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
GST_DEBUG ("%d display attributes", n);
|
|
|
|
for (i = 0; i < n; i++) {
|
|
|
|
VADisplayAttribute *const attr = &display_attrs[i];
|
|
|
|
GstVaapiProperty prop;
|
|
|
|
gint value;
|
|
|
|
|
|
|
|
GST_DEBUG (" %s", string_of_VADisplayAttributeType (attr->type));
|
|
|
|
|
|
|
|
switch (attr->type) {
|
|
|
|
#if !VA_CHECK_VERSION(0,34,0)
|
|
|
|
case VADisplayAttribDirectSurface:
|
|
|
|
prop.name = GST_VAAPI_DISPLAY_PROP_RENDER_MODE;
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
case VADisplayAttribRenderMode:
|
|
|
|
prop.name = GST_VAAPI_DISPLAY_PROP_RENDER_MODE;
|
|
|
|
break;
|
|
|
|
case VADisplayAttribRotation:
|
|
|
|
prop.name = GST_VAAPI_DISPLAY_PROP_ROTATION;
|
|
|
|
break;
|
|
|
|
case VADisplayAttribHue:
|
|
|
|
prop.name = GST_VAAPI_DISPLAY_PROP_HUE;
|
|
|
|
break;
|
|
|
|
case VADisplayAttribSaturation:
|
|
|
|
prop.name = GST_VAAPI_DISPLAY_PROP_SATURATION;
|
|
|
|
break;
|
|
|
|
case VADisplayAttribBrightness:
|
|
|
|
prop.name = GST_VAAPI_DISPLAY_PROP_BRIGHTNESS;
|
|
|
|
break;
|
|
|
|
case VADisplayAttribContrast:
|
|
|
|
prop.name = GST_VAAPI_DISPLAY_PROP_CONTRAST;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
prop.name = NULL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (!prop.name)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/* Assume the attribute is really supported if we can get the
|
|
|
|
* actual and current value */
|
|
|
|
if (!get_attribute (display, attr->type, &value))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/* Some drivers (e.g. EMGD) have completely random initial
|
|
|
|
* values */
|
|
|
|
if (value < attr->min_value || value > attr->max_value)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
prop.attribute = *attr;
|
|
|
|
prop.old_value = value;
|
|
|
|
g_array_append_val (priv->properties, prop);
|
|
|
|
}
|
|
|
|
success = TRUE;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
g_free (display_attrs);
|
|
|
|
return success;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Initialize VA image formats */
|
|
|
|
static gboolean
|
|
|
|
ensure_image_formats (GstVaapiDisplay * display)
|
|
|
|
{
|
|
|
|
GstVaapiDisplayPrivate *const priv = GST_VAAPI_DISPLAY_GET_PRIVATE (display);
|
|
|
|
VAImageFormat *formats = NULL;
|
|
|
|
VAStatus status;
|
|
|
|
gint i, n;
|
|
|
|
gboolean success = FALSE;
|
|
|
|
|
|
|
|
if (priv->image_formats)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
priv->image_formats = g_array_new (FALSE, FALSE, sizeof (GstVaapiFormatInfo));
|
|
|
|
if (!priv->image_formats)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
/* VA image formats */
|
|
|
|
formats = g_new (VAImageFormat, vaMaxNumImageFormats (priv->display));
|
|
|
|
if (!formats)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
n = 0;
|
|
|
|
status = vaQueryImageFormats (priv->display, formats, &n);
|
|
|
|
if (!vaapi_check_status (status, "vaQueryImageFormats()"))
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
GST_DEBUG ("%d image formats", n);
|
|
|
|
for (i = 0; i < n; i++)
|
|
|
|
GST_DEBUG (" %" GST_FOURCC_FORMAT, GST_FOURCC_ARGS (formats[i].fourcc));
|
|
|
|
|
|
|
|
append_formats (priv->image_formats, formats, NULL, n);
|
|
|
|
g_array_sort (priv->image_formats, compare_yuv_formats);
|
|
|
|
success = TRUE;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
g_free (formats);
|
|
|
|
return success;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Initialize VA subpicture formats */
|
|
|
|
static gboolean
|
|
|
|
ensure_subpicture_formats (GstVaapiDisplay * display)
|
|
|
|
{
|
|
|
|
GstVaapiDisplayPrivate *const priv = GST_VAAPI_DISPLAY_GET_PRIVATE (display);
|
|
|
|
VAImageFormat *formats = NULL;
|
|
|
|
unsigned int *flags = NULL;
|
|
|
|
VAStatus status;
|
|
|
|
guint i, n;
|
|
|
|
gboolean success = FALSE;
|
|
|
|
|
|
|
|
if (priv->subpicture_formats)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
priv->subpicture_formats =
|
|
|
|
g_array_new (FALSE, FALSE, sizeof (GstVaapiFormatInfo));
|
|
|
|
if (!priv->subpicture_formats)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
/* VA subpicture formats */
|
|
|
|
n = vaMaxNumSubpictureFormats (priv->display);
|
|
|
|
formats = g_new (VAImageFormat, n);
|
|
|
|
if (!formats)
|
|
|
|
goto cleanup;
|
|
|
|
flags = g_new (guint, n);
|
|
|
|
if (!flags)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
n = 0;
|
|
|
|
status = vaQuerySubpictureFormats (priv->display, formats, flags, &n);
|
|
|
|
if (!vaapi_check_status (status, "vaQuerySubpictureFormats()"))
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
GST_DEBUG ("%d subpicture formats", n);
|
|
|
|
for (i = 0; i < n; i++) {
|
|
|
|
GST_DEBUG (" %" GST_FOURCC_FORMAT, GST_FOURCC_ARGS (formats[i].fourcc));
|
|
|
|
flags[i] = to_GstVaapiSubpictureFlags (flags[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
append_formats (priv->subpicture_formats, formats, flags, n);
|
|
|
|
g_array_sort (priv->subpicture_formats, compare_rgb_formats);
|
|
|
|
success = TRUE;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
g_free (formats);
|
|
|
|
g_free (flags);
|
|
|
|
return success;
|
|
|
|
}
|
|
|
|
|
2010-03-22 09:32:01 +00:00
|
|
|
static void
|
2013-12-20 12:27:07 +00:00
|
|
|
gst_vaapi_display_calculate_pixel_aspect_ratio (GstVaapiDisplay * display)
|
|
|
|
{
|
|
|
|
GstVaapiDisplayPrivate *const priv = GST_VAAPI_DISPLAY_GET_PRIVATE (display);
|
|
|
|
gdouble ratio, delta;
|
|
|
|
gint i, j, index, windex;
|
|
|
|
|
|
|
|
static const gint par[][2] = {
|
|
|
|
{1, 1}, /* regular screen */
|
|
|
|
{16, 15}, /* PAL TV */
|
|
|
|
{11, 10}, /* 525 line Rec.601 video */
|
|
|
|
{54, 59}, /* 625 line Rec.601 video */
|
|
|
|
{64, 45}, /* 1280x1024 on 16:9 display */
|
|
|
|
{5, 3}, /* 1280x1024 on 4:3 display */
|
|
|
|
{4, 3} /* 800x600 on 16:9 display */
|
|
|
|
};
|
|
|
|
|
|
|
|
/* First, calculate the "real" ratio based on the X values;
|
|
|
|
* which is the "physical" w/h divided by the w/h in pixels of the
|
|
|
|
* display */
|
|
|
|
if (!priv->width || !priv->height || !priv->width_mm || !priv->height_mm)
|
|
|
|
ratio = 1.0;
|
|
|
|
else
|
|
|
|
ratio = (gdouble) (priv->width_mm * priv->height) /
|
|
|
|
(priv->height_mm * priv->width);
|
|
|
|
GST_DEBUG ("calculated pixel aspect ratio: %f", ratio);
|
|
|
|
|
|
|
|
/* Now, find the one from par[][2] with the lowest delta to the real one */
|
2012-09-06 09:51:41 +00:00
|
|
|
#define DELTA(idx, w) (ABS(ratio - ((gdouble)par[idx][w] / par[idx][!(w)])))
|
2013-12-20 12:27:07 +00:00
|
|
|
delta = DELTA (0, 0);
|
|
|
|
index = 0;
|
|
|
|
windex = 0;
|
|
|
|
|
|
|
|
for (i = 1; i < G_N_ELEMENTS (par); i++) {
|
|
|
|
for (j = 0; j < 2; j++) {
|
|
|
|
const gdouble this_delta = DELTA (i, j);
|
|
|
|
if (this_delta < delta) {
|
|
|
|
index = i;
|
|
|
|
windex = j;
|
|
|
|
delta = this_delta;
|
|
|
|
}
|
2010-03-22 09:32:01 +00:00
|
|
|
}
|
2013-12-20 12:27:07 +00:00
|
|
|
}
|
2010-03-22 09:32:01 +00:00
|
|
|
#undef DELTA
|
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
priv->par_n = par[index][windex];
|
|
|
|
priv->par_d = par[index][windex ^ 1];
|
2010-03-22 09:32:01 +00:00
|
|
|
}
|
|
|
|
|
2017-09-29 13:07:47 +00:00
|
|
|
static void
|
|
|
|
gst_vaapi_display_ensure_screen_resolution (GstVaapiDisplay * display)
|
|
|
|
{
|
|
|
|
GstVaapiDisplayPrivate *const priv = GST_VAAPI_DISPLAY_GET_PRIVATE (display);
|
|
|
|
const GstVaapiDisplayClass *const klass =
|
|
|
|
GST_VAAPI_DISPLAY_GET_CLASS (display);
|
|
|
|
|
|
|
|
if (priv->got_scrres)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (klass->get_size)
|
|
|
|
klass->get_size (display, &priv->width, &priv->height);
|
|
|
|
if (klass->get_size_mm)
|
|
|
|
klass->get_size_mm (display, &priv->width_mm, &priv->height_mm);
|
|
|
|
|
|
|
|
gst_vaapi_display_calculate_pixel_aspect_ratio (display);
|
|
|
|
priv->got_scrres = TRUE;
|
|
|
|
}
|
|
|
|
|
2010-03-10 12:25:19 +00:00
|
|
|
static void
|
2013-12-20 12:27:07 +00:00
|
|
|
gst_vaapi_display_destroy (GstVaapiDisplay * display)
|
2010-03-10 12:25:19 +00:00
|
|
|
{
|
2013-12-20 12:27:07 +00:00
|
|
|
GstVaapiDisplayPrivate *const priv = GST_VAAPI_DISPLAY_GET_PRIVATE (display);
|
2010-03-10 12:25:19 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
if (priv->decoders) {
|
|
|
|
g_array_free (priv->decoders, TRUE);
|
|
|
|
priv->decoders = NULL;
|
|
|
|
}
|
2010-04-20 13:36:04 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
if (priv->encoders) {
|
|
|
|
g_array_free (priv->encoders, TRUE);
|
|
|
|
priv->encoders = NULL;
|
|
|
|
}
|
2010-03-10 12:25:19 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
if (priv->image_formats) {
|
|
|
|
g_array_free (priv->image_formats, TRUE);
|
|
|
|
priv->image_formats = NULL;
|
|
|
|
}
|
2010-03-10 12:25:19 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
if (priv->subpicture_formats) {
|
|
|
|
g_array_free (priv->subpicture_formats, TRUE);
|
|
|
|
priv->subpicture_formats = NULL;
|
|
|
|
}
|
2010-03-10 12:25:19 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
if (priv->properties) {
|
|
|
|
g_array_free (priv->properties, TRUE);
|
|
|
|
priv->properties = NULL;
|
|
|
|
}
|
2012-08-27 14:02:49 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
if (priv->display) {
|
2017-09-28 14:12:23 +00:00
|
|
|
vaTerminate (priv->display);
|
2013-12-20 12:27:07 +00:00
|
|
|
priv->display = NULL;
|
|
|
|
}
|
2010-03-11 15:01:00 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
if (!priv->use_foreign_display) {
|
|
|
|
GstVaapiDisplayClass *klass = GST_VAAPI_DISPLAY_GET_CLASS (display);
|
|
|
|
if (klass->close_display)
|
|
|
|
klass->close_display (display);
|
|
|
|
}
|
2012-01-12 14:03:04 +00:00
|
|
|
|
2014-07-25 09:24:39 +00:00
|
|
|
g_free (priv->display_name);
|
|
|
|
priv->display_name = NULL;
|
|
|
|
|
2014-05-20 09:36:40 +00:00
|
|
|
g_free (priv->vendor_string);
|
|
|
|
priv->vendor_string = NULL;
|
2010-03-10 12:25:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2014-03-07 13:50:14 +00:00
|
|
|
gst_vaapi_display_create_unlocked (GstVaapiDisplay * display,
|
2017-07-05 05:32:35 +00:00
|
|
|
GstVaapiDisplayInitType init_type, gpointer data)
|
2010-03-10 12:25:19 +00:00
|
|
|
{
|
2013-12-20 12:27:07 +00:00
|
|
|
GstVaapiDisplayPrivate *const priv = GST_VAAPI_DISPLAY_GET_PRIVATE (display);
|
|
|
|
const GstVaapiDisplayClass *const klass =
|
|
|
|
GST_VAAPI_DISPLAY_GET_CLASS (display);
|
2017-07-05 05:32:35 +00:00
|
|
|
GstVaapiDisplayInfo info = {
|
|
|
|
.display = display,
|
|
|
|
};
|
2013-12-20 12:27:07 +00:00
|
|
|
|
|
|
|
switch (init_type) {
|
2017-07-05 05:32:35 +00:00
|
|
|
case GST_VAAPI_DISPLAY_INIT_FROM_VA_DISPLAY:{
|
|
|
|
GstVaapiDisplayInfo *p_info = data;
|
|
|
|
|
|
|
|
info.va_display = p_info->va_display;
|
|
|
|
priv->display = p_info->va_display;
|
2013-12-20 12:27:07 +00:00
|
|
|
priv->use_foreign_display = TRUE;
|
2017-07-05 05:32:35 +00:00
|
|
|
|
|
|
|
if (!klass->bind_display)
|
|
|
|
break;
|
|
|
|
|
|
|
|
data = p_info->native_display;
|
|
|
|
goto bind_display;
|
|
|
|
}
|
2013-05-07 09:39:34 +00:00
|
|
|
case GST_VAAPI_DISPLAY_INIT_FROM_DISPLAY_NAME:
|
2017-07-05 05:32:35 +00:00
|
|
|
if (klass->open_display && !klass->open_display (display, data))
|
2013-12-20 12:27:07 +00:00
|
|
|
return FALSE;
|
|
|
|
goto create_display;
|
2013-05-07 09:39:34 +00:00
|
|
|
case GST_VAAPI_DISPLAY_INIT_FROM_NATIVE_DISPLAY:
|
2017-07-05 05:32:35 +00:00
|
|
|
bind_display:
|
|
|
|
if (klass->bind_display && !klass->bind_display (display, data))
|
2010-03-11 15:01:00 +00:00
|
|
|
return FALSE;
|
2013-12-20 12:27:07 +00:00
|
|
|
// fall-through
|
|
|
|
create_display:
|
|
|
|
if (!klass->get_display || !klass->get_display (display, &info))
|
2012-01-12 14:03:04 +00:00
|
|
|
return FALSE;
|
2013-12-20 12:27:07 +00:00
|
|
|
priv->display = info.va_display;
|
2014-12-01 16:08:29 +00:00
|
|
|
priv->native_display = info.native_display;
|
2013-12-20 12:27:07 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (!priv->display)
|
|
|
|
return FALSE;
|
2010-03-10 12:25:19 +00:00
|
|
|
|
2017-09-28 14:12:23 +00:00
|
|
|
if (!vaapi_initialize (priv->display))
|
|
|
|
return FALSE;
|
2013-12-20 12:27:07 +00:00
|
|
|
|
2016-10-13 03:53:17 +00:00
|
|
|
GST_INFO_OBJECT (display, "new display addr=%p", display);
|
2014-07-25 09:24:39 +00:00
|
|
|
g_free (priv->display_name);
|
|
|
|
priv->display_name = g_strdup (info.display_name);
|
2013-12-20 13:01:45 +00:00
|
|
|
return TRUE;
|
2010-03-10 12:25:19 +00:00
|
|
|
}
|
|
|
|
|
2014-03-07 13:50:14 +00:00
|
|
|
static gboolean
|
|
|
|
gst_vaapi_display_create (GstVaapiDisplay * display,
|
|
|
|
GstVaapiDisplayInitType init_type, gpointer init_value)
|
|
|
|
{
|
2017-06-26 19:18:25 +00:00
|
|
|
return gst_vaapi_display_create_unlocked (display, init_type, init_value);
|
2014-03-07 13:50:14 +00:00
|
|
|
}
|
|
|
|
|
2010-03-17 07:59:31 +00:00
|
|
|
static void
|
2013-12-20 12:27:07 +00:00
|
|
|
gst_vaapi_display_lock_default (GstVaapiDisplay * display)
|
2010-03-17 07:59:31 +00:00
|
|
|
{
|
2013-12-20 12:27:07 +00:00
|
|
|
GstVaapiDisplayPrivate *priv = GST_VAAPI_DISPLAY_GET_PRIVATE (display);
|
2012-01-12 14:03:04 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
g_rec_mutex_lock (&priv->mutex);
|
2010-03-17 07:59:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-12-20 12:27:07 +00:00
|
|
|
gst_vaapi_display_unlock_default (GstVaapiDisplay * display)
|
2010-03-17 07:59:31 +00:00
|
|
|
{
|
2013-12-20 12:27:07 +00:00
|
|
|
GstVaapiDisplayPrivate *priv = GST_VAAPI_DISPLAY_GET_PRIVATE (display);
|
2012-01-12 14:03:04 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
g_rec_mutex_unlock (&priv->mutex);
|
2010-03-17 07:59:31 +00:00
|
|
|
}
|
|
|
|
|
2010-01-25 16:15:01 +00:00
|
|
|
static void
|
2013-12-20 12:27:07 +00:00
|
|
|
gst_vaapi_display_init (GstVaapiDisplay * display)
|
2010-01-25 16:15:01 +00:00
|
|
|
{
|
2016-10-13 03:53:17 +00:00
|
|
|
GstVaapiDisplayPrivate *const priv =
|
|
|
|
gst_vaapi_display_get_instance_private (display);
|
2010-01-25 16:15:01 +00:00
|
|
|
|
2016-10-13 03:53:17 +00:00
|
|
|
display->priv = priv;
|
2013-12-20 12:27:07 +00:00
|
|
|
priv->par_n = 1;
|
|
|
|
priv->par_d = 1;
|
2010-01-25 16:15:01 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
g_rec_mutex_init (&priv->mutex);
|
2010-01-25 16:15:01 +00:00
|
|
|
}
|
|
|
|
|
2017-09-22 15:04:17 +00:00
|
|
|
static gboolean
|
|
|
|
_set_property (GstVaapiDisplay * display, const GstVaapiProperty * prop,
|
|
|
|
const GValue * value)
|
|
|
|
{
|
|
|
|
switch (prop->attribute.type) {
|
|
|
|
case VADisplayAttribRenderMode:{
|
|
|
|
GstVaapiRenderMode mode;
|
|
|
|
if (!G_VALUE_HOLDS (value, GST_VAAPI_TYPE_RENDER_MODE))
|
|
|
|
return FALSE;
|
|
|
|
mode = g_value_get_enum (value);
|
|
|
|
return gst_vaapi_display_set_render_mode (display, mode);
|
|
|
|
}
|
|
|
|
case VADisplayAttribRotation:{
|
|
|
|
GstVaapiRotation rotation;
|
|
|
|
if (!G_VALUE_HOLDS (value, GST_VAAPI_TYPE_ROTATION))
|
|
|
|
return FALSE;
|
|
|
|
rotation = g_value_get_enum (value);
|
|
|
|
return gst_vaapi_display_set_rotation (display, rotation);
|
|
|
|
}
|
|
|
|
case VADisplayAttribHue:
|
|
|
|
case VADisplayAttribSaturation:
|
|
|
|
case VADisplayAttribBrightness:
|
|
|
|
case VADisplayAttribContrast:{
|
|
|
|
gfloat v;
|
|
|
|
if (!G_VALUE_HOLDS (value, G_TYPE_FLOAT))
|
|
|
|
return FALSE;
|
|
|
|
v = g_value_get_float (value);
|
|
|
|
return set_color_balance (display, find_property_id (prop->name), v);
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_WARNING ("unsupported property '%s'", prop->name);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2017-09-22 14:29:02 +00:00
|
|
|
static void
|
2018-05-22 12:05:54 +00:00
|
|
|
gst_vaapi_display_set_property (GObject * object, guint property_id,
|
2017-09-22 14:29:02 +00:00
|
|
|
const GValue * value, GParamSpec * pspec)
|
|
|
|
{
|
|
|
|
GstVaapiDisplay *display = GST_VAAPI_DISPLAY (object);
|
|
|
|
const GstVaapiProperty *prop;
|
|
|
|
|
2017-09-22 15:04:17 +00:00
|
|
|
if (!ensure_properties (display))
|
|
|
|
return;
|
|
|
|
|
2017-09-22 14:29:02 +00:00
|
|
|
prop = find_property_by_pspec (display, pspec);
|
|
|
|
if (!prop) {
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-09-22 15:04:17 +00:00
|
|
|
_set_property (display, prop, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
_get_property (GstVaapiDisplay * display, const GstVaapiProperty * prop,
|
|
|
|
GValue * value)
|
|
|
|
{
|
|
|
|
switch (prop->attribute.type) {
|
|
|
|
case VADisplayAttribRenderMode:{
|
|
|
|
GstVaapiRenderMode mode;
|
|
|
|
if (!gst_vaapi_display_get_render_mode (display, &mode))
|
|
|
|
return FALSE;
|
2017-09-22 16:59:49 +00:00
|
|
|
if (!G_IS_VALUE (value))
|
|
|
|
g_value_init (value, GST_VAAPI_TYPE_RENDER_MODE);
|
2017-09-22 15:04:17 +00:00
|
|
|
g_value_set_enum (value, mode);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case VADisplayAttribRotation:{
|
|
|
|
GstVaapiRotation rotation;
|
|
|
|
rotation = gst_vaapi_display_get_rotation (display);
|
2017-09-22 16:59:49 +00:00
|
|
|
if (!G_IS_VALUE (value))
|
|
|
|
g_value_init (value, GST_VAAPI_TYPE_ROTATION);
|
2017-09-22 15:04:17 +00:00
|
|
|
g_value_set_enum (value, rotation);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case VADisplayAttribHue:
|
|
|
|
case VADisplayAttribSaturation:
|
|
|
|
case VADisplayAttribBrightness:
|
|
|
|
case VADisplayAttribContrast:{
|
|
|
|
gfloat val;
|
|
|
|
if (!get_color_balance (display, find_property_id (prop->name), &val))
|
|
|
|
return FALSE;
|
2017-09-22 16:59:49 +00:00
|
|
|
if (!G_IS_VALUE (value))
|
|
|
|
g_value_init (value, G_TYPE_FLOAT);
|
2017-09-22 15:04:17 +00:00
|
|
|
g_value_set_float (value, val);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
GST_WARNING ("unsupported property '%s'", prop->name);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
return TRUE;
|
2017-09-22 14:29:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2018-05-22 12:05:54 +00:00
|
|
|
gst_vaapi_display_get_property (GObject * object, guint property_id,
|
2017-09-22 14:29:02 +00:00
|
|
|
GValue * value, GParamSpec * pspec)
|
|
|
|
{
|
|
|
|
GstVaapiDisplay *display = GST_VAAPI_DISPLAY (object);
|
|
|
|
const GstVaapiProperty *prop;
|
|
|
|
|
2017-09-22 15:04:17 +00:00
|
|
|
if (!ensure_properties (display))
|
|
|
|
return;
|
|
|
|
|
2017-09-22 14:29:02 +00:00
|
|
|
prop = find_property_by_pspec (display, pspec);
|
|
|
|
if (!prop) {
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-09-22 15:04:17 +00:00
|
|
|
_get_property (display, prop, value);
|
2017-09-22 14:29:02 +00:00
|
|
|
}
|
|
|
|
|
2010-01-25 16:15:01 +00:00
|
|
|
static void
|
2016-10-13 03:53:17 +00:00
|
|
|
gst_vaapi_display_finalize (GObject * object)
|
2010-01-25 16:15:01 +00:00
|
|
|
{
|
2016-10-13 03:53:17 +00:00
|
|
|
GstVaapiDisplay *const display = GST_VAAPI_DISPLAY (object);
|
2013-12-20 12:27:07 +00:00
|
|
|
GstVaapiDisplayPrivate *const priv = GST_VAAPI_DISPLAY_GET_PRIVATE (display);
|
2010-01-25 16:15:01 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
gst_vaapi_display_destroy (display);
|
|
|
|
g_rec_mutex_clear (&priv->mutex);
|
2016-10-13 03:53:17 +00:00
|
|
|
|
|
|
|
G_OBJECT_CLASS (gst_vaapi_display_parent_class)->finalize (object);
|
2010-03-11 15:01:00 +00:00
|
|
|
}
|
|
|
|
|
2013-05-07 09:39:34 +00:00
|
|
|
void
|
2013-12-20 12:27:07 +00:00
|
|
|
gst_vaapi_display_class_init (GstVaapiDisplayClass * klass)
|
2010-01-25 16:15:01 +00:00
|
|
|
{
|
2016-10-13 03:53:17 +00:00
|
|
|
GObjectClass *const object_class = G_OBJECT_CLASS (klass);
|
2010-01-25 16:15:01 +00:00
|
|
|
|
2016-10-13 03:53:17 +00:00
|
|
|
object_class->finalize = gst_vaapi_display_finalize;
|
2018-05-22 12:05:54 +00:00
|
|
|
object_class->set_property = gst_vaapi_display_set_property;
|
|
|
|
object_class->get_property = gst_vaapi_display_get_property;
|
2017-09-22 13:12:05 +00:00
|
|
|
|
2016-10-13 03:53:17 +00:00
|
|
|
klass->lock = gst_vaapi_display_lock_default;
|
|
|
|
klass->unlock = gst_vaapi_display_unlock_default;
|
2017-09-22 13:12:05 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
/**
|
|
|
|
* GstVaapiDisplay:render-mode:
|
|
|
|
*
|
|
|
|
* The VA display rendering mode, expressed as a #GstVaapiRenderMode.
|
|
|
|
*/
|
|
|
|
g_properties[PROP_RENDER_MODE] =
|
|
|
|
g_param_spec_enum (GST_VAAPI_DISPLAY_PROP_RENDER_MODE,
|
|
|
|
"render mode",
|
|
|
|
"The display rendering mode",
|
|
|
|
GST_VAAPI_TYPE_RENDER_MODE, DEFAULT_RENDER_MODE, G_PARAM_READWRITE);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* GstVaapiDisplay:rotation:
|
|
|
|
*
|
|
|
|
* The VA display rotation mode, expressed as a #GstVaapiRotation.
|
|
|
|
*/
|
|
|
|
g_properties[PROP_ROTATION] =
|
|
|
|
g_param_spec_enum (GST_VAAPI_DISPLAY_PROP_ROTATION,
|
|
|
|
"rotation",
|
|
|
|
"The display rotation mode",
|
|
|
|
GST_VAAPI_TYPE_ROTATION, DEFAULT_ROTATION, G_PARAM_READWRITE);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* GstVaapiDisplay:hue:
|
|
|
|
*
|
|
|
|
* The VA display hue, expressed as a float value. Range is -180.0
|
|
|
|
* to 180.0. Default value is 0.0 and represents no modification.
|
|
|
|
*/
|
|
|
|
g_properties[PROP_HUE] =
|
|
|
|
g_param_spec_float (GST_VAAPI_DISPLAY_PROP_HUE,
|
|
|
|
"hue", "The display hue value", -180.0, 180.0, 0.0, G_PARAM_READWRITE);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* GstVaapiDisplay:saturation:
|
|
|
|
*
|
|
|
|
* The VA display saturation, expressed as a float value. Range is
|
|
|
|
* 0.0 to 2.0. Default value is 1.0 and represents no modification.
|
|
|
|
*/
|
|
|
|
g_properties[PROP_SATURATION] =
|
|
|
|
g_param_spec_float (GST_VAAPI_DISPLAY_PROP_SATURATION,
|
|
|
|
"saturation",
|
|
|
|
"The display saturation value", 0.0, 2.0, 1.0, G_PARAM_READWRITE);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* GstVaapiDisplay:brightness:
|
|
|
|
*
|
|
|
|
* The VA display brightness, expressed as a float value. Range is
|
|
|
|
* -1.0 to 1.0. Default value is 0.0 and represents no modification.
|
|
|
|
*/
|
|
|
|
g_properties[PROP_BRIGHTNESS] =
|
|
|
|
g_param_spec_float (GST_VAAPI_DISPLAY_PROP_BRIGHTNESS,
|
|
|
|
"brightness",
|
|
|
|
"The display brightness value", -1.0, 1.0, 0.0, G_PARAM_READWRITE);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* GstVaapiDisplay:contrast:
|
|
|
|
*
|
|
|
|
* The VA display contrast, expressed as a float value. Range is 0.0
|
|
|
|
* to 2.0. Default value is 1.0 and represents no modification.
|
|
|
|
*/
|
|
|
|
g_properties[PROP_CONTRAST] =
|
|
|
|
g_param_spec_float (GST_VAAPI_DISPLAY_PROP_CONTRAST,
|
|
|
|
"contrast",
|
|
|
|
"The display contrast value", 0.0, 2.0, 1.0, G_PARAM_READWRITE);
|
2017-09-22 14:29:02 +00:00
|
|
|
|
|
|
|
g_object_class_install_properties (object_class, N_PROPERTIES, g_properties);
|
2013-05-07 09:39:34 +00:00
|
|
|
}
|
2012-08-28 11:59:50 +00:00
|
|
|
|
2013-05-07 09:39:34 +00:00
|
|
|
GstVaapiDisplay *
|
2016-10-13 03:53:17 +00:00
|
|
|
gst_vaapi_display_new (GstVaapiDisplay * display,
|
2013-05-07 09:39:34 +00:00
|
|
|
GstVaapiDisplayInitType init_type, gpointer init_value)
|
2010-01-25 16:15:01 +00:00
|
|
|
{
|
2016-10-13 03:53:17 +00:00
|
|
|
g_return_val_if_fail (display != NULL, NULL);
|
2010-03-17 07:59:31 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
if (!gst_vaapi_display_create (display, init_type, init_value))
|
|
|
|
goto error;
|
|
|
|
return display;
|
2013-05-07 09:39:34 +00:00
|
|
|
|
2016-10-19 17:04:20 +00:00
|
|
|
/* ERRORS */
|
2013-05-07 09:39:34 +00:00
|
|
|
error:
|
2016-10-19 17:04:20 +00:00
|
|
|
{
|
|
|
|
gst_vaapi_display_unref_internal (display);
|
|
|
|
return NULL;
|
|
|
|
}
|
2010-01-25 16:15:01 +00:00
|
|
|
}
|
|
|
|
|
2010-03-19 15:45:21 +00:00
|
|
|
/**
|
|
|
|
* gst_vaapi_display_new_with_display:
|
|
|
|
* @va_display: a #VADisplay
|
|
|
|
*
|
|
|
|
* Creates a new #GstVaapiDisplay, using @va_display as the VA
|
|
|
|
* display.
|
|
|
|
*
|
|
|
|
* Return value: the newly created #GstVaapiDisplay object
|
|
|
|
*/
|
2010-03-10 12:25:19 +00:00
|
|
|
GstVaapiDisplay *
|
2013-12-20 12:27:07 +00:00
|
|
|
gst_vaapi_display_new_with_display (VADisplay va_display)
|
2010-01-25 16:15:01 +00:00
|
|
|
{
|
2017-07-05 05:32:35 +00:00
|
|
|
GstVaapiDisplayInfo info = {
|
|
|
|
.va_display = va_display,
|
|
|
|
};
|
|
|
|
|
2016-10-13 03:53:17 +00:00
|
|
|
return gst_vaapi_display_new (g_object_new (GST_TYPE_VAAPI_DISPLAY, NULL),
|
2017-07-05 05:32:35 +00:00
|
|
|
GST_VAAPI_DISPLAY_INIT_FROM_VA_DISPLAY, &info);
|
2013-05-07 09:39:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_vaapi_display_ref:
|
|
|
|
* @display: a #GstVaapiDisplay
|
|
|
|
*
|
|
|
|
* Atomically increases the reference count of the given @display by one.
|
|
|
|
*
|
|
|
|
* Returns: The same @display argument
|
|
|
|
*/
|
|
|
|
GstVaapiDisplay *
|
2013-12-20 12:27:07 +00:00
|
|
|
gst_vaapi_display_ref (GstVaapiDisplay * display)
|
2013-05-07 09:39:34 +00:00
|
|
|
{
|
2013-12-20 12:27:07 +00:00
|
|
|
return gst_vaapi_display_ref_internal (display);
|
2013-05-07 09:39:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_vaapi_display_unref:
|
|
|
|
* @display: a #GstVaapiDisplay
|
|
|
|
*
|
|
|
|
* Atomically decreases the reference count of the @display by one. If
|
|
|
|
* the reference count reaches zero, the display will be free'd.
|
|
|
|
*/
|
|
|
|
void
|
2013-12-20 12:27:07 +00:00
|
|
|
gst_vaapi_display_unref (GstVaapiDisplay * display)
|
2013-05-07 09:39:34 +00:00
|
|
|
{
|
2013-12-20 12:27:07 +00:00
|
|
|
gst_vaapi_display_unref_internal (display);
|
2013-05-07 09:39:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_vaapi_display_replace:
|
|
|
|
* @old_display_ptr: a pointer to a #GstVaapiDisplay
|
|
|
|
* @new_display: a #GstVaapiDisplay
|
|
|
|
*
|
|
|
|
* Atomically replaces the display display held in @old_display_ptr
|
|
|
|
* with @new_display. This means that @old_display_ptr shall reference
|
|
|
|
* a valid display. However, @new_display can be NULL.
|
|
|
|
*/
|
|
|
|
void
|
2013-12-20 12:27:07 +00:00
|
|
|
gst_vaapi_display_replace (GstVaapiDisplay ** old_display_ptr,
|
|
|
|
GstVaapiDisplay * new_display)
|
2013-05-07 09:39:34 +00:00
|
|
|
{
|
2013-12-20 12:27:07 +00:00
|
|
|
gst_vaapi_display_replace_internal (old_display_ptr, new_display);
|
2010-01-25 16:15:01 +00:00
|
|
|
}
|
|
|
|
|
2010-03-19 15:45:21 +00:00
|
|
|
/**
|
|
|
|
* gst_vaapi_display_lock:
|
|
|
|
* @display: a #GstVaapiDisplay
|
|
|
|
*
|
|
|
|
* Locks @display. If @display is already locked by another thread,
|
|
|
|
* the current thread will block until @display is unlocked by the
|
|
|
|
* other thread.
|
|
|
|
*/
|
2010-03-17 07:59:31 +00:00
|
|
|
void
|
2013-12-20 12:27:07 +00:00
|
|
|
gst_vaapi_display_lock (GstVaapiDisplay * display)
|
2010-03-17 07:59:31 +00:00
|
|
|
{
|
2013-12-20 12:27:07 +00:00
|
|
|
GstVaapiDisplayClass *klass;
|
2010-03-17 07:59:31 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
g_return_if_fail (display != NULL);
|
2010-03-17 07:59:31 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
klass = GST_VAAPI_DISPLAY_GET_CLASS (display);
|
|
|
|
if (klass->lock)
|
|
|
|
klass->lock (display);
|
2010-03-17 07:59:31 +00:00
|
|
|
}
|
|
|
|
|
2010-03-19 15:45:21 +00:00
|
|
|
/**
|
|
|
|
* gst_vaapi_display_unlock:
|
|
|
|
* @display: a #GstVaapiDisplay
|
|
|
|
*
|
|
|
|
* Unlocks @display. If another thread is blocked in a
|
|
|
|
* gst_vaapi_display_lock() call for @display, it will be woken and
|
|
|
|
* can lock @display itself.
|
|
|
|
*/
|
2010-03-17 07:59:31 +00:00
|
|
|
void
|
2013-12-20 12:27:07 +00:00
|
|
|
gst_vaapi_display_unlock (GstVaapiDisplay * display)
|
2010-03-17 07:59:31 +00:00
|
|
|
{
|
2013-12-20 12:27:07 +00:00
|
|
|
GstVaapiDisplayClass *klass;
|
2010-03-17 07:59:31 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
g_return_if_fail (display != NULL);
|
2010-03-17 07:59:31 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
klass = GST_VAAPI_DISPLAY_GET_CLASS (display);
|
|
|
|
if (klass->unlock)
|
|
|
|
klass->unlock (display);
|
2010-03-17 07:59:31 +00:00
|
|
|
}
|
|
|
|
|
2010-03-26 11:35:20 +00:00
|
|
|
/**
|
|
|
|
* gst_vaapi_display_sync:
|
|
|
|
* @display: a #GstVaapiDisplay
|
|
|
|
*
|
|
|
|
* Flushes any requests queued for the windowing system and waits until
|
|
|
|
* all requests have been handled. This is often used for making sure
|
|
|
|
* that the display is synchronized with the current state of the program.
|
|
|
|
*
|
|
|
|
* This is most useful for X11. On windowing systems where requests are
|
|
|
|
* handled synchronously, this function will do nothing.
|
|
|
|
*/
|
|
|
|
void
|
2013-12-20 12:27:07 +00:00
|
|
|
gst_vaapi_display_sync (GstVaapiDisplay * display)
|
2010-03-26 11:35:20 +00:00
|
|
|
{
|
2013-12-20 12:27:07 +00:00
|
|
|
GstVaapiDisplayClass *klass;
|
2010-03-26 11:35:20 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
g_return_if_fail (display != NULL);
|
2010-03-26 11:35:20 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
klass = GST_VAAPI_DISPLAY_GET_CLASS (display);
|
|
|
|
if (klass->sync)
|
|
|
|
klass->sync (display);
|
|
|
|
else if (klass->flush)
|
|
|
|
klass->flush (display);
|
2010-03-26 11:35:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-03-29 11:25:20 +00:00
|
|
|
* gst_vaapi_display_flush:
|
2010-03-26 11:35:20 +00:00
|
|
|
* @display: a #GstVaapiDisplay
|
|
|
|
*
|
|
|
|
* Flushes any requests queued for the windowing system.
|
|
|
|
*
|
|
|
|
* This is most useful for X11. On windowing systems where requests
|
|
|
|
* are handled synchronously, this function will do nothing.
|
|
|
|
*/
|
|
|
|
void
|
2013-12-20 12:27:07 +00:00
|
|
|
gst_vaapi_display_flush (GstVaapiDisplay * display)
|
2010-03-26 11:35:20 +00:00
|
|
|
{
|
2013-12-20 12:27:07 +00:00
|
|
|
GstVaapiDisplayClass *klass;
|
2010-03-26 11:35:20 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
g_return_if_fail (display != NULL);
|
2010-03-26 11:35:20 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
klass = GST_VAAPI_DISPLAY_GET_CLASS (display);
|
|
|
|
if (klass->flush)
|
|
|
|
klass->flush (display);
|
2010-03-26 11:35:20 +00:00
|
|
|
}
|
|
|
|
|
2014-12-10 17:02:55 +00:00
|
|
|
/**
|
|
|
|
* gst_vaapi_display_get_class_type:
|
|
|
|
* @display: a #GstVaapiDisplay
|
|
|
|
*
|
|
|
|
* Returns the #GstVaapiDisplayType of @display. This is the type of
|
|
|
|
* the object, thus the associated class, not the type of the VA
|
|
|
|
* display.
|
|
|
|
*
|
|
|
|
* Return value: the #GstVaapiDisplayType
|
|
|
|
*/
|
|
|
|
GstVaapiDisplayType
|
|
|
|
gst_vaapi_display_get_class_type (GstVaapiDisplay * display)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (display != NULL, GST_VAAPI_DISPLAY_TYPE_ANY);
|
|
|
|
|
|
|
|
return GST_VAAPI_DISPLAY_GET_CLASS_TYPE (display);
|
|
|
|
}
|
|
|
|
|
2012-07-25 07:16:02 +00:00
|
|
|
/**
|
2014-12-02 10:23:29 +00:00
|
|
|
* gst_vaapi_display_get_display_type:
|
2012-07-25 07:16:02 +00:00
|
|
|
* @display: a #GstVaapiDisplay
|
|
|
|
*
|
2014-12-10 17:02:55 +00:00
|
|
|
* Returns the #GstVaapiDisplayType of the VA display bound to
|
|
|
|
* @display. This is not the type of the @display object.
|
2012-07-25 07:16:02 +00:00
|
|
|
*
|
|
|
|
* Return value: the #GstVaapiDisplayType
|
|
|
|
*/
|
|
|
|
GstVaapiDisplayType
|
2013-12-20 12:27:07 +00:00
|
|
|
gst_vaapi_display_get_display_type (GstVaapiDisplay * display)
|
2012-07-25 07:16:02 +00:00
|
|
|
{
|
2013-12-20 12:27:07 +00:00
|
|
|
g_return_val_if_fail (display != NULL, GST_VAAPI_DISPLAY_TYPE_ANY);
|
2012-07-25 07:16:02 +00:00
|
|
|
|
2014-12-10 17:02:55 +00:00
|
|
|
return GST_VAAPI_DISPLAY_VADISPLAY_TYPE (display);
|
2012-07-25 07:16:02 +00:00
|
|
|
}
|
|
|
|
|
2014-07-25 09:24:39 +00:00
|
|
|
/**
|
|
|
|
* gst_vaapi_display_get_display_type:
|
|
|
|
* @display: a #GstVaapiDisplay
|
|
|
|
*
|
|
|
|
* Returns the @display name.
|
|
|
|
*
|
|
|
|
* Return value: the display name
|
|
|
|
*/
|
|
|
|
const gchar *
|
|
|
|
gst_vaapi_display_get_display_name (GstVaapiDisplay * display)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (display != NULL, NULL);
|
|
|
|
|
|
|
|
return GST_VAAPI_DISPLAY_GET_PRIVATE (display)->display_name;
|
|
|
|
}
|
|
|
|
|
2010-03-19 15:45:21 +00:00
|
|
|
/**
|
|
|
|
* gst_vaapi_display_get_display:
|
|
|
|
* @display: a #GstVaapiDisplay
|
|
|
|
*
|
|
|
|
* Returns the #VADisplay bound to @display.
|
|
|
|
*
|
|
|
|
* Return value: the #VADisplay
|
|
|
|
*/
|
2010-03-10 12:25:19 +00:00
|
|
|
VADisplay
|
2013-12-20 12:27:07 +00:00
|
|
|
gst_vaapi_display_get_display (GstVaapiDisplay * display)
|
2010-01-25 16:15:01 +00:00
|
|
|
{
|
2013-12-20 12:27:07 +00:00
|
|
|
g_return_val_if_fail (display != NULL, NULL);
|
2010-01-25 16:15:01 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
return GST_VAAPI_DISPLAY_GET_PRIVATE (display)->display;
|
2010-01-25 16:15:01 +00:00
|
|
|
}
|
|
|
|
|
2010-03-22 08:44:38 +00:00
|
|
|
/**
|
|
|
|
* gst_vaapi_display_get_width:
|
|
|
|
* @display: a #GstVaapiDisplay
|
|
|
|
*
|
|
|
|
* Retrieves the width of a #GstVaapiDisplay.
|
|
|
|
*
|
|
|
|
* Return value: the width of the @display, in pixels
|
|
|
|
*/
|
|
|
|
guint
|
2013-12-20 12:27:07 +00:00
|
|
|
gst_vaapi_display_get_width (GstVaapiDisplay * display)
|
2010-03-22 08:44:38 +00:00
|
|
|
{
|
2013-12-20 12:27:07 +00:00
|
|
|
g_return_val_if_fail (display != NULL, 0);
|
2010-03-22 08:44:38 +00:00
|
|
|
|
2017-09-29 13:07:47 +00:00
|
|
|
gst_vaapi_display_ensure_screen_resolution (display);
|
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
return GST_VAAPI_DISPLAY_GET_PRIVATE (display)->width;
|
2010-03-22 08:44:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_vaapi_display_get_height:
|
|
|
|
* @display: a #GstVaapiDisplay
|
|
|
|
*
|
|
|
|
* Retrieves the height of a #GstVaapiDisplay
|
|
|
|
*
|
|
|
|
* Return value: the height of the @display, in pixels
|
|
|
|
*/
|
|
|
|
guint
|
2013-12-20 12:27:07 +00:00
|
|
|
gst_vaapi_display_get_height (GstVaapiDisplay * display)
|
2010-03-22 08:44:38 +00:00
|
|
|
{
|
2013-12-20 12:27:07 +00:00
|
|
|
g_return_val_if_fail (display != NULL, 0);
|
2010-03-22 08:44:38 +00:00
|
|
|
|
2017-09-29 13:07:47 +00:00
|
|
|
gst_vaapi_display_ensure_screen_resolution (display);
|
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
return GST_VAAPI_DISPLAY_GET_PRIVATE (display)->height;
|
2010-03-22 08:44:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_vaapi_display_get_size:
|
|
|
|
* @display: a #GstVaapiDisplay
|
2010-03-23 13:32:36 +00:00
|
|
|
* @pwidth: return location for the width, or %NULL
|
|
|
|
* @pheight: return location for the height, or %NULL
|
2010-03-22 08:44:38 +00:00
|
|
|
*
|
|
|
|
* Retrieves the dimensions of a #GstVaapiDisplay.
|
|
|
|
*/
|
|
|
|
void
|
2013-12-20 12:27:07 +00:00
|
|
|
gst_vaapi_display_get_size (GstVaapiDisplay * display, guint * pwidth,
|
|
|
|
guint * pheight)
|
2010-03-22 08:44:38 +00:00
|
|
|
{
|
2013-12-20 12:27:07 +00:00
|
|
|
g_return_if_fail (GST_VAAPI_DISPLAY (display));
|
2010-03-22 08:44:38 +00:00
|
|
|
|
2017-09-29 13:07:47 +00:00
|
|
|
gst_vaapi_display_ensure_screen_resolution (display);
|
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
if (pwidth)
|
|
|
|
*pwidth = GST_VAAPI_DISPLAY_GET_PRIVATE (display)->width;
|
2010-03-22 08:44:38 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
if (pheight)
|
|
|
|
*pheight = GST_VAAPI_DISPLAY_GET_PRIVATE (display)->height;
|
2010-03-22 08:44:38 +00:00
|
|
|
}
|
|
|
|
|
2010-03-22 09:32:01 +00:00
|
|
|
/**
|
|
|
|
* gst_vaapi_display_get_pixel_aspect_ratio:
|
|
|
|
* @display: a #GstVaapiDisplay
|
2010-03-23 13:32:36 +00:00
|
|
|
* @par_n: return location for the numerator of pixel aspect ratio, or %NULL
|
|
|
|
* @par_d: return location for the denominator of pixel aspect ratio, or %NULL
|
2010-03-22 09:32:01 +00:00
|
|
|
*
|
|
|
|
* Retrieves the pixel aspect ratio of a #GstVaapiDisplay.
|
|
|
|
*/
|
|
|
|
void
|
2013-12-20 12:27:07 +00:00
|
|
|
gst_vaapi_display_get_pixel_aspect_ratio (GstVaapiDisplay * display,
|
|
|
|
guint * par_n, guint * par_d)
|
2010-03-22 09:32:01 +00:00
|
|
|
{
|
2013-12-20 12:27:07 +00:00
|
|
|
g_return_if_fail (display != NULL);
|
2010-03-22 09:32:01 +00:00
|
|
|
|
2017-09-29 13:07:47 +00:00
|
|
|
gst_vaapi_display_ensure_screen_resolution (display);
|
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
if (par_n)
|
|
|
|
*par_n = GST_VAAPI_DISPLAY_GET_PRIVATE (display)->par_n;
|
2010-03-22 09:32:01 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
if (par_d)
|
|
|
|
*par_d = GST_VAAPI_DISPLAY_GET_PRIVATE (display)->par_d;
|
2010-03-22 09:32:01 +00:00
|
|
|
}
|
|
|
|
|
2013-12-20 13:01:45 +00:00
|
|
|
/**
|
|
|
|
* gst_vaapi_display_has_video_processing:
|
|
|
|
* @display: a #GstVaapiDisplay
|
|
|
|
*
|
|
|
|
* Checks whether the underlying VA driver implementation supports
|
|
|
|
* video processing (VPP) acceleration.
|
|
|
|
*
|
|
|
|
* Returns: %TRUE if some VPP features are available
|
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
gst_vaapi_display_has_video_processing (GstVaapiDisplay * display)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (display != NULL, FALSE);
|
|
|
|
|
|
|
|
if (!ensure_profiles (display))
|
|
|
|
return FALSE;
|
|
|
|
return GST_VAAPI_DISPLAY_GET_PRIVATE (display)->has_vpp;
|
|
|
|
}
|
|
|
|
|
2010-03-19 15:45:21 +00:00
|
|
|
/**
|
2013-12-20 14:31:14 +00:00
|
|
|
* gst_vaapi_display_get_decode_profiles:
|
2010-04-20 13:36:04 +00:00
|
|
|
* @display: a #GstVaapiDisplay
|
|
|
|
*
|
2013-12-20 14:31:14 +00:00
|
|
|
* Gets the supported profiles for decoding. The caller owns an extra
|
|
|
|
* reference to the resulting array of #GstVaapiProfile elements, so
|
|
|
|
* it shall be released with g_array_unref() after usage.
|
2010-04-20 13:36:04 +00:00
|
|
|
*
|
2013-12-20 14:31:14 +00:00
|
|
|
* Return value: a newly allocated #GArray, or %NULL or error or if
|
|
|
|
* decoding is not supported at all
|
2010-04-20 13:36:04 +00:00
|
|
|
*/
|
2013-12-20 14:31:14 +00:00
|
|
|
GArray *
|
|
|
|
gst_vaapi_display_get_decode_profiles (GstVaapiDisplay * display)
|
2010-04-20 13:36:04 +00:00
|
|
|
{
|
2013-12-20 12:27:07 +00:00
|
|
|
g_return_val_if_fail (display != NULL, NULL);
|
2010-04-20 13:36:04 +00:00
|
|
|
|
2013-12-20 13:01:45 +00:00
|
|
|
if (!ensure_profiles (display))
|
|
|
|
return NULL;
|
2013-12-20 14:31:14 +00:00
|
|
|
return get_profiles (GST_VAAPI_DISPLAY_GET_PRIVATE (display)->decoders);
|
2010-04-20 13:36:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_vaapi_display_has_decoder:
|
2010-03-19 15:45:21 +00:00
|
|
|
* @display: a #GstVaapiDisplay
|
|
|
|
* @profile: a #VAProfile
|
2010-04-30 09:52:29 +00:00
|
|
|
* @entrypoint: a #GstVaaiEntrypoint
|
2010-03-19 15:45:21 +00:00
|
|
|
*
|
2010-04-30 09:52:29 +00:00
|
|
|
* Returns whether VA @display supports @profile for decoding at the
|
|
|
|
* specified @entrypoint.
|
2010-03-19 15:45:21 +00:00
|
|
|
*
|
2010-04-20 13:36:04 +00:00
|
|
|
* Return value: %TRUE if VA @display supports @profile for decoding.
|
2010-03-19 15:45:21 +00:00
|
|
|
*/
|
2010-03-04 17:41:34 +00:00
|
|
|
gboolean
|
2013-12-20 12:27:07 +00:00
|
|
|
gst_vaapi_display_has_decoder (GstVaapiDisplay * display,
|
|
|
|
GstVaapiProfile profile, GstVaapiEntrypoint entrypoint)
|
2010-04-20 13:36:04 +00:00
|
|
|
{
|
2013-12-20 12:27:07 +00:00
|
|
|
g_return_val_if_fail (display != NULL, FALSE);
|
2010-04-20 13:36:04 +00:00
|
|
|
|
2013-12-20 13:01:45 +00:00
|
|
|
if (!ensure_profiles (display))
|
|
|
|
return FALSE;
|
2013-12-20 12:27:07 +00:00
|
|
|
return find_config (GST_VAAPI_DISPLAY_GET_PRIVATE (display)->decoders,
|
|
|
|
profile, entrypoint);
|
2010-04-20 13:36:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-12-20 14:31:14 +00:00
|
|
|
* gst_vaapi_display_get_encode_profiles:
|
2010-04-20 13:36:04 +00:00
|
|
|
* @display: a #GstVaapiDisplay
|
|
|
|
*
|
2013-12-20 14:31:14 +00:00
|
|
|
* Gets the supported profiles for encoding. The caller owns an extra
|
|
|
|
* reference to the resulting array of #GstVaapiProfile elements, so
|
|
|
|
* it shall be released with g_array_unref() after usage.
|
2010-04-20 13:36:04 +00:00
|
|
|
*
|
2013-12-20 14:31:14 +00:00
|
|
|
* Return value: a newly allocated #GArray, or %NULL or error or if
|
|
|
|
* encoding is not supported at all
|
2010-04-20 13:36:04 +00:00
|
|
|
*/
|
2013-12-20 14:31:14 +00:00
|
|
|
GArray *
|
|
|
|
gst_vaapi_display_get_encode_profiles (GstVaapiDisplay * display)
|
2010-04-20 13:36:04 +00:00
|
|
|
{
|
2013-12-20 12:27:07 +00:00
|
|
|
g_return_val_if_fail (display != NULL, NULL);
|
2010-04-20 13:36:04 +00:00
|
|
|
|
2013-12-20 13:01:45 +00:00
|
|
|
if (!ensure_profiles (display))
|
|
|
|
return NULL;
|
2013-12-20 14:31:14 +00:00
|
|
|
return get_profiles (GST_VAAPI_DISPLAY_GET_PRIVATE (display)->encoders);
|
2010-04-20 13:36:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_vaapi_display_has_encoder:
|
|
|
|
* @display: a #GstVaapiDisplay
|
|
|
|
* @profile: a #VAProfile
|
2010-04-30 09:52:29 +00:00
|
|
|
* @entrypoint: a #GstVaapiEntrypoint
|
2010-04-20 13:36:04 +00:00
|
|
|
*
|
2010-04-30 09:52:29 +00:00
|
|
|
* Returns whether VA @display supports @profile for encoding at the
|
|
|
|
* specified @entrypoint.
|
2010-04-20 13:36:04 +00:00
|
|
|
*
|
|
|
|
* Return value: %TRUE if VA @display supports @profile for encoding.
|
|
|
|
*/
|
|
|
|
gboolean
|
2013-12-20 12:27:07 +00:00
|
|
|
gst_vaapi_display_has_encoder (GstVaapiDisplay * display,
|
|
|
|
GstVaapiProfile profile, GstVaapiEntrypoint entrypoint)
|
2010-03-04 17:41:34 +00:00
|
|
|
{
|
2013-12-20 12:27:07 +00:00
|
|
|
g_return_val_if_fail (display != NULL, FALSE);
|
2010-03-04 17:41:34 +00:00
|
|
|
|
2013-12-20 13:01:45 +00:00
|
|
|
if (!ensure_profiles (display))
|
|
|
|
return FALSE;
|
2013-12-20 12:27:07 +00:00
|
|
|
return find_config (GST_VAAPI_DISPLAY_GET_PRIVATE (display)->encoders,
|
|
|
|
profile, entrypoint);
|
2010-03-10 10:43:31 +00:00
|
|
|
}
|
|
|
|
|
2010-03-19 15:45:21 +00:00
|
|
|
/**
|
2013-12-20 14:15:05 +00:00
|
|
|
* gst_vaapi_display_get_image_formats:
|
2010-03-19 15:45:21 +00:00
|
|
|
* @display: a #GstVaapiDisplay
|
|
|
|
*
|
|
|
|
* Gets the supported image formats for gst_vaapi_surface_get_image()
|
2013-12-20 14:15:05 +00:00
|
|
|
* or gst_vaapi_surface_put_image().
|
2010-03-19 15:45:21 +00:00
|
|
|
*
|
|
|
|
* Note that this method does not necessarily map image formats
|
|
|
|
* returned by vaQueryImageFormats(). The set of capabilities can be
|
|
|
|
* stripped down, if gstreamer-vaapi does not support the format, or
|
|
|
|
* expanded to cover compatible formats not exposed by the underlying
|
|
|
|
* driver. e.g. I420 can be supported even if the driver only exposes
|
|
|
|
* YV12.
|
|
|
|
*
|
2013-12-20 14:15:05 +00:00
|
|
|
* Note: the caller owns an extra reference to the resulting array of
|
|
|
|
* #GstVideoFormat elements, so it shall be released with
|
|
|
|
* g_array_unref() after usage.
|
|
|
|
*
|
|
|
|
* Return value: a newly allocated #GArray, or %NULL on error or if
|
|
|
|
* the set is empty
|
2010-03-19 15:45:21 +00:00
|
|
|
*/
|
2013-12-20 14:15:05 +00:00
|
|
|
GArray *
|
|
|
|
gst_vaapi_display_get_image_formats (GstVaapiDisplay * display)
|
2010-03-10 10:43:31 +00:00
|
|
|
{
|
2013-12-20 12:27:07 +00:00
|
|
|
g_return_val_if_fail (display != NULL, NULL);
|
2010-03-10 10:43:31 +00:00
|
|
|
|
2013-12-20 13:01:45 +00:00
|
|
|
if (!ensure_image_formats (display))
|
|
|
|
return NULL;
|
2013-12-20 14:15:05 +00:00
|
|
|
return get_formats (GST_VAAPI_DISPLAY_GET_PRIVATE (display)->image_formats);
|
2010-03-10 10:43:31 +00:00
|
|
|
}
|
|
|
|
|
2010-03-19 15:45:21 +00:00
|
|
|
/**
|
|
|
|
* gst_vaapi_display_has_image_format:
|
|
|
|
* @display: a #GstVaapiDisplay
|
2013-07-09 12:03:01 +00:00
|
|
|
* @format: a #GstVideoFormat
|
2010-03-19 15:45:21 +00:00
|
|
|
*
|
|
|
|
* Returns whether VA @display supports @format image format.
|
|
|
|
*
|
|
|
|
* Return value: %TRUE if VA @display supports @format image format
|
|
|
|
*/
|
2010-03-04 17:41:34 +00:00
|
|
|
gboolean
|
2013-12-20 12:27:07 +00:00
|
|
|
gst_vaapi_display_has_image_format (GstVaapiDisplay * display,
|
|
|
|
GstVideoFormat format)
|
2010-03-04 17:41:34 +00:00
|
|
|
{
|
2013-12-20 13:01:45 +00:00
|
|
|
GstVaapiDisplayPrivate *priv;
|
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
g_return_val_if_fail (display != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (format, FALSE);
|
2010-03-04 17:41:34 +00:00
|
|
|
|
2013-12-20 13:01:45 +00:00
|
|
|
priv = GST_VAAPI_DISPLAY_GET_PRIVATE (display);
|
|
|
|
|
|
|
|
if (!ensure_image_formats (display))
|
|
|
|
return FALSE;
|
|
|
|
if (find_format (priv->image_formats, format))
|
2013-12-20 12:27:07 +00:00
|
|
|
return TRUE;
|
2011-12-12 12:39:20 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
/* XXX: try subpicture formats since some drivers could report a
|
|
|
|
* set of VA image formats that is not a superset of the set of VA
|
|
|
|
* subpicture formats
|
|
|
|
*/
|
2013-12-20 13:01:45 +00:00
|
|
|
if (!ensure_subpicture_formats (display))
|
|
|
|
return FALSE;
|
|
|
|
return find_format (priv->subpicture_formats, format);
|
2010-03-04 17:41:34 +00:00
|
|
|
}
|
|
|
|
|
2010-03-19 15:45:21 +00:00
|
|
|
/**
|
2013-12-20 14:15:05 +00:00
|
|
|
* gst_vaapi_display_get_subpicture_formats:
|
2010-03-19 15:45:21 +00:00
|
|
|
* @display: a #GstVaapiDisplay
|
|
|
|
*
|
2013-12-20 14:15:05 +00:00
|
|
|
* Gets the supported subpicture formats.
|
2010-03-19 15:45:21 +00:00
|
|
|
*
|
|
|
|
* Note that this method does not necessarily map subpicture formats
|
|
|
|
* returned by vaQuerySubpictureFormats(). The set of capabilities can
|
|
|
|
* be stripped down if gstreamer-vaapi does not support the
|
|
|
|
* format. e.g. this is the case for paletted formats like IA44.
|
|
|
|
*
|
2013-12-20 14:15:05 +00:00
|
|
|
* Note: the caller owns an extra reference to the resulting array of
|
|
|
|
* #GstVideoFormat elements, so it shall be released with
|
|
|
|
* g_array_unref() after usage.
|
|
|
|
*
|
|
|
|
* Return value: a newly allocated #GArray, or %NULL on error of if
|
|
|
|
* the set is empty
|
2010-03-19 15:45:21 +00:00
|
|
|
*/
|
2013-12-20 14:15:05 +00:00
|
|
|
GArray *
|
|
|
|
gst_vaapi_display_get_subpicture_formats (GstVaapiDisplay * display)
|
2010-03-10 10:43:31 +00:00
|
|
|
{
|
2013-12-20 12:27:07 +00:00
|
|
|
g_return_val_if_fail (display != NULL, NULL);
|
2010-03-10 10:43:31 +00:00
|
|
|
|
2013-12-20 13:01:45 +00:00
|
|
|
if (!ensure_subpicture_formats (display))
|
|
|
|
return NULL;
|
2016-02-02 16:59:57 +00:00
|
|
|
return
|
|
|
|
get_formats (GST_VAAPI_DISPLAY_GET_PRIVATE (display)->subpicture_formats);
|
2010-03-10 10:43:31 +00:00
|
|
|
}
|
|
|
|
|
2010-03-19 15:45:21 +00:00
|
|
|
/**
|
|
|
|
* gst_vaapi_display_has_subpicture_format:
|
|
|
|
* @display: a #GstVaapiDisplay
|
2013-07-09 12:03:01 +00:00
|
|
|
* @format: a #GstVideoFormat
|
2013-01-14 10:48:58 +00:00
|
|
|
* @flags_ptr: pointer to #GstVaapiSubpictureFlags, or zero
|
2010-03-19 15:45:21 +00:00
|
|
|
*
|
2012-05-15 08:24:08 +00:00
|
|
|
* Returns whether VA @display supports @format subpicture format with
|
|
|
|
* the supplied @flags.
|
2010-03-19 15:45:21 +00:00
|
|
|
*
|
|
|
|
* Return value: %TRUE if VA @display supports @format subpicture format
|
|
|
|
*/
|
2010-03-04 17:41:34 +00:00
|
|
|
gboolean
|
2013-12-20 12:27:07 +00:00
|
|
|
gst_vaapi_display_has_subpicture_format (GstVaapiDisplay * display,
|
|
|
|
GstVideoFormat format, guint * flags_ptr)
|
2010-03-04 17:41:34 +00:00
|
|
|
{
|
2013-12-20 13:01:45 +00:00
|
|
|
GstVaapiDisplayPrivate *priv;
|
2013-12-20 12:27:07 +00:00
|
|
|
const GstVaapiFormatInfo *fip;
|
2012-05-15 08:24:08 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
g_return_val_if_fail (display != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (format, FALSE);
|
2010-03-04 17:41:34 +00:00
|
|
|
|
2013-12-20 13:01:45 +00:00
|
|
|
priv = GST_VAAPI_DISPLAY_GET_PRIVATE (display);
|
|
|
|
|
|
|
|
if (!ensure_subpicture_formats (display))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
fip = find_format_info (priv->subpicture_formats, format);
|
2013-12-20 12:27:07 +00:00
|
|
|
if (!fip)
|
|
|
|
return FALSE;
|
2012-05-15 08:24:08 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
if (flags_ptr)
|
|
|
|
*flags_ptr = fip->flags;
|
|
|
|
return TRUE;
|
2010-03-04 17:41:34 +00:00
|
|
|
}
|
2012-08-27 14:02:49 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_vaapi_display_has_property:
|
|
|
|
* @display: a #GstVaapiDisplay
|
|
|
|
* @name: the property name to check
|
|
|
|
*
|
|
|
|
* Returns whether VA @display supports the requested property. The
|
|
|
|
* check is performed against the property @name. So, the client
|
|
|
|
* application may perform this check only once and cache this
|
|
|
|
* information.
|
|
|
|
*
|
|
|
|
* Return value: %TRUE if VA @display supports property @name
|
|
|
|
*/
|
|
|
|
gboolean
|
2013-12-20 12:27:07 +00:00
|
|
|
gst_vaapi_display_has_property (GstVaapiDisplay * display, const gchar * name)
|
2012-08-27 14:02:49 +00:00
|
|
|
{
|
2013-12-20 12:27:07 +00:00
|
|
|
g_return_val_if_fail (display != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (name, FALSE);
|
2012-08-27 14:02:49 +00:00
|
|
|
|
2013-12-20 13:01:45 +00:00
|
|
|
if (!ensure_properties (display))
|
|
|
|
return FALSE;
|
2013-12-20 12:27:07 +00:00
|
|
|
return find_property (GST_VAAPI_DISPLAY_GET_PRIVATE (display)->properties,
|
|
|
|
name) != NULL;
|
2013-05-07 09:39:34 +00:00
|
|
|
}
|
|
|
|
|
2012-08-27 15:11:37 +00:00
|
|
|
static gboolean
|
2013-12-20 12:27:07 +00:00
|
|
|
get_attribute (GstVaapiDisplay * display, VADisplayAttribType type,
|
|
|
|
gint * value)
|
2012-08-27 15:11:37 +00:00
|
|
|
{
|
2013-12-20 12:27:07 +00:00
|
|
|
GstVaapiDisplayPrivate *const priv = GST_VAAPI_DISPLAY_GET_PRIVATE (display);
|
2016-03-09 05:13:24 +00:00
|
|
|
VADisplayAttribute attr = { 0, };
|
2013-12-20 12:27:07 +00:00
|
|
|
VAStatus status;
|
2012-08-27 15:11:37 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
attr.type = type;
|
|
|
|
attr.flags = VA_DISPLAY_ATTRIB_GETTABLE;
|
|
|
|
status = vaGetDisplayAttributes (priv->display, &attr, 1);
|
|
|
|
if (!vaapi_check_status (status, "vaGetDisplayAttributes()"))
|
|
|
|
return FALSE;
|
|
|
|
*value = attr.value;
|
|
|
|
return TRUE;
|
2012-08-27 15:11:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2013-12-20 12:27:07 +00:00
|
|
|
set_attribute (GstVaapiDisplay * display, VADisplayAttribType type, gint value)
|
|
|
|
{
|
|
|
|
GstVaapiDisplayPrivate *const priv = GST_VAAPI_DISPLAY_GET_PRIVATE (display);
|
2016-03-09 05:13:24 +00:00
|
|
|
VADisplayAttribute attr = { 0, };
|
2013-12-20 12:27:07 +00:00
|
|
|
VAStatus status;
|
|
|
|
|
|
|
|
attr.type = type;
|
|
|
|
attr.value = value;
|
|
|
|
attr.flags = VA_DISPLAY_ATTRIB_SETTABLE;
|
|
|
|
status = vaSetDisplayAttributes (priv->display, &attr, 1);
|
|
|
|
if (!vaapi_check_status (status, "vaSetDisplayAttributes()"))
|
|
|
|
return FALSE;
|
|
|
|
return TRUE;
|
2012-08-27 15:11:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2013-12-20 12:27:07 +00:00
|
|
|
get_render_mode_VADisplayAttribRenderMode (GstVaapiDisplay * display,
|
|
|
|
GstVaapiRenderMode * pmode)
|
2012-08-27 15:11:37 +00:00
|
|
|
{
|
2013-12-20 12:27:07 +00:00
|
|
|
gint modes, devices;
|
2012-08-27 15:11:37 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
if (!get_attribute (display, VADisplayAttribRenderDevice, &devices))
|
|
|
|
return FALSE;
|
|
|
|
if (!devices)
|
|
|
|
return FALSE;
|
|
|
|
if (!get_attribute (display, VADisplayAttribRenderMode, &modes))
|
|
|
|
return FALSE;
|
2012-08-27 15:11:37 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
/* Favor "overlay" mode since it is the most restrictive one */
|
|
|
|
if (modes & (VA_RENDER_MODE_LOCAL_OVERLAY | VA_RENDER_MODE_EXTERNAL_OVERLAY))
|
|
|
|
*pmode = GST_VAAPI_RENDER_MODE_OVERLAY;
|
|
|
|
else
|
|
|
|
*pmode = GST_VAAPI_RENDER_MODE_TEXTURE;
|
|
|
|
return TRUE;
|
2012-08-27 15:11:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2013-12-20 12:27:07 +00:00
|
|
|
get_render_mode_VADisplayAttribDirectSurface (GstVaapiDisplay * display,
|
|
|
|
GstVaapiRenderMode * pmode)
|
2012-08-27 15:11:37 +00:00
|
|
|
{
|
|
|
|
#if VA_CHECK_VERSION(0,34,0)
|
2013-12-20 12:27:07 +00:00
|
|
|
/* VADisplayAttribDirectsurface was removed in VA-API >= 0.34.0 */
|
|
|
|
return FALSE;
|
2012-08-27 15:11:37 +00:00
|
|
|
#else
|
2013-12-20 12:27:07 +00:00
|
|
|
gint direct_surface;
|
2012-08-27 15:11:37 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
if (!get_attribute (display, VADisplayAttribDirectSurface, &direct_surface))
|
|
|
|
return FALSE;
|
|
|
|
if (direct_surface)
|
|
|
|
*pmode = GST_VAAPI_RENDER_MODE_OVERLAY;
|
|
|
|
else
|
|
|
|
*pmode = GST_VAAPI_RENDER_MODE_TEXTURE;
|
|
|
|
return TRUE;
|
2012-08-27 15:11:37 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2013-12-20 12:27:07 +00:00
|
|
|
get_render_mode_default (GstVaapiDisplay * display, GstVaapiRenderMode * pmode)
|
2012-08-27 15:11:37 +00:00
|
|
|
{
|
2017-09-28 15:35:01 +00:00
|
|
|
switch (GST_VAAPI_DISPLAY_VADISPLAY_TYPE (display)) {
|
2012-08-27 15:11:37 +00:00
|
|
|
#if USE_WAYLAND
|
|
|
|
case GST_VAAPI_DISPLAY_TYPE_WAYLAND:
|
2013-12-20 12:27:07 +00:00
|
|
|
/* wl_buffer mapped from VA surface through vaGetSurfaceBufferWl() */
|
|
|
|
*pmode = GST_VAAPI_RENDER_MODE_OVERLAY;
|
|
|
|
break;
|
2012-08-27 15:11:37 +00:00
|
|
|
#endif
|
|
|
|
#if USE_DRM
|
|
|
|
case GST_VAAPI_DISPLAY_TYPE_DRM:
|
2013-12-20 12:27:07 +00:00
|
|
|
/* vaGetSurfaceBufferDRM() returns the underlying DRM buffer handle */
|
|
|
|
*pmode = GST_VAAPI_RENDER_MODE_OVERLAY;
|
|
|
|
break;
|
2012-08-27 15:11:37 +00:00
|
|
|
#endif
|
|
|
|
default:
|
2013-12-20 12:27:07 +00:00
|
|
|
/* This includes VA/X11 and VA/GLX modes */
|
|
|
|
*pmode = DEFAULT_RENDER_MODE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return TRUE;
|
2012-08-27 15:11:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_vaapi_display_get_render_mode:
|
|
|
|
* @display: a #GstVaapiDisplay
|
|
|
|
* @pmode: return location for the VA @display rendering mode
|
|
|
|
*
|
|
|
|
* Returns the current VA @display rendering mode.
|
|
|
|
*
|
|
|
|
* Return value: %TRUE if VA @display rendering mode could be determined
|
|
|
|
*/
|
|
|
|
gboolean
|
2013-12-20 12:27:07 +00:00
|
|
|
gst_vaapi_display_get_render_mode (GstVaapiDisplay * display,
|
|
|
|
GstVaapiRenderMode * pmode)
|
2012-08-27 15:11:37 +00:00
|
|
|
{
|
2013-12-20 12:27:07 +00:00
|
|
|
g_return_val_if_fail (display != NULL, FALSE);
|
2012-08-27 15:11:37 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
/* Try with render-mode attribute */
|
|
|
|
if (get_render_mode_VADisplayAttribRenderMode (display, pmode))
|
|
|
|
return TRUE;
|
2012-08-27 15:11:37 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
/* Try with direct-surface attribute */
|
|
|
|
if (get_render_mode_VADisplayAttribDirectSurface (display, pmode))
|
|
|
|
return TRUE;
|
2012-08-27 15:11:37 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
/* Default: determine from the display type */
|
|
|
|
return get_render_mode_default (display, pmode);
|
2012-08-27 15:11:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_vaapi_display_set_render_mode:
|
|
|
|
* @display: a #GstVaapiDisplay
|
|
|
|
* @mode: the #GstVaapiRenderMode to set
|
|
|
|
*
|
|
|
|
* Sets the VA @display rendering mode to the supplied @mode. This
|
|
|
|
* function returns %FALSE if the rendering mode could not be set,
|
|
|
|
* e.g. run-time switching rendering mode is not supported.
|
|
|
|
*
|
|
|
|
* Return value: %TRUE if VA @display rendering @mode could be changed
|
|
|
|
* to the requested value
|
|
|
|
*/
|
|
|
|
gboolean
|
2013-12-20 12:27:07 +00:00
|
|
|
gst_vaapi_display_set_render_mode (GstVaapiDisplay * display,
|
|
|
|
GstVaapiRenderMode mode)
|
2012-08-27 15:11:37 +00:00
|
|
|
{
|
2013-12-20 12:27:07 +00:00
|
|
|
gint modes, devices;
|
2012-08-27 15:11:37 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
g_return_val_if_fail (display != NULL, FALSE);
|
2012-08-27 15:11:37 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
if (!get_attribute (display, VADisplayAttribRenderDevice, &devices))
|
|
|
|
return FALSE;
|
2012-08-27 15:11:37 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
modes = 0;
|
|
|
|
switch (mode) {
|
2012-08-27 15:11:37 +00:00
|
|
|
case GST_VAAPI_RENDER_MODE_OVERLAY:
|
2013-12-20 12:27:07 +00:00
|
|
|
if (devices & VA_RENDER_DEVICE_LOCAL)
|
|
|
|
modes |= VA_RENDER_MODE_LOCAL_OVERLAY;
|
|
|
|
if (devices & VA_RENDER_DEVICE_EXTERNAL)
|
|
|
|
modes |= VA_RENDER_MODE_EXTERNAL_OVERLAY;
|
|
|
|
break;
|
2012-08-27 15:11:37 +00:00
|
|
|
case GST_VAAPI_RENDER_MODE_TEXTURE:
|
2013-12-20 12:27:07 +00:00
|
|
|
if (devices & VA_RENDER_DEVICE_LOCAL)
|
|
|
|
modes |= VA_RENDER_MODE_LOCAL_GPU;
|
|
|
|
if (devices & VA_RENDER_DEVICE_EXTERNAL)
|
|
|
|
modes |= VA_RENDER_MODE_EXTERNAL_GPU;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (!modes)
|
|
|
|
return FALSE;
|
|
|
|
if (!set_attribute (display, VADisplayAttribRenderMode, modes))
|
|
|
|
return FALSE;
|
|
|
|
return TRUE;
|
2012-08-27 15:11:37 +00:00
|
|
|
}
|
2012-08-22 06:18:11 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_vaapi_display_get_rotation:
|
|
|
|
* @display: a #GstVaapiDisplay
|
|
|
|
*
|
|
|
|
* Returns the current VA @display rotation angle. If the VA driver
|
|
|
|
* does not support "rotation" display attribute, then the display is
|
|
|
|
* assumed to be un-rotated.
|
|
|
|
*
|
|
|
|
* Return value: the current #GstVaapiRotation value
|
|
|
|
*/
|
|
|
|
GstVaapiRotation
|
2013-12-20 12:27:07 +00:00
|
|
|
gst_vaapi_display_get_rotation (GstVaapiDisplay * display)
|
2012-08-22 06:18:11 +00:00
|
|
|
{
|
2013-12-20 12:27:07 +00:00
|
|
|
gint value;
|
2012-08-22 06:18:11 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
g_return_val_if_fail (display != NULL, DEFAULT_ROTATION);
|
2012-08-22 06:18:11 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
if (!get_attribute (display, VADisplayAttribRotation, &value))
|
|
|
|
value = VA_ROTATION_NONE;
|
|
|
|
return to_GstVaapiRotation (value);
|
2012-08-22 06:18:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_vaapi_display_set_rotation:
|
|
|
|
* @display: a #GstVaapiDisplay
|
|
|
|
* @rotation: the #GstVaapiRotation value to set
|
|
|
|
*
|
|
|
|
* Sets the VA @display rotation angle to the supplied @rotation
|
|
|
|
* value. This function returns %FALSE if the rotation angle could not
|
|
|
|
* be set, e.g. the VA driver does not allow to change the display
|
|
|
|
* rotation angle.
|
|
|
|
*
|
|
|
|
* Return value: %TRUE if VA @display rotation angle could be changed
|
|
|
|
* to the requested value
|
|
|
|
*/
|
|
|
|
gboolean
|
2013-12-20 12:27:07 +00:00
|
|
|
gst_vaapi_display_set_rotation (GstVaapiDisplay * display,
|
|
|
|
GstVaapiRotation rotation)
|
2012-08-22 06:18:11 +00:00
|
|
|
{
|
2013-12-20 12:27:07 +00:00
|
|
|
guint value;
|
2012-08-22 06:18:11 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
g_return_val_if_fail (display != NULL, FALSE);
|
2012-08-22 06:18:11 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
value = from_GstVaapiRotation (rotation);
|
|
|
|
if (!set_attribute (display, VADisplayAttribRotation, value))
|
|
|
|
return FALSE;
|
|
|
|
return TRUE;
|
2012-08-22 06:18:11 +00:00
|
|
|
}
|
2012-08-28 11:59:50 +00:00
|
|
|
|
|
|
|
/* Get color balance attributes */
|
|
|
|
static gboolean
|
2013-12-20 12:27:07 +00:00
|
|
|
get_color_balance (GstVaapiDisplay * display, guint prop_id, gfloat * v)
|
2012-08-28 11:59:50 +00:00
|
|
|
{
|
2013-12-20 12:27:07 +00:00
|
|
|
GParamSpecFloat *const pspec = G_PARAM_SPEC_FLOAT (g_properties[prop_id]);
|
|
|
|
const GstVaapiProperty *prop;
|
|
|
|
const VADisplayAttribute *attr;
|
|
|
|
gfloat out_value;
|
|
|
|
gint value;
|
2012-08-28 11:59:50 +00:00
|
|
|
|
2013-12-20 13:01:45 +00:00
|
|
|
if (!ensure_properties (display))
|
|
|
|
return FALSE;
|
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
if (!pspec)
|
|
|
|
return FALSE;
|
2012-08-28 11:59:50 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
prop = find_property_by_pspec (display, &pspec->parent_instance);
|
|
|
|
if (!prop)
|
|
|
|
return FALSE;
|
|
|
|
attr = &prop->attribute;
|
2012-08-28 11:59:50 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
if (!get_attribute (display, attr->type, &value))
|
|
|
|
return FALSE;
|
2012-08-28 11:59:50 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
/* Scale wrt. the medium ("default") value */
|
|
|
|
out_value = pspec->default_value;
|
|
|
|
if (value > attr->value)
|
|
|
|
out_value += ((gfloat) (value - attr->value) /
|
|
|
|
(attr->max_value - attr->value) *
|
|
|
|
(pspec->maximum - pspec->default_value));
|
|
|
|
else if (value < attr->value)
|
|
|
|
out_value -= ((gfloat) (attr->value - value) /
|
|
|
|
(attr->value - attr->min_value) *
|
|
|
|
(pspec->default_value - pspec->minimum));
|
|
|
|
*v = out_value;
|
|
|
|
return TRUE;
|
2012-08-28 11:59:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Set color balance attribute */
|
|
|
|
static gboolean
|
2013-12-20 12:27:07 +00:00
|
|
|
set_color_balance (GstVaapiDisplay * display, guint prop_id, gfloat v)
|
2012-08-28 11:59:50 +00:00
|
|
|
{
|
2013-12-20 12:27:07 +00:00
|
|
|
GParamSpecFloat *const pspec = G_PARAM_SPEC_FLOAT (g_properties[prop_id]);
|
|
|
|
const GstVaapiProperty *prop;
|
|
|
|
const VADisplayAttribute *attr;
|
|
|
|
gint value;
|
2012-08-28 11:59:50 +00:00
|
|
|
|
2013-12-20 13:01:45 +00:00
|
|
|
if (!ensure_properties (display))
|
|
|
|
return FALSE;
|
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
if (!pspec)
|
|
|
|
return FALSE;
|
2012-08-28 11:59:50 +00:00
|
|
|
|
2013-12-20 12:27:07 +00:00
|
|
|
prop = find_property_by_pspec (display, &pspec->parent_instance);
|
|
|
|
if (!prop)
|
|
|
|
return FALSE;
|
|
|
|
attr = &prop->attribute;
|
|
|
|
|
|
|
|
/* Scale wrt. the medium ("default") value */
|
|
|
|
value = attr->value;
|
|
|
|
if (v > pspec->default_value)
|
|
|
|
value += ((v - pspec->default_value) /
|
|
|
|
(pspec->maximum - pspec->default_value) *
|
|
|
|
(attr->max_value - attr->value));
|
|
|
|
else if (v < pspec->default_value)
|
|
|
|
value -= ((pspec->default_value - v) /
|
|
|
|
(pspec->default_value - pspec->minimum) *
|
|
|
|
(attr->value - attr->min_value));
|
|
|
|
if (!set_attribute (display, attr->type, value))
|
|
|
|
return FALSE;
|
|
|
|
return TRUE;
|
2012-08-28 11:59:50 +00:00
|
|
|
}
|
2014-05-20 09:36:40 +00:00
|
|
|
|
|
|
|
/* Ensures the VA driver vendor string was copied */
|
|
|
|
static gboolean
|
|
|
|
ensure_vendor_string (GstVaapiDisplay * display)
|
|
|
|
{
|
|
|
|
GstVaapiDisplayPrivate *const priv = GST_VAAPI_DISPLAY_GET_PRIVATE (display);
|
|
|
|
const gchar *vendor_string;
|
|
|
|
|
|
|
|
GST_VAAPI_DISPLAY_LOCK (display);
|
|
|
|
if (!priv->vendor_string) {
|
|
|
|
vendor_string = vaQueryVendorString (priv->display);
|
|
|
|
if (vendor_string)
|
|
|
|
priv->vendor_string = g_strdup (vendor_string);
|
|
|
|
}
|
|
|
|
GST_VAAPI_DISPLAY_UNLOCK (display);
|
|
|
|
return priv->vendor_string != NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_vaapi_display_get_vendor_string:
|
|
|
|
* @display: a #GstVaapiDisplay
|
|
|
|
*
|
|
|
|
* Returns the VA driver vendor string attached to the supplied VA @display.
|
|
|
|
* The @display owns the vendor string, do *not* de-allocate it.
|
|
|
|
*
|
|
|
|
* This function is thread safe.
|
|
|
|
*
|
|
|
|
* Return value: the current #GstVaapiRotation value
|
|
|
|
*/
|
|
|
|
const gchar *
|
|
|
|
gst_vaapi_display_get_vendor_string (GstVaapiDisplay * display)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (display != NULL, NULL);
|
|
|
|
|
|
|
|
if (!ensure_vendor_string (display))
|
|
|
|
return NULL;
|
2016-10-13 03:53:17 +00:00
|
|
|
return GST_VAAPI_DISPLAY_GET_PRIVATE (display)->vendor_string;
|
2014-05-20 09:36:40 +00:00
|
|
|
}
|
2014-12-03 10:39:24 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_vaapi_display_has_opengl:
|
|
|
|
* @display: a #GstVaapiDisplay
|
|
|
|
*
|
|
|
|
* Returns wether the @display that was created does support OpenGL
|
|
|
|
* context to be attached.
|
|
|
|
*
|
|
|
|
* This function is thread safe.
|
|
|
|
*
|
|
|
|
* Return value: %TRUE if the @display supports OpenGL context, %FALSE
|
|
|
|
* otherwise
|
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
gst_vaapi_display_has_opengl (GstVaapiDisplay * display)
|
|
|
|
{
|
|
|
|
GstVaapiDisplayClass *klass;
|
|
|
|
|
2015-02-18 09:46:11 +00:00
|
|
|
g_return_val_if_fail (display != NULL, FALSE);
|
2014-12-03 10:39:24 +00:00
|
|
|
|
|
|
|
klass = GST_VAAPI_DISPLAY_GET_CLASS (display);
|
2015-02-20 14:27:53 +00:00
|
|
|
return (klass->display_type == GST_VAAPI_DISPLAY_TYPE_GLX ||
|
2016-02-02 16:59:57 +00:00
|
|
|
klass->display_type == GST_VAAPI_DISPLAY_TYPE_EGL);
|
2014-12-03 10:39:24 +00:00
|
|
|
}
|
2016-09-22 07:34:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_vaapi_display_reset_texture_map:
|
|
|
|
* @display: a #GstVaapiDisplay
|
|
|
|
*
|
|
|
|
* Reset the internal #GstVaapiTextureMap if available.
|
|
|
|
*
|
|
|
|
* This function is thread safe.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_vaapi_display_reset_texture_map (GstVaapiDisplay * display)
|
|
|
|
{
|
|
|
|
GstVaapiDisplayClass *klass;
|
|
|
|
GstVaapiTextureMap *map;
|
|
|
|
|
|
|
|
g_return_if_fail (display != NULL);
|
|
|
|
|
|
|
|
if (!gst_vaapi_display_has_opengl (display))
|
|
|
|
return;
|
|
|
|
klass = GST_VAAPI_DISPLAY_GET_CLASS (display);
|
|
|
|
if (!klass->get_texture_map)
|
|
|
|
return;
|
|
|
|
if ((map = klass->get_texture_map (display)))
|
|
|
|
gst_vaapi_texture_map_reset (map);
|
|
|
|
}
|