1/*
2 * GStreamer
3 * Copyright (C) 2012 Matthew Waters <ystree00@gmail.com>
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
14 *
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19 */
20
21#ifndef __GST_GL_COLOR_CONVERT_H__
22#define __GST_GL_COLOR_CONVERT_H__
23
24#include <gst/video/video.h>
25#include <gst/gstmemory.h>
26
27#include <gst/gl/gstgl_fwd.h>
28
29G_BEGIN_DECLS
30
31GST_GL_API
32GType gst_gl_color_convert_get_type (void);
33#define GST_TYPE_GL_COLOR_CONVERT (gst_gl_color_convert_get_type())
34#define GST_GL_COLOR_CONVERT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_GL_COLOR_CONVERT,GstGLColorConvert))
35#define GST_GL_COLOR_CONVERT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_GL_DISPLAY,GstGLColorConvertClass))
36#define GST_IS_GL_COLOR_CONVERT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_GL_COLOR_CONVERT))
37#define GST_IS_GL_COLOR_CONVERT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_GL_COLOR_CONVERT))
38#define GST_GL_COLOR_CONVERT_CAST(obj) ((GstGLColorConvert*)(obj))
39
40/**
41 * GstGLColorConvert
42 *
43 * Opaque #GstGLColorConvert object
44 */
45struct _GstGLColorConvert
46{
47 /*< private >*/
48 GstObject parent;
49
50 GstGLContext *context;
51
52 /* input data */
53 GstVideoInfo in_info;
54 GstVideoInfo out_info;
55
56 gboolean initted;
57 gboolean passthrough;
58
59 GstBuffer * inbuf;
60 GstBuffer * outbuf;
61
62 /* used for the conversion */
63 GstGLFramebuffer *fbo;
64 GstGLShader *shader;
65
66 /*< private >*/
67 GstGLColorConvertPrivate *priv;
68
69 gpointer _reserved[GST_PADDING];
70};
71
72/**
73 * GstGLColorConvertClass:
74 *
75 * The #GstGLColorConvertClass struct only contains private data
76 */
77struct _GstGLColorConvertClass
78{
79 /*< private >*/
80 GstObjectClass object_class;
81
82 gpointer _padding[GST_PADDING];
83};
84
85/**
86 * GST_GL_COLOR_CONVERT_EXT_FORMATS: (skip)
87 *
88 */
89#if G_BYTE_ORDER == G_LITTLE_ENDIAN
90#define GST_GL_COLOR_CONVERT_EXT_FORMATS \
91 ", RGBA64_LE, BGR10A2_LE, RGB10A2_LE, P010_10LE, P012_LE, P016_LE, Y212_LE, Y412_LE" \
92 ", A444_16LE, A422_16LE, A420_16LE, A444_12LE, A422_12LE, A420_12LE, A420_10LE" \
93 ", A422_10LE, A444_10LE, I420_12LE, I420_10LE"
94#else
95#define GST_GL_COLOR_CONVERT_EXT_FORMATS \
96 ", RGBA64_BE, P010_10BE, P012_BE, P016_BE, Y212_BE, Y412_BE" \
97 ", A444_16BE, A422_16BE, A420_16BE, A444_12BE, A422_12BE, A420_12BE, A420_10BE" \
98 ", A422_10BE, A444_10BE, I420_12BE, I420_10BE"
99#endif
100
101/**
102 * GST_GL_COLOR_CONVERT_FORMATS:
103 *
104 * The currently supported formats that can be converted
105 */
106#define GST_GL_COLOR_CONVERT_FORMATS "{ RGBA, RGB, RGBx, BGR, BGRx, BGRA, xRGB, " \
107 "xBGR, ARGB, ABGR, GBRA, GBR, RGBP, BGRP, Y444, I420, YV12, Y42B, " \
108 "Y41B, NV12, NV21, NV16, NV61, YUY2, UYVY, Y210, AYUV, " \
109 "VUYA, Y410, A444, A422, GRAY8, GRAY16_LE, GRAY16_BE, " \
110 "RGB16, BGR16, ARGB64, A420, AV12, NV12_16L32S, NV12_4L4, RBGA" \
111 GST_GL_COLOR_CONVERT_EXT_FORMATS "}"
112
113/**
114 * GST_GL_COLOR_CONVERT_VIDEO_CAPS:
115 *
116 * The currently supported #GstCaps that can be converted
117 */
118#define GST_GL_COLOR_CONVERT_VIDEO_CAPS \
119 "video/x-raw(" GST_CAPS_FEATURE_MEMORY_GL_MEMORY "), " \
120 "format = (string) " GST_GL_COLOR_CONVERT_FORMATS ", " \
121 "width = " GST_VIDEO_SIZE_RANGE ", " \
122 "height = " GST_VIDEO_SIZE_RANGE ", " \
123 "framerate = " GST_VIDEO_FPS_RANGE ", " \
124 "texture-target = (string) { 2D, rectangle, external-oes } " \
125 " ; " \
126 "video/x-raw(" GST_CAPS_FEATURE_MEMORY_GL_MEMORY "," \
127 GST_CAPS_FEATURE_META_GST_VIDEO_OVERLAY_COMPOSITION "), " \
128 "format = (string) " GST_GL_COLOR_CONVERT_FORMATS ", " \
129 "width = " GST_VIDEO_SIZE_RANGE ", " \
130 "height = " GST_VIDEO_SIZE_RANGE ", " \
131 "framerate = " GST_VIDEO_FPS_RANGE ", " \
132 "texture-target = (string) { 2D, rectangle, external-oes }" \
133 " ; " \
134 GST_VIDEO_DMA_DRM_CAPS_MAKE
135
136GST_GL_API
137GstGLColorConvert * gst_gl_color_convert_new (GstGLContext * context);
138
139GST_GL_API
140GstCaps * gst_gl_color_convert_transform_caps (GstGLContext * context,
141 GstPadDirection direction,
142 GstCaps * caps,
143 GstCaps * filter);
144GST_GL_API
145GstCaps * gst_gl_color_convert_fixate_caps (GstGLContext * context,
146 GstPadDirection direction,
147 GstCaps * caps,
148 GstCaps * other);
149GST_GL_API
150gboolean gst_gl_color_convert_set_caps (GstGLColorConvert * convert,
151 GstCaps * in_caps,
152 GstCaps * out_caps);
153GST_GL_API
154gboolean gst_gl_color_convert_decide_allocation (GstGLColorConvert * convert,
155 GstQuery * query);
156
157GST_GL_API
158GstBuffer * gst_gl_color_convert_perform (GstGLColorConvert * convert, GstBuffer * inbuf);
159
160GST_GL_API
161gchar * gst_gl_color_convert_swizzle_shader_string (GstGLContext * context);
162
163GST_GL_API
164gchar * gst_gl_color_convert_yuv_to_rgb_shader_string (GstGLContext * context);
165
166G_END_DECLS
167
168#endif /* __GST_GL_COLOR_CONVERT_H__ */
169

source code of include/gstreamer-1.0/gst/gl/gstglcolorconvert.h