EglConfig * egl_config_new (EglDisplay * display, guint gles_version, GstVideoFormat format) { EGLint attribs[2 * 6 + 1], *attrib = attribs; const GstVideoFormatInfo *finfo; const GlVersionInfo *vinfo; g_return_val_if_fail (display != NULL, NULL); finfo = gst_video_format_get_info (format); if (!finfo || !GST_VIDEO_FORMAT_INFO_IS_RGB (finfo)) return NULL; vinfo = gl_version_info_lookup (gles_version); if (!vinfo) return NULL; *attrib++ = EGL_COLOR_BUFFER_TYPE; *attrib++ = EGL_RGB_BUFFER; *attrib++ = EGL_RED_SIZE; *attrib++ = GST_VIDEO_FORMAT_INFO_DEPTH (finfo, GST_VIDEO_COMP_R); *attrib++ = EGL_GREEN_SIZE; *attrib++ = GST_VIDEO_FORMAT_INFO_DEPTH (finfo, GST_VIDEO_COMP_G); *attrib++ = EGL_BLUE_SIZE; *attrib++ = GST_VIDEO_FORMAT_INFO_DEPTH (finfo, GST_VIDEO_COMP_B); *attrib++ = EGL_ALPHA_SIZE; *attrib++ = GST_VIDEO_FORMAT_INFO_DEPTH (finfo, GST_VIDEO_COMP_A); *attrib++ = EGL_RENDERABLE_TYPE; *attrib++ = vinfo->gl_api_bit; *attrib++ = EGL_NONE; g_assert (attrib - attribs <= G_N_ELEMENTS (attribs)); return egl_config_new_with_attribs (display, attribs); }
static gboolean gst_opencv_get_ipl_depth_and_channels (GstStructure * structure, gint * ipldepth, gint * channels, GError ** err) { GstVideoFormat format = GST_VIDEO_FORMAT_UNKNOWN; const GstVideoFormatInfo *info; gint depth = 0, i; const gchar *s; if (gst_structure_has_name (structure, "video/x-raw")) { if (!(s = gst_structure_get_string (structure, "format"))) return FALSE; format = gst_video_format_from_string (s); if (format == GST_VIDEO_FORMAT_UNKNOWN) return FALSE; } info = gst_video_format_get_info (format); if (GST_VIDEO_FORMAT_INFO_IS_RGB (info)) *channels=3; else if (GST_VIDEO_FORMAT_INFO_IS_GRAY (info)) *channels=1; else { g_set_error (err, GST_CORE_ERROR, GST_CORE_ERROR_NEGOTIATION, "Unsupported structure %s", gst_structure_get_name (structure)); return FALSE; } for (i = 0; i < GST_VIDEO_FORMAT_INFO_N_COMPONENTS (info); i++) depth += GST_VIDEO_FORMAT_INFO_DEPTH (info, i); if (depth / *channels == 8) { /* TODO signdness? */ *ipldepth = IPL_DEPTH_8U; } else if (depth / *channels == 16) { *ipldepth = IPL_DEPTH_16U; } else { g_set_error (err, GST_CORE_ERROR, GST_CORE_ERROR_NEGOTIATION, "Unsupported depth/channels %d/%d", depth, *channels); return FALSE; } return TRUE; }
static void check_1x1_buffer (GstBuffer * buf, GstCaps * caps) { GstVideoInfo info; GstVideoFrame frame; /* the exact values we check for come from videotestsrc */ static const guint yuv_values[] = { 81, 90, 240, 255 }; static const guint rgb_values[] = { 0xff, 0, 0, 255 }; static const guint gray8_values[] = { 0x51 }; static const guint gray16_values[] = { 0x5151 }; const guint *values; guint i; const GstVideoFormatInfo *finfo; fail_unless (buf != NULL); fail_unless (caps != NULL); fail_unless (gst_video_info_from_caps (&info, caps)); fail_unless (gst_video_frame_map (&frame, &info, buf, GST_MAP_READ)); finfo = info.finfo; if (GST_VIDEO_INFO_IS_YUV (&info)) values = yuv_values; else if (GST_VIDEO_INFO_IS_GRAY (&info)) if (GST_VIDEO_FORMAT_INFO_BITS (finfo) == 8) values = gray8_values; else values = gray16_values; else values = rgb_values; GST_MEMDUMP ("buffer", GST_VIDEO_FRAME_PLANE_DATA (&frame, 0), 8); for (i = 0; i < GST_VIDEO_FRAME_N_COMPONENTS (&frame); i++) { guint8 *data = GST_VIDEO_FRAME_COMP_DATA (&frame, i); GST_DEBUG ("W: %d", GST_VIDEO_FORMAT_INFO_W_SUB (finfo, i)); GST_DEBUG ("H: %d", GST_VIDEO_FORMAT_INFO_H_SUB (finfo, i)); if (GST_VIDEO_FORMAT_INFO_W_SUB (finfo, i) >= GST_VIDEO_FRAME_WIDTH (&frame)) continue; if (GST_VIDEO_FORMAT_INFO_H_SUB (finfo, i) >= GST_VIDEO_FRAME_HEIGHT (&frame)) continue; if (GST_VIDEO_FORMAT_INFO_BITS (finfo) == 8) { fail_unless_equals_int (data[0], values[i]); } else if (GST_VIDEO_FORMAT_INFO_BITS (finfo) == 16) { guint16 pixels, val; gint depth; if (GST_VIDEO_FORMAT_INFO_IS_LE (finfo)) pixels = GST_READ_UINT16_LE (data); else pixels = GST_READ_UINT16_BE (data); depth = GST_VIDEO_FORMAT_INFO_DEPTH (finfo, i); val = pixels >> GST_VIDEO_FORMAT_INFO_SHIFT (finfo, i); val = val & ((1 << depth) - 1); GST_DEBUG ("val %08x %d : %d", pixels, i, val); if (depth <= 8) { fail_unless_equals_int (val, values[i] >> (8 - depth)); } else {