vaapidecodebin: ensure VPP before going to READY
[platform/upstream/gstreamer.git] / gst / vaapi / gstvaapipluginutil.h
1 /*
2  *  gstvaapipluginutil.h - VA-API plugins private helper
3  *
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>
8  *
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.
13  *
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.
18  *
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
23  */
24
25 #ifndef GST_VAAPI_PLUGIN_UTIL_H
26 #define GST_VAAPI_PLUGIN_UTIL_H
27
28 #include <gst/vaapi/gstvaapidisplay.h>
29 #include <gst/vaapi/gstvaapisurface.h>
30 #include "gstvaapivideomemory.h"
31
32 G_GNUC_INTERNAL
33 gboolean
34 gst_vaapi_ensure_display (GstElement * element, GstVaapiDisplayType type);
35
36 G_GNUC_INTERNAL
37 gboolean
38 gst_vaapi_reply_to_query (GstQuery * query, GstVaapiDisplay * display);
39
40 G_GNUC_INTERNAL
41 gboolean
42 gst_vaapi_append_surface_caps (GstCaps * out_caps, GstCaps * in_caps);
43
44 G_GNUC_INTERNAL
45 gboolean
46 gst_vaapi_apply_composition (GstVaapiSurface * surface, GstBuffer * buffer);
47
48 #ifndef G_PRIMITIVE_SWAP
49 #define G_PRIMITIVE_SWAP(type, a, b) do {       \
50         const type t = a; a = b; b = t;         \
51     } while (0)
52 #endif
53
54 /* Helpers for GValue construction for video formats */
55 G_GNUC_INTERNAL
56 gboolean
57 gst_vaapi_value_set_format (GValue * value, GstVideoFormat format);
58
59 G_GNUC_INTERNAL
60 gboolean
61 gst_vaapi_value_set_format_list (GValue * value, GArray * formats);
62
63 /* Helpers to build video caps */
64 typedef enum
65 {
66   GST_VAAPI_CAPS_FEATURE_NOT_NEGOTIATED,
67   GST_VAAPI_CAPS_FEATURE_SYSTEM_MEMORY,
68   GST_VAAPI_CAPS_FEATURE_GL_TEXTURE_UPLOAD_META,
69   GST_VAAPI_CAPS_FEATURE_VAAPI_SURFACE,
70 } GstVaapiCapsFeature;
71
72 G_GNUC_INTERNAL
73 GstCaps *
74 gst_vaapi_video_format_new_template_caps (GstVideoFormat format);
75
76 G_GNUC_INTERNAL
77 GstCaps *
78 gst_vaapi_video_format_new_template_caps_from_list (GArray * formats);
79
80 G_GNUC_INTERNAL
81 GstCaps *
82 gst_vaapi_video_format_new_template_caps_with_features (GstVideoFormat format,
83     const gchar * features_string);
84
85 G_GNUC_INTERNAL
86 GstVaapiCapsFeature
87 gst_vaapi_find_preferred_caps_feature (GstPad * pad, GstVideoFormat format,
88     GstVideoFormat * out_format_ptr);
89
90 G_GNUC_INTERNAL
91 const gchar *
92 gst_vaapi_caps_feature_to_string (GstVaapiCapsFeature feature);
93
94 /* Helpers to handle interlaced contents */
95 # define GST_CAPS_INTERLACED_MODES \
96     "interlace-mode = (string){ progressive, interleaved, mixed }"
97 # define GST_CAPS_INTERLACED_FALSE \
98     "interlace-mode = (string)progressive"
99
100 #define GST_VAAPI_MAKE_SURFACE_CAPS                                     \
101     GST_VIDEO_CAPS_MAKE_WITH_FEATURES(                                  \
102         GST_CAPS_FEATURE_MEMORY_VAAPI_SURFACE, "{ ENCODED, I420, YV12, NV12 }")
103
104 #define GST_VAAPI_MAKE_ENC_SURFACE_CAPS                         \
105     GST_VIDEO_CAPS_MAKE_WITH_FEATURES(                                  \
106         GST_CAPS_FEATURE_MEMORY_VAAPI_SURFACE, "{ ENCODED, NV12, I420, YV12 }")
107
108 #define GST_VAAPI_MAKE_GLTEXUPLOAD_CAPS                         \
109     GST_VIDEO_CAPS_MAKE_WITH_FEATURES(                                  \
110         GST_CAPS_FEATURE_META_GST_VIDEO_GL_TEXTURE_UPLOAD_META, "{ RGBA, BGRA }")
111
112 G_GNUC_INTERNAL
113 gboolean
114 gst_caps_set_interlaced (GstCaps * caps, GstVideoInfo * vip);
115
116 G_GNUC_INTERNAL
117 gboolean
118 gst_caps_has_vaapi_surface (GstCaps * caps);
119
120 G_GNUC_INTERNAL
121 void
122 gst_video_info_change_format (GstVideoInfo * vip, GstVideoFormat format,
123     guint width, guint height);
124
125 G_GNUC_INTERNAL
126 GstVaapiDisplay *
127 gst_vaapi_create_test_display (void);
128
129 #endif /* GST_VAAPI_PLUGIN_UTIL_H */