static GstFlowReturn gst_video_median_transform_frame (GstVideoFilter * filter, GstVideoFrame * in_frame, GstVideoFrame * out_frame) { GstVideoMedian *median = GST_VIDEO_MEDIAN (filter); if (median->filtersize == 5) { median_5 (GST_VIDEO_FRAME_PLANE_DATA (out_frame, 0), GST_VIDEO_FRAME_PLANE_STRIDE (out_frame, 0), GST_VIDEO_FRAME_PLANE_DATA (in_frame, 0), GST_VIDEO_FRAME_PLANE_STRIDE (in_frame, 0), GST_VIDEO_FRAME_WIDTH (in_frame), GST_VIDEO_FRAME_HEIGHT (in_frame)); if (median->lum_only) { gst_video_frame_copy_plane (out_frame, in_frame, 1); gst_video_frame_copy_plane (out_frame, in_frame, 2); } else { median_5 (GST_VIDEO_FRAME_PLANE_DATA (out_frame, 1), GST_VIDEO_FRAME_PLANE_STRIDE (out_frame, 1), GST_VIDEO_FRAME_PLANE_DATA (in_frame, 1), GST_VIDEO_FRAME_PLANE_STRIDE (in_frame, 1), GST_VIDEO_FRAME_WIDTH (in_frame) / 2, GST_VIDEO_FRAME_HEIGHT (in_frame) / 2); median_5 (GST_VIDEO_FRAME_PLANE_DATA (out_frame, 2), GST_VIDEO_FRAME_PLANE_STRIDE (out_frame, 2), GST_VIDEO_FRAME_PLANE_DATA (in_frame, 2), GST_VIDEO_FRAME_PLANE_STRIDE (in_frame, 2), GST_VIDEO_FRAME_WIDTH (in_frame) / 2, GST_VIDEO_FRAME_HEIGHT (in_frame) / 2); } } else { median_9 (GST_VIDEO_FRAME_PLANE_DATA (out_frame, 0), GST_VIDEO_FRAME_PLANE_STRIDE (out_frame, 0), GST_VIDEO_FRAME_PLANE_DATA (in_frame, 0), GST_VIDEO_FRAME_PLANE_STRIDE (in_frame, 0), GST_VIDEO_FRAME_WIDTH (in_frame), GST_VIDEO_FRAME_HEIGHT (in_frame)); if (median->lum_only) { gst_video_frame_copy_plane (out_frame, in_frame, 1); gst_video_frame_copy_plane (out_frame, in_frame, 2); } else { median_9 (GST_VIDEO_FRAME_PLANE_DATA (out_frame, 1), GST_VIDEO_FRAME_PLANE_STRIDE (out_frame, 1), GST_VIDEO_FRAME_PLANE_DATA (in_frame, 1), GST_VIDEO_FRAME_PLANE_STRIDE (in_frame, 1), GST_VIDEO_FRAME_WIDTH (in_frame) / 2, GST_VIDEO_FRAME_HEIGHT (in_frame) / 2); median_9 (GST_VIDEO_FRAME_PLANE_DATA (out_frame, 2), GST_VIDEO_FRAME_PLANE_STRIDE (out_frame, 2), GST_VIDEO_FRAME_PLANE_DATA (in_frame, 2), GST_VIDEO_FRAME_PLANE_STRIDE (in_frame, 2), GST_VIDEO_FRAME_WIDTH (in_frame) / 2, GST_VIDEO_FRAME_HEIGHT (in_frame) / 2); } } return GST_FLOW_OK; }
/** * gst_video_frame_copy: * @dest: a #GstVideoFrame * @src: a #GstVideoFrame * * Copy the contents from @src to @dest. * * Returns: TRUE if the contents could be copied. */ gboolean gst_video_frame_copy (GstVideoFrame * dest, const GstVideoFrame * src) { guint i, n_planes; const GstVideoInfo *sinfo; GstVideoInfo *dinfo; g_return_val_if_fail (dest != NULL, FALSE); g_return_val_if_fail (src != NULL, FALSE); sinfo = &src->info; dinfo = &dest->info; g_return_val_if_fail (dinfo->finfo->format == sinfo->finfo->format, FALSE); g_return_val_if_fail (dinfo->width == sinfo->width && dinfo->height == sinfo->height, FALSE); n_planes = dinfo->finfo->n_planes; if (GST_VIDEO_FORMAT_INFO_HAS_PALETTE (sinfo->finfo)) { memcpy (dest->data[1], src->data[1], 256 * 4); n_planes = 1; } for (i = 0; i < n_planes; i++) gst_video_frame_copy_plane (dest, src, i); return TRUE; }
static GstFlowReturn gst_smooth_transform_frame (GstVideoFilter * vfilter, GstVideoFrame * in_frame, GstVideoFrame * out_frame) { GstSmooth *smooth; smooth = GST_SMOOTH (vfilter); if (!smooth->active) { gst_video_frame_copy (out_frame, in_frame); return GST_FLOW_OK; } smooth_filter (GST_VIDEO_FRAME_COMP_DATA (out_frame, 0), GST_VIDEO_FRAME_COMP_DATA (in_frame, 0), GST_VIDEO_FRAME_COMP_WIDTH (in_frame, 0), GST_VIDEO_FRAME_COMP_HEIGHT (in_frame, 0), GST_VIDEO_FRAME_COMP_STRIDE (in_frame, 0), GST_VIDEO_FRAME_COMP_STRIDE (out_frame, 0), smooth->tolerance, smooth->filtersize); if (!smooth->luma_only) { smooth_filter (GST_VIDEO_FRAME_COMP_DATA (out_frame, 1), GST_VIDEO_FRAME_COMP_DATA (in_frame, 1), GST_VIDEO_FRAME_COMP_WIDTH (in_frame, 1), GST_VIDEO_FRAME_COMP_HEIGHT (in_frame, 1), GST_VIDEO_FRAME_COMP_STRIDE (in_frame, 1), GST_VIDEO_FRAME_COMP_STRIDE (out_frame, 1), smooth->tolerance, smooth->filtersize); smooth_filter (GST_VIDEO_FRAME_COMP_DATA (out_frame, 2), GST_VIDEO_FRAME_COMP_DATA (in_frame, 2), GST_VIDEO_FRAME_COMP_WIDTH (in_frame, 2), GST_VIDEO_FRAME_COMP_HEIGHT (in_frame, 2), GST_VIDEO_FRAME_COMP_STRIDE (in_frame, 2), GST_VIDEO_FRAME_COMP_STRIDE (out_frame, 2), smooth->tolerance, smooth->filtersize); } else { gst_video_frame_copy_plane (out_frame, in_frame, 1); gst_video_frame_copy_plane (out_frame, in_frame, 2); } return GST_FLOW_OK; }