2 * gstvaapipluginutil.h - VA-API plugins private helper
4 * Copyright (C) 2011-2014 Intel Corporation
5 * Author: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
6 * Copyright (C) 2011 Collabora
7 * Author: Nicolas Dufresne <nicolas.dufresne@collabora.co.uk>
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public License
11 * as published by the Free Software Foundation; either version 2.1
12 * of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free
21 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22 * Boston, MA 02110-1301 USA
25 #ifndef GST_VAAPI_PLUGIN_UTIL_H
26 #define GST_VAAPI_PLUGIN_UTIL_H
28 #include <gst/vaapi/gstvaapidisplay.h>
29 #include <gst/vaapi/gstvaapisurface.h>
30 #include <gst/vaapi/gstvaapicontext.h>
31 #include "gstvaapivideomemory.h"
33 typedef GstVaapiProfile (*GstVaapiStrToProfileFunc) (const gchar * str);
34 typedef const gchar * (*GstVaapiProfileToStrFunc) (GstVaapiProfile profile);
38 gst_vaapi_ensure_display (GstElement * element, GstVaapiDisplayType type);
42 gst_vaapi_handle_context_query (GstElement * element, GstQuery * query);
46 gst_vaapi_append_surface_caps (GstCaps * out_caps, GstCaps * in_caps);
50 gst_vaapi_apply_composition (GstVaapiSurface * surface, GstBuffer * buffer);
52 #ifndef G_PRIMITIVE_SWAP
53 #define G_PRIMITIVE_SWAP(type, a, b) do { \
54 const type t = a; a = b; b = t; \
58 /* Helpers for GValue construction for video formats */
61 gst_vaapi_value_set_format (GValue * value, GstVideoFormat format);
65 gst_vaapi_value_set_format_list (GValue * value, GArray * formats);
67 /* Helpers to build video caps */
70 GST_VAAPI_CAPS_FEATURE_NOT_NEGOTIATED,
71 GST_VAAPI_CAPS_FEATURE_SYSTEM_MEMORY,
72 GST_VAAPI_CAPS_FEATURE_GL_TEXTURE_UPLOAD_META,
73 GST_VAAPI_CAPS_FEATURE_DMABUF,
74 GST_VAAPI_CAPS_FEATURE_VAAPI_SURFACE,
75 } GstVaapiCapsFeature;
79 gst_vaapi_video_format_new_template_caps (GstVideoFormat format);
83 gst_vaapi_video_format_new_template_caps_from_list (GArray * formats);
87 gst_vaapi_video_format_new_template_caps_with_features (GstVideoFormat format,
88 const gchar * features_string);
92 gst_vaapi_find_preferred_caps_feature (GstPad * pad, GstCaps * allowed_caps,
93 GstVideoFormat * out_format_ptr);
97 gst_vaapi_caps_feature_to_string (GstVaapiCapsFeature feature);
101 gst_vaapi_caps_feature_contains (const GstCaps * caps,
102 GstVaapiCapsFeature feature);
104 /* Helpers to handle interlaced contents */
105 # define GST_CAPS_INTERLACED_MODES \
106 "interlace-mode = (string){ progressive, interleaved, mixed }"
107 # define GST_CAPS_INTERLACED_FALSE \
108 "interlace-mode = (string)progressive"
110 #define GST_VAAPI_MAKE_SURFACE_CAPS \
111 GST_VIDEO_CAPS_MAKE_WITH_FEATURES( \
112 GST_CAPS_FEATURE_MEMORY_VAAPI_SURFACE, GST_VAAPI_FORMATS_ALL)
114 #define GST_VAAPI_MAKE_GLTEXUPLOAD_CAPS \
115 GST_VIDEO_CAPS_MAKE_WITH_FEATURES( \
116 GST_CAPS_FEATURE_META_GST_VIDEO_GL_TEXTURE_UPLOAD_META, "{ RGBA, BGRA }")
118 #define GST_VAAPI_MAKE_DMABUF_CAPS \
119 GST_VIDEO_CAPS_MAKE_WITH_FEATURES( \
120 GST_CAPS_FEATURE_MEMORY_DMABUF, "{ I420, YV12, RGBA }")
124 gst_caps_set_interlaced (GstCaps * caps, GstVideoInfo * vip);
128 gst_caps_has_vaapi_surface (GstCaps * caps);
132 gst_caps_is_video_raw (GstCaps * caps);
136 gst_video_info_change_format (GstVideoInfo * vip, GstVideoFormat format,
137 guint width, guint height);
141 gst_video_info_changed (const GstVideoInfo * old, const GstVideoInfo * new);
145 gst_video_info_force_nv12_if_encoded (GstVideoInfo * vinfo);
149 gst_vaapi_create_test_display (void);
153 gst_vaapi_driver_is_whitelisted (GstVaapiDisplay * display);
157 gst_vaapi_codecs_has_codec (GArray * codecs, GstVaapiCodec codec);
161 gst_vaapi_encoder_get_profiles_from_caps (GstCaps * caps,
162 GstVaapiStrToProfileFunc func);
166 gst_vaapi_caps_set_width_and_height_range (GstCaps * caps, gint min_width,
167 gint min_height, gint max_width, gint max_height);
171 gst_vaapi_build_caps_from_formats (GArray * formats, gint min_width,
172 gint min_height, gint max_width, gint max_height, guint mem_type);
176 gst_vaapi_build_template_raw_caps_by_codec (GstVaapiDisplay * display,
177 GstVaapiContextUsage usage, GstVaapiCodec codec, GArray * extra_fmts);
181 gst_vaapi_structure_set_profiles (GstStructure * st, gchar ** list);
185 gst_vaapi_build_template_coded_caps_by_codec (GstVaapiDisplay * display,
186 GstVaapiContextUsage usage, GstVaapiCodec codec, const char *caps_str,
187 GstVaapiProfileToStrFunc func);
189 #endif /* GST_VAAPI_PLUGIN_UTIL_H */