void yadif_filter (GstYadif * yadif, int parity, int tff) { int y, i; const GstVideoInfo *vi = &yadif->video_info; const GstVideoFormatInfo *vfi = vi->finfo; for (i = 0; i < GST_VIDEO_FORMAT_INFO_N_COMPONENTS (vfi); i++) { int w = GST_VIDEO_FORMAT_INFO_SCALE_WIDTH (vfi, i, vi->width); int h = GST_VIDEO_FORMAT_INFO_SCALE_HEIGHT (vfi, i, vi->height); int refs = GST_VIDEO_INFO_COMP_STRIDE (vi, i); int df = GST_VIDEO_INFO_COMP_PSTRIDE (vi, i); guint8 *prev_data = GST_VIDEO_FRAME_COMP_DATA (&yadif->prev_frame, i); guint8 *cur_data = GST_VIDEO_FRAME_COMP_DATA (&yadif->cur_frame, i); guint8 *next_data = GST_VIDEO_FRAME_COMP_DATA (&yadif->next_frame, i); guint8 *dest_data = GST_VIDEO_FRAME_COMP_DATA (&yadif->dest_frame, i); for (y = 0; y < h; y++) { if ((y ^ parity) & 1) { guint8 *prev = prev_data + y * refs; guint8 *cur = cur_data + y * refs; guint8 *next = next_data + y * refs; guint8 *dst = dest_data + y * refs; int mode = ((y == 1) || (y + 2 == h)) ? 2 : yadif->mode; #if HAVE_CPU_X86_64 if (0) { filter_line_c (dst, prev, cur, next, w, y + 1 < h ? refs : -refs, y ? -refs : refs, parity ^ tff, mode); } else { filter_line_x86_64 (dst, prev, cur, next, w, y + 1 < h ? refs : -refs, y ? -refs : refs, parity ^ tff, mode); } #else filter_line_c (dst, prev, cur, next, w, y + 1 < h ? refs : -refs, y ? -refs : refs, parity ^ tff, mode); #endif } else { guint8 *dst = dest_data + y * refs; guint8 *cur = cur_data + y * refs; memcpy (dst, cur, w * df); } } } #if 0 emms_c (); #endif }
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; }