2010-05-12 07:57:55 +00:00
|
|
|
/*
|
2011-11-04 20:50:15 +00:00
|
|
|
* gstvaapipluginutil.h - VA-API plugins private helper
|
2010-05-12 07:57:55 +00:00
|
|
|
*
|
2014-01-22 17:54:14 +00:00
|
|
|
* Copyright (C) 2011-2014 Intel Corporation
|
2013-11-22 04:57:18 +00:00
|
|
|
* Author: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
|
2011-11-04 20:50:15 +00:00
|
|
|
* Copyright (C) 2011 Collabora
|
|
|
|
* Author: Nicolas Dufresne <nicolas.dufresne@collabora.co.uk>
|
2010-05-12 07:57:55 +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.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
2012-07-23 15:49:08 +00:00
|
|
|
#ifndef GST_VAAPI_PLUGIN_UTIL_H
|
|
|
|
#define GST_VAAPI_PLUGIN_UTIL_H
|
|
|
|
|
2010-05-12 07:57:55 +00:00
|
|
|
#include <gst/vaapi/gstvaapidisplay.h>
|
2013-03-21 15:32:43 +00:00
|
|
|
#include <gst/vaapi/gstvaapisurface.h>
|
2014-01-14 18:08:36 +00:00
|
|
|
#include "gstvaapivideomemory.h"
|
2010-05-12 07:57:55 +00:00
|
|
|
|
2012-07-24 14:14:51 +00:00
|
|
|
G_GNUC_INTERNAL
|
2012-07-23 16:01:26 +00:00
|
|
|
gboolean
|
2015-05-08 13:54:09 +00:00
|
|
|
gst_vaapi_ensure_display (GstElement * element, GstVaapiDisplayType type);
|
2012-07-23 16:01:26 +00:00
|
|
|
|
2012-07-24 14:14:51 +00:00
|
|
|
G_GNUC_INTERNAL
|
2012-07-23 16:01:26 +00:00
|
|
|
gboolean
|
2015-11-04 20:38:42 +00:00
|
|
|
gst_vaapi_handle_context_query (GstQuery * query, GstVaapiDisplay * display);
|
2012-01-05 10:00:39 +00:00
|
|
|
|
2012-07-24 14:14:51 +00:00
|
|
|
G_GNUC_INTERNAL
|
2012-01-05 10:00:39 +00:00
|
|
|
gboolean
|
2013-12-21 05:22:30 +00:00
|
|
|
gst_vaapi_append_surface_caps (GstCaps * out_caps, GstCaps * in_caps);
|
2012-07-23 15:49:08 +00:00
|
|
|
|
2013-03-21 15:32:43 +00:00
|
|
|
G_GNUC_INTERNAL
|
|
|
|
gboolean
|
2013-12-21 05:22:30 +00:00
|
|
|
gst_vaapi_apply_composition (GstVaapiSurface * surface, GstBuffer * buffer);
|
2013-03-21 15:32:43 +00:00
|
|
|
|
2012-09-06 09:47:40 +00:00
|
|
|
#ifndef G_PRIMITIVE_SWAP
|
|
|
|
#define G_PRIMITIVE_SWAP(type, a, b) do { \
|
|
|
|
const type t = a; a = b; b = t; \
|
|
|
|
} while (0)
|
|
|
|
#endif
|
|
|
|
|
2013-12-21 05:41:34 +00:00
|
|
|
/* Helpers for GValue construction for video formats */
|
|
|
|
G_GNUC_INTERNAL
|
|
|
|
gboolean
|
|
|
|
gst_vaapi_value_set_format (GValue * value, GstVideoFormat format);
|
|
|
|
|
|
|
|
G_GNUC_INTERNAL
|
|
|
|
gboolean
|
|
|
|
gst_vaapi_value_set_format_list (GValue * value, GArray * formats);
|
|
|
|
|
2013-12-21 09:41:22 +00:00
|
|
|
/* Helpers to build video caps */
|
2014-01-14 18:08:36 +00:00
|
|
|
typedef enum
|
|
|
|
{
|
vaapidecode: delayed src caps negotiation
Currently the src caps are set immediately after the sink caps are set, but in
that moment the pipeline might not fully constructed and the video sink has
not negotiated its supported caps and features. As a consequence, in many cases
of playback, the least optimized caps feature is forced. This is partially the
responsible of bug #744039.
Also, vaapidecode doesn't attend the reconfigure events from downstream,
which is a problem too, since the video sink can be changed with different
caps features.
This patch delays the src caps, setting them until the first frame arrives to
the decoder, assuming until that very moment the whole pipeline is already
negotiated. Particularly, it checks if the src pad needs to be reconfigured,
as a consequence of a reconfiguration event from downstream.
A key part of this patch is the new GstVaapiCapsFeature
GST_VAAPI_CAPS_FEATURE_NOT_NEGOTIATED, which is returned when the src pad
doesn't have a peer yet. Also, for a better report of the caps allowed
through the src pad and its peer, this patch uses gst_pad_get_allowed_caps()
instead of gst_pad_peer_query_caps() when looking for the preferred feature.
v3: move the input_state unref to close(), since videodecoder resets at
some events such as navigation.
v4: a) the state_changed() callback replaces the input_state if the media
changed, so this case is also handled.
b) since the parameter ref_state in gst_vaapidecode_update_src_caps() is
always the input_state, the parameter were removed.
c) there were a lot of repeated code handling the input_state, so I
refactored it with the function gst_vaapi_decode_input_state_replace().
https://bugzilla.gnome.org/show_bug.cgi?id=744618
Signed-off-by: Víctor Manuel Jáquez Leal <victorx.jaquez@intel.com>
Signed-off-by: Sreerenj Balachandran <sreerenj.balachandran@intel.com>
2015-02-26 10:24:55 +00:00
|
|
|
GST_VAAPI_CAPS_FEATURE_NOT_NEGOTIATED,
|
|
|
|
GST_VAAPI_CAPS_FEATURE_SYSTEM_MEMORY,
|
2014-01-14 18:08:36 +00:00
|
|
|
GST_VAAPI_CAPS_FEATURE_GL_TEXTURE_UPLOAD_META,
|
|
|
|
GST_VAAPI_CAPS_FEATURE_VAAPI_SURFACE,
|
|
|
|
} GstVaapiCapsFeature;
|
|
|
|
|
2013-12-21 09:41:22 +00:00
|
|
|
G_GNUC_INTERNAL
|
|
|
|
GstCaps *
|
|
|
|
gst_vaapi_video_format_new_template_caps (GstVideoFormat format);
|
|
|
|
|
|
|
|
G_GNUC_INTERNAL
|
|
|
|
GstCaps *
|
|
|
|
gst_vaapi_video_format_new_template_caps_from_list (GArray * formats);
|
|
|
|
|
2014-01-14 18:08:36 +00:00
|
|
|
G_GNUC_INTERNAL
|
|
|
|
GstCaps *
|
|
|
|
gst_vaapi_video_format_new_template_caps_with_features (GstVideoFormat format,
|
|
|
|
const gchar * features_string);
|
|
|
|
|
|
|
|
G_GNUC_INTERNAL
|
|
|
|
GstVaapiCapsFeature
|
2016-03-29 12:17:54 +00:00
|
|
|
gst_vaapi_find_preferred_caps_feature (GstPad * pad, GstCaps * allowed_caps,
|
2015-02-09 20:09:07 +00:00
|
|
|
GstVideoFormat * out_format_ptr);
|
2014-01-14 18:08:36 +00:00
|
|
|
|
2014-08-22 13:22:32 +00:00
|
|
|
G_GNUC_INTERNAL
|
|
|
|
const gchar *
|
|
|
|
gst_vaapi_caps_feature_to_string (GstVaapiCapsFeature feature);
|
|
|
|
|
2015-10-14 18:30:30 +00:00
|
|
|
G_GNUC_INTERNAL
|
|
|
|
gboolean
|
|
|
|
gst_vaapi_caps_feature_contains (const GstCaps * caps,
|
|
|
|
GstVaapiCapsFeature feature);
|
|
|
|
|
2013-04-17 08:18:45 +00:00
|
|
|
/* Helpers to handle interlaced contents */
|
|
|
|
# define GST_CAPS_INTERLACED_MODES \
|
2013-10-04 14:00:56 +00:00
|
|
|
"interlace-mode = (string){ progressive, interleaved, mixed }"
|
2013-04-17 08:18:45 +00:00
|
|
|
# define GST_CAPS_INTERLACED_FALSE \
|
|
|
|
"interlace-mode = (string)progressive"
|
|
|
|
|
2015-08-05 12:11:12 +00:00
|
|
|
#define GST_VAAPI_MAKE_SURFACE_CAPS \
|
|
|
|
GST_VIDEO_CAPS_MAKE_WITH_FEATURES( \
|
2016-03-29 12:02:46 +00:00
|
|
|
GST_CAPS_FEATURE_MEMORY_VAAPI_SURFACE, "{ ENCODED, NV12, I420, YV12, P010_10LE }")
|
2015-08-05 12:11:12 +00:00
|
|
|
|
|
|
|
#define GST_VAAPI_MAKE_GLTEXUPLOAD_CAPS \
|
|
|
|
GST_VIDEO_CAPS_MAKE_WITH_FEATURES( \
|
|
|
|
GST_CAPS_FEATURE_META_GST_VIDEO_GL_TEXTURE_UPLOAD_META, "{ RGBA, BGRA }")
|
|
|
|
|
2013-10-04 17:30:36 +00:00
|
|
|
G_GNUC_INTERNAL
|
|
|
|
gboolean
|
2013-12-21 05:22:30 +00:00
|
|
|
gst_caps_set_interlaced (GstCaps * caps, GstVideoInfo * vip);
|
2013-10-04 17:30:36 +00:00
|
|
|
|
2014-08-20 09:30:41 +00:00
|
|
|
G_GNUC_INTERNAL
|
|
|
|
gboolean
|
|
|
|
gst_caps_has_vaapi_surface (GstCaps * caps);
|
|
|
|
|
2014-11-18 13:57:02 +00:00
|
|
|
G_GNUC_INTERNAL
|
|
|
|
void
|
|
|
|
gst_video_info_change_format (GstVideoInfo * vip, GstVideoFormat format,
|
|
|
|
guint width, guint height);
|
|
|
|
|
2016-05-20 12:15:53 +00:00
|
|
|
G_GNUC_INTERNAL
|
|
|
|
gboolean
|
|
|
|
gst_video_info_changed (GstVideoInfo * old, GstVideoInfo * new);
|
|
|
|
|
2016-05-23 13:38:07 +00:00
|
|
|
G_GNUC_INTERNAL
|
|
|
|
void
|
|
|
|
gst_video_info_force_nv12_if_encoded (GstVideoInfo * vinfo);
|
|
|
|
|
2015-08-06 16:48:13 +00:00
|
|
|
G_GNUC_INTERNAL
|
|
|
|
GstVaapiDisplay *
|
|
|
|
gst_vaapi_create_test_display (void);
|
|
|
|
|
2016-06-28 15:14:06 +00:00
|
|
|
G_GNUC_INTERNAL
|
|
|
|
gboolean
|
|
|
|
gst_vaapi_driver_is_whitelisted (GstVaapiDisplay * display);
|
|
|
|
|
2012-07-23 15:49:08 +00:00
|
|
|
#endif /* GST_VAAPI_PLUGIN_UTIL_H */
|