1 /*
2 * GStreamer
3 * Copyright (C) 2015 Matthew Waters <matthew@centricular.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 /**
22 * SECTION:gstglformat
23 * @title: GstGLFormat
24 * @short_description: utilities for dealing with OpenGL formats
25 * @see_also: #GstGLBaseMemory, #GstGLMemory, #GstGLFramebuffer, #GstGLBuffer
26 *
27 * Some useful utilities for converting between various formats and OpenGL
28 * formats.
29 */
30
31 #ifdef HAVE_CONFIG_H
32 #include "config.h"
33 #endif
34
35 #include "gstglformat.h"
36
37 #include "gstglcontext.h"
38 #include "gstglfuncs.h"
39
40 #define USING_OPENGL(context) (gst_gl_context_check_gl_version (context, GST_GL_API_OPENGL, 1, 0))
41 #define USING_OPENGL3(context) (gst_gl_context_check_gl_version (context, GST_GL_API_OPENGL3, 3, 1))
42 #define USING_GLES(context) (gst_gl_context_check_gl_version (context, GST_GL_API_GLES, 1, 0))
43 #define USING_GLES2(context) (gst_gl_context_check_gl_version (context, GST_GL_API_GLES2, 2, 0))
44 #define USING_GLES3(context) (gst_gl_context_check_gl_version (context, GST_GL_API_GLES2, 3, 0))
45
46 #ifndef GL_TEXTURE_RECTANGLE
47 #define GL_TEXTURE_RECTANGLE 0x84F5
48 #endif
49 #ifndef GL_TEXTURE_EXTERNAL_OES
50 #define GL_TEXTURE_EXTERNAL_OES 0x8D65
51 #endif
52 #ifndef GL_UNSIGNED_INT_2_10_10_10_REV
53 #define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368
54 #endif
55
56 static inline guint
_gl_format_n_components(guint format)57 _gl_format_n_components (guint format)
58 {
59 switch (format) {
60 case GST_VIDEO_GL_TEXTURE_TYPE_RGBA:
61 case GST_GL_RGBA:
62 case GST_GL_RGBA8:
63 case GST_GL_RGBA16:
64 case GST_GL_RGB10_A2:
65 return 4;
66 case GST_VIDEO_GL_TEXTURE_TYPE_RGB:
67 case GST_VIDEO_GL_TEXTURE_TYPE_RGB16:
68 case GST_GL_RGB:
69 case GST_GL_RGB8:
70 case GST_GL_RGB16:
71 case GST_GL_RGB565:
72 return 3;
73 case GST_VIDEO_GL_TEXTURE_TYPE_LUMINANCE_ALPHA:
74 case GST_VIDEO_GL_TEXTURE_TYPE_RG:
75 case GST_GL_LUMINANCE_ALPHA:
76 case GST_GL_RG:
77 case GST_GL_RG8:
78 case GST_GL_RG16:
79 return 2;
80 case GST_VIDEO_GL_TEXTURE_TYPE_LUMINANCE:
81 case GST_VIDEO_GL_TEXTURE_TYPE_R:
82 case GST_GL_LUMINANCE:
83 case GST_GL_ALPHA:
84 case GST_GL_RED:
85 case GST_GL_R8:
86 case GST_GL_R16:
87 return 1;
88 default:
89 return 0;
90 }
91 }
92
93 static inline guint
_gl_type_n_components(guint type)94 _gl_type_n_components (guint type)
95 {
96 switch (type) {
97 case GL_UNSIGNED_BYTE:
98 case GL_UNSIGNED_SHORT:
99 return 1;
100 case GL_UNSIGNED_SHORT_5_6_5:
101 return 3;
102 case GL_UNSIGNED_INT_2_10_10_10_REV:
103 return 4;
104 default:
105 g_assert_not_reached ();
106 return 0;
107 }
108 }
109
110 static inline guint
_gl_type_n_bytes(guint type)111 _gl_type_n_bytes (guint type)
112 {
113 switch (type) {
114 case GL_UNSIGNED_BYTE:
115 return 1;
116 case GL_UNSIGNED_SHORT:
117 case GL_UNSIGNED_SHORT_5_6_5:
118 return 2;
119 case GL_UNSIGNED_INT_2_10_10_10_REV:
120 return 4;
121 default:
122 g_assert_not_reached ();
123 return 0;
124 }
125 }
126
127 /**
128 * gst_gl_format_type_n_bytes:
129 * @format: the OpenGL format, `GL_RGBA`, `GL_LUMINANCE`, etc
130 * @type: the OpenGL type, `GL_UNSIGNED_BYTE`, `GL_FLOAT`, etc
131 *
132 * Returns: the number of bytes the specified @format, @type combination takes
133 * per pixel
134 */
135 guint
gst_gl_format_type_n_bytes(guint format,guint type)136 gst_gl_format_type_n_bytes (guint format, guint type)
137 {
138 return _gl_format_n_components (format) / _gl_type_n_components (type) *
139 _gl_type_n_bytes (type);
140 }
141
142 /**
143 * gst_gl_format_from_video_info:
144 * @context: a #GstGLContext
145 * @vinfo: a #GstVideoInfo
146 * @plane: the plane number in @vinfo
147 *
148 * Returns: the #GstGLFormat necessary for holding the data in @plane of @vinfo
149 */
150 GstGLFormat
gst_gl_format_from_video_info(GstGLContext * context,const GstVideoInfo * vinfo,guint plane)151 gst_gl_format_from_video_info (GstGLContext * context,
152 const GstVideoInfo * vinfo, guint plane)
153 {
154 gboolean texture_rg =
155 gst_gl_context_check_feature (context, "GL_EXT_texture_rg")
156 || gst_gl_context_check_gl_version (context, GST_GL_API_GLES2, 3, 0)
157 || gst_gl_context_check_feature (context, "GL_ARB_texture_rg")
158 || gst_gl_context_check_gl_version (context, GST_GL_API_OPENGL3, 3, 0);
159 GstVideoFormat v_format = GST_VIDEO_INFO_FORMAT (vinfo);
160 guint n_plane_components;
161
162 switch (v_format) {
163 case GST_VIDEO_FORMAT_RGBx:
164 case GST_VIDEO_FORMAT_BGRx:
165 case GST_VIDEO_FORMAT_xRGB:
166 case GST_VIDEO_FORMAT_xBGR:
167 case GST_VIDEO_FORMAT_RGBA:
168 case GST_VIDEO_FORMAT_BGRA:
169 case GST_VIDEO_FORMAT_ARGB:
170 case GST_VIDEO_FORMAT_ABGR:
171 case GST_VIDEO_FORMAT_AYUV:
172 case GST_VIDEO_FORMAT_VUYA:
173 n_plane_components = 4;
174 break;
175 case GST_VIDEO_FORMAT_ARGB64:
176 return GST_GL_RGBA16;
177 case GST_VIDEO_FORMAT_RGB:
178 case GST_VIDEO_FORMAT_BGR:
179 n_plane_components = 3;
180 break;
181 case GST_VIDEO_FORMAT_RGB16:
182 case GST_VIDEO_FORMAT_BGR16:
183 return GST_GL_RGB565;
184 break;
185 case GST_VIDEO_FORMAT_GRAY16_BE:
186 case GST_VIDEO_FORMAT_GRAY16_LE:
187 case GST_VIDEO_FORMAT_YUY2:
188 case GST_VIDEO_FORMAT_UYVY:
189 n_plane_components = 2;
190 break;
191 case GST_VIDEO_FORMAT_NV12:
192 case GST_VIDEO_FORMAT_NV21:
193 case GST_VIDEO_FORMAT_NV16:
194 case GST_VIDEO_FORMAT_NV61:
195 n_plane_components = plane == 0 ? 1 : 2;
196 break;
197 case GST_VIDEO_FORMAT_AV12:
198 n_plane_components = (plane == 1) ? 2 : 1;
199 break;
200 case GST_VIDEO_FORMAT_GRAY8:
201 case GST_VIDEO_FORMAT_Y444:
202 case GST_VIDEO_FORMAT_Y42B:
203 case GST_VIDEO_FORMAT_Y41B:
204 case GST_VIDEO_FORMAT_I420:
205 case GST_VIDEO_FORMAT_YV12:
206 case GST_VIDEO_FORMAT_A420:
207 n_plane_components = 1;
208 break;
209 case GST_VIDEO_FORMAT_BGR10A2_LE:
210 case GST_VIDEO_FORMAT_RGB10A2_LE:
211 case GST_VIDEO_FORMAT_Y410:
212 return GST_GL_RGB10_A2;
213 case GST_VIDEO_FORMAT_P010_10LE:
214 case GST_VIDEO_FORMAT_P010_10BE:
215 case GST_VIDEO_FORMAT_P012_LE:
216 case GST_VIDEO_FORMAT_P012_BE:
217 case GST_VIDEO_FORMAT_P016_LE:
218 case GST_VIDEO_FORMAT_P016_BE:
219 return plane == 0 ? GST_GL_R16 : GST_GL_RG16;
220 case GST_VIDEO_FORMAT_Y210:
221 case GST_VIDEO_FORMAT_Y212_LE:
222 case GST_VIDEO_FORMAT_Y212_BE:
223 return GST_GL_RG16;
224 case GST_VIDEO_FORMAT_Y412_LE:
225 case GST_VIDEO_FORMAT_Y412_BE:
226 return GST_GL_RGBA16;
227 case GST_VIDEO_FORMAT_GBR:
228 case GST_VIDEO_FORMAT_RGBP:
229 case GST_VIDEO_FORMAT_BGRP:
230 case GST_VIDEO_FORMAT_GBRA:
231 return GST_GL_R8;
232 default:
233 n_plane_components = 4;
234 g_assert_not_reached ();
235 break;
236 }
237
238 switch (n_plane_components) {
239 case 4:
240 return GST_GL_RGBA;
241 case 3:
242 return GST_GL_RGB;
243 case 2:
244 return texture_rg ? GST_GL_RG : GST_GL_LUMINANCE_ALPHA;
245 case 1:
246 return texture_rg ? GST_GL_RED : GST_GL_LUMINANCE;
247 default:
248 break;
249 }
250
251 g_critical ("Unknown video format 0x%x provided", v_format);
252 return 0;
253 }
254
255 /**
256 * gst_gl_sized_gl_format_from_gl_format_type:
257 * @context: a #GstGLContext
258 * @format: an OpenGL format, `GL_RGBA`, `GL_LUMINANCE`, etc
259 * @type: an OpenGL type, `GL_UNSIGNED_BYTE`, `GL_FLOAT`, etc
260 *
261 * Returns: the sized internal format specified by @format and @type that can
262 * be used in @context
263 */
264 guint
gst_gl_sized_gl_format_from_gl_format_type(GstGLContext * context,guint format,guint type)265 gst_gl_sized_gl_format_from_gl_format_type (GstGLContext * context,
266 guint format, guint type)
267 {
268 gboolean ext_texture_rg =
269 gst_gl_context_check_feature (context, "GL_EXT_texture_rg");
270
271 switch (format) {
272 case GST_GL_RGBA:
273 switch (type) {
274 case GL_UNSIGNED_BYTE:
275 return USING_GLES2 (context)
276 && !USING_GLES3 (context) ? GST_GL_RGBA : GST_GL_RGBA8;
277 case GL_UNSIGNED_SHORT:
278 return GST_GL_RGBA16;
279 case GL_UNSIGNED_INT_2_10_10_10_REV:
280 return GST_GL_RGB10_A2;
281 }
282 break;
283 case GST_GL_RGB:
284 switch (type) {
285 case GL_UNSIGNED_BYTE:
286 return USING_GLES2 (context)
287 && !USING_GLES3 (context) ? GST_GL_RGB : GST_GL_RGB8;
288 case GL_UNSIGNED_SHORT_5_6_5:
289 return GST_GL_RGB565;
290 case GL_UNSIGNED_SHORT:
291 return GST_GL_RGB16;
292 }
293 break;
294 case GST_GL_RG:
295 switch (type) {
296 case GL_UNSIGNED_BYTE:
297 if (!USING_GLES3 (context) && USING_GLES2 (context) && ext_texture_rg)
298 return GST_GL_RG;
299 return GST_GL_RG8;
300 case GL_UNSIGNED_SHORT:
301 return GST_GL_RG16;
302 }
303 break;
304 case GST_GL_RED:
305 switch (type) {
306 case GL_UNSIGNED_BYTE:
307 if (!USING_GLES3 (context) && USING_GLES2 (context) && ext_texture_rg)
308 return GST_GL_RED;
309 return GST_GL_R8;
310 case GL_UNSIGNED_SHORT:
311 return GST_GL_R16;
312 }
313 break;
314 case GST_GL_RGBA8:
315 case GST_GL_RGBA16:
316 case GST_GL_RGB8:
317 case GST_GL_RGB16:
318 case GST_GL_RGB565:
319 case GST_GL_RG8:
320 case GST_GL_R8:
321 case GST_GL_LUMINANCE:
322 case GST_GL_LUMINANCE_ALPHA:
323 case GST_GL_ALPHA:
324 case GST_GL_DEPTH_COMPONENT16:
325 case GST_GL_DEPTH24_STENCIL8:
326 case GST_GL_RGB10_A2:
327 case GST_GL_R16:
328 case GST_GL_RG16:
329 return format;
330 default:
331 g_critical ("Unknown GL format 0x%x type 0x%x provided", format, type);
332 return format;
333 }
334
335 g_assert_not_reached ();
336 return 0;
337 }
338
339 /**
340 * gst_gl_format_type_from_sized_gl_format:
341 * @format: the sized internal #GstGLFormat
342 * @unsized_format: (out): location for the resulting unsized #GstGLFormat
343 * @gl_type: (out): location for the resulting GL type
344 *
345 * Get the unsized format and type from @format for usage in glReadPixels,
346 * glTex{Sub}Image*, glTexImage* and similar functions.
347 *
348 * Since: 1.16
349 */
350 void
gst_gl_format_type_from_sized_gl_format(GstGLFormat format,GstGLFormat * unsized_format,guint * gl_type)351 gst_gl_format_type_from_sized_gl_format (GstGLFormat format,
352 GstGLFormat * unsized_format, guint * gl_type)
353 {
354 g_return_if_fail (unsized_format != NULL);
355 g_return_if_fail (gl_type != NULL);
356
357 switch (format) {
358 case GST_GL_RGBA8:
359 *unsized_format = GST_GL_RGBA;
360 *gl_type = GL_UNSIGNED_BYTE;
361 break;
362 case GST_GL_RGB8:
363 *unsized_format = GST_GL_RGB;
364 *gl_type = GL_UNSIGNED_BYTE;
365 break;
366 case GST_GL_RGBA16:
367 *unsized_format = GST_GL_RGBA;
368 *gl_type = GL_UNSIGNED_SHORT;
369 break;
370 case GST_GL_RGB16:
371 *unsized_format = GST_GL_RGB;
372 *gl_type = GL_UNSIGNED_SHORT;
373 break;
374 case GST_GL_RGB565:
375 *unsized_format = GST_GL_RGB;
376 *gl_type = GL_UNSIGNED_SHORT_5_6_5;
377 break;
378 case GST_GL_RG8:
379 *unsized_format = GST_GL_RG;
380 *gl_type = GL_UNSIGNED_BYTE;
381 break;
382 case GST_GL_R8:
383 *unsized_format = GST_GL_RED;
384 *gl_type = GL_UNSIGNED_BYTE;
385 break;
386 case GST_GL_RGBA:
387 case GST_GL_RGB:
388 case GST_GL_RG:
389 case GST_GL_RED:
390 case GST_GL_LUMINANCE:
391 case GST_GL_LUMINANCE_ALPHA:
392 case GST_GL_ALPHA:
393 *unsized_format = format;
394 *gl_type = GL_UNSIGNED_BYTE;
395 break;
396 case GST_GL_RGB10_A2:
397 *unsized_format = GST_GL_RGBA;
398 *gl_type = GL_UNSIGNED_INT_2_10_10_10_REV;
399 break;
400 case GST_GL_R16:
401 *unsized_format = GST_GL_RED;
402 *gl_type = GL_UNSIGNED_SHORT;
403 break;
404 case GST_GL_RG16:
405 *unsized_format = GST_GL_RG;
406 *gl_type = GL_UNSIGNED_SHORT;
407 break;
408 default:
409 g_critical ("Unknown GL format 0x%x provided", format);
410 *unsized_format = format;
411 *gl_type = GL_UNSIGNED_BYTE;
412 return;
413 }
414 }
415
416 /**
417 * gst_gl_format_is_supported:
418 * @context: a #GstGLContext
419 * @format: the #GstGLFormat to check is supported by @context
420 *
421 * Returns: Whether @format is supported by @context based on the OpenGL API,
422 * version, or available OpenGL extension/s.
423 *
424 * Since: 1.16
425 */
426 gboolean
gst_gl_format_is_supported(GstGLContext * context,GstGLFormat format)427 gst_gl_format_is_supported (GstGLContext * context, GstGLFormat format)
428 {
429 g_return_val_if_fail (GST_IS_GL_CONTEXT (context), FALSE);
430
431 switch (format) {
432 case GST_GL_RGBA:
433 case GST_GL_RGB:
434 return TRUE;
435 case GST_GL_LUMINANCE:
436 case GST_GL_ALPHA:
437 case GST_GL_LUMINANCE_ALPHA:
438 /* deprecated/removed in core GL3 contexts */
439 return USING_OPENGL (context) || USING_GLES2 (context);
440 case GST_GL_RG:
441 case GST_GL_RED:
442 return gst_gl_context_check_gl_version (context, GST_GL_API_GLES2, 3, 0)
443 || gst_gl_context_check_gl_version (context, GST_GL_API_OPENGL3, 3, 0)
444 || gst_gl_context_check_feature (context, "GL_EXT_texture_rg")
445 || gst_gl_context_check_feature (context, "GL_ARB_texture_rg");
446 case GST_GL_R8:
447 case GST_GL_RG8:
448 return USING_GLES3 (context)
449 || gst_gl_context_check_gl_version (context, GST_GL_API_OPENGL3, 3, 0)
450 || gst_gl_context_check_feature (context, "GL_ARB_texture_rg");
451 case GST_GL_RGB8:
452 case GST_GL_RGBA8:
453 return (USING_GLES3 (context) && !USING_GLES2 (context))
454 || USING_OPENGL (context) || USING_OPENGL3 (context);
455 case GST_GL_RGB16:
456 case GST_GL_RGBA16:
457 return USING_OPENGL (context) || USING_OPENGL3 (context)
458 || USING_GLES3 (context);
459 case GST_GL_RGB565:
460 return USING_GLES2 (context) || (USING_OPENGL3 (context)
461 && gst_gl_context_check_feature (context,
462 "GL_ARB_ES2_compatibility"));
463 case GST_GL_DEPTH_COMPONENT16:
464 return gst_gl_context_check_gl_version (context, GST_GL_API_OPENGL, 1, 4)
465 || USING_GLES2 (context)
466 || gst_gl_context_check_feature (context, "GL_ARB_depth_texture")
467 || gst_gl_context_check_feature (context, "GL_OES_depth_texture");
468 case GST_GL_DEPTH24_STENCIL8:
469 return gst_gl_context_check_gl_version (context, GST_GL_API_OPENGL, 3, 0)
470 || USING_GLES3 (context)
471 || gst_gl_context_check_feature (context,
472 "GL_OES_packed_depth_stencil")
473 || gst_gl_context_check_feature (context,
474 "GL_EXT_packed_depth_stencil");
475 case GST_GL_RGB10_A2:
476 return USING_OPENGL (context) || USING_OPENGL3 (context)
477 || USING_GLES3 (context)
478 || gst_gl_context_check_feature (context,
479 "GL_OES_required_internalformat");
480 case GST_GL_R16:
481 case GST_GL_RG16:
482 return gst_gl_context_check_gl_version (context,
483 GST_GL_API_OPENGL | GST_GL_API_OPENGL3, 3, 0)
484 || (gst_gl_context_check_gl_version (context, GST_GL_API_GLES2, 3, 1)
485 && gst_gl_context_check_feature (context, "GL_EXT_texture_norm16"));
486 default:
487 g_assert_not_reached ();
488 return FALSE;
489 }
490 }
491
492 /**
493 * gst_gl_texture_target_to_string:
494 * @target: a #GstGLTextureTarget
495 *
496 * Returns: the stringified version of @target or %NULL
497 */
498 const gchar *
gst_gl_texture_target_to_string(GstGLTextureTarget target)499 gst_gl_texture_target_to_string (GstGLTextureTarget target)
500 {
501 switch (target) {
502 case GST_GL_TEXTURE_TARGET_2D:
503 return GST_GL_TEXTURE_TARGET_2D_STR;
504 case GST_GL_TEXTURE_TARGET_RECTANGLE:
505 return GST_GL_TEXTURE_TARGET_RECTANGLE_STR;
506 case GST_GL_TEXTURE_TARGET_EXTERNAL_OES:
507 return GST_GL_TEXTURE_TARGET_EXTERNAL_OES_STR;
508 default:
509 return NULL;
510 }
511 }
512
513 /**
514 * gst_gl_texture_target_from_string:
515 * @str: a string equivalent to one of the GST_GL_TEXTURE_TARGET_*_STR values
516 *
517 * Returns: the #GstGLTextureTarget represented by @str or
518 * %GST_GL_TEXTURE_TARGET_NONE
519 */
520 GstGLTextureTarget
gst_gl_texture_target_from_string(const gchar * str)521 gst_gl_texture_target_from_string (const gchar * str)
522 {
523 if (!str)
524 return GST_GL_TEXTURE_TARGET_NONE;
525
526 if (g_strcmp0 (str, GST_GL_TEXTURE_TARGET_2D_STR) == 0)
527 return GST_GL_TEXTURE_TARGET_2D;
528 if (g_strcmp0 (str, GST_GL_TEXTURE_TARGET_RECTANGLE_STR) == 0)
529 return GST_GL_TEXTURE_TARGET_RECTANGLE;
530 if (g_strcmp0 (str, GST_GL_TEXTURE_TARGET_EXTERNAL_OES_STR) == 0)
531 return GST_GL_TEXTURE_TARGET_EXTERNAL_OES;
532
533 return GST_GL_TEXTURE_TARGET_NONE;
534 }
535
536 /**
537 * gst_gl_texture_target_to_gl:
538 * @target: a #GstGLTextureTarget
539 *
540 * Returns: the OpenGL value for binding the @target with glBindTexture() and
541 * similar functions or 0
542 */
543 guint
gst_gl_texture_target_to_gl(GstGLTextureTarget target)544 gst_gl_texture_target_to_gl (GstGLTextureTarget target)
545 {
546 switch (target) {
547 case GST_GL_TEXTURE_TARGET_2D:
548 return GL_TEXTURE_2D;
549 case GST_GL_TEXTURE_TARGET_RECTANGLE:
550 return GL_TEXTURE_RECTANGLE;
551 case GST_GL_TEXTURE_TARGET_EXTERNAL_OES:
552 return GL_TEXTURE_EXTERNAL_OES;
553 default:
554 return 0;
555 }
556 }
557
558 /**
559 * gst_gl_texture_target_from_gl:
560 * @target: an OpenGL texture binding target
561 *
562 * Returns: the #GstGLTextureTarget that's equiavalant to @target or
563 * %GST_GL_TEXTURE_TARGET_NONE
564 */
565 GstGLTextureTarget
gst_gl_texture_target_from_gl(guint target)566 gst_gl_texture_target_from_gl (guint target)
567 {
568 switch (target) {
569 case GL_TEXTURE_2D:
570 return GST_GL_TEXTURE_TARGET_2D;
571 case GL_TEXTURE_RECTANGLE:
572 return GST_GL_TEXTURE_TARGET_RECTANGLE;
573 case GL_TEXTURE_EXTERNAL_OES:
574 return GST_GL_TEXTURE_TARGET_EXTERNAL_OES;
575 default:
576 return GST_GL_TEXTURE_TARGET_NONE;
577 }
578 }
579
580 /**
581 * gst_gl_texture_target_to_buffer_pool_option:
582 * @target: a #GstGLTextureTarget
583 *
584 * Returns: a string representing the @GstBufferPoolOption specified by @target
585 */
586 const gchar *
gst_gl_texture_target_to_buffer_pool_option(GstGLTextureTarget target)587 gst_gl_texture_target_to_buffer_pool_option (GstGLTextureTarget target)
588 {
589 switch (target) {
590 case GST_GL_TEXTURE_TARGET_2D:
591 return GST_BUFFER_POOL_OPTION_GL_TEXTURE_TARGET_2D;
592 case GST_GL_TEXTURE_TARGET_RECTANGLE:
593 return GST_BUFFER_POOL_OPTION_GL_TEXTURE_TARGET_RECTANGLE;
594 case GST_GL_TEXTURE_TARGET_EXTERNAL_OES:
595 return GST_BUFFER_POOL_OPTION_GL_TEXTURE_TARGET_EXTERNAL_OES;
596 default:
597 return NULL;
598 }
599 }
600