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_FORMATS:
87 *
88 * The currently supported formats that can be converted
89 */
90#define GST_GL_COLOR_CONVERT_FORMATS "{ RGBA, RGB, RGBx, BGR, BGRx, BGRA, xRGB, " \
91 "xBGR, ARGB, ABGR, Y444, I420, YV12, Y42B, " \
92 "Y41B, NV12, NV21, YUY2, UYVY, AYUV, VUYA, " \
93 "GRAY8, GRAY16_LE, GRAY16_BE, RGB16, BGR16, ARGB64 }"
94
95/**
96 * GST_GL_COLOR_CONVERT_VIDEO_CAPS:
97 *
98 * The currently supported #GstCaps that can be converted
99 */
100#define GST_GL_COLOR_CONVERT_VIDEO_CAPS \
101 "video/x-raw(" GST_CAPS_FEATURE_MEMORY_GL_MEMORY "), " \
102 "format = (string) " GST_GL_COLOR_CONVERT_FORMATS ", " \
103 "width = " GST_VIDEO_SIZE_RANGE ", " \
104 "height = " GST_VIDEO_SIZE_RANGE ", " \
105 "framerate = " GST_VIDEO_FPS_RANGE ", " \
106 "texture-target = (string) { 2D, rectangle, external-oes } " \
107 " ; " \
108 "video/x-raw(" GST_CAPS_FEATURE_MEMORY_GL_MEMORY "," \
109 GST_CAPS_FEATURE_META_GST_VIDEO_OVERLAY_COMPOSITION "), " \
110 "format = (string) " GST_GL_COLOR_CONVERT_FORMATS ", " \
111 "width = " GST_VIDEO_SIZE_RANGE ", " \
112 "height = " GST_VIDEO_SIZE_RANGE ", " \
113 "framerate = " GST_VIDEO_FPS_RANGE ", " \
114 "texture-target = (string) { 2D, rectangle, external-oes }"
115
116GST_GL_API
117GstGLColorConvert * gst_gl_color_convert_new (GstGLContext * context);
118
119GST_GL_API
120GstCaps * gst_gl_color_convert_transform_caps (GstGLContext * context,
121 GstPadDirection direction,
122 GstCaps * caps,
123 GstCaps * filter);
124GST_GL_API
125GstCaps * gst_gl_color_convert_fixate_caps (GstGLContext * context,
126 GstPadDirection direction,
127 GstCaps * caps,
128 GstCaps * other);
129GST_GL_API
130gboolean gst_gl_color_convert_set_caps (GstGLColorConvert * convert,
131 GstCaps * in_caps,
132 GstCaps * out_caps);
133GST_GL_API
134gboolean gst_gl_color_convert_decide_allocation (GstGLColorConvert * convert,
135 GstQuery * query);
136
137GST_GL_API
138GstBuffer * gst_gl_color_convert_perform (GstGLColorConvert * convert, GstBuffer * inbuf);
139
140G_END_DECLS
141
142#endif /* __GST_GL_COLOR_CONVERT_H__ */
143