void GLView::process() { makeCurrent(); if (m_image.isNull()) { m_dst = texture_2d(); return; } int w = m_image.width(); int h = m_image.height(); glViewport(0, 0, w, h); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fbo); glPushAttrib(GL_TEXTURE_BIT); texture_2d src(GL_RGB16F_ARB, m_image.width(), m_image.height(), GL_BGRA, GL_UNSIGNED_BYTE, m_image.bits()); texture_2d lab = rgb2lab(src); texture_2d tfm = tangent_flow_map(src, sst_sigma); texture_2d bfe = (bf_ne > 0)? orientation_aligned_bilateral_filter(lab, tfm, bf_ne, bf_sigma_d, bf_sigma_r) : lab; texture_2d bfa = (bf_na > 0)? orientation_aligned_bilateral_filter(lab, tfm, bf_na, bf_sigma_d, bf_sigma_r) : lab; texture_2d edges = (fdog_type == 0)? fdog_filter(bfe, tfm, fdog_n, fdog_sigma_e, fdog_sigma_r, fdog_tau, fdog_sigma_m, fdog_phi) : dog_filter(bfe, fdog_n, fdog_sigma_e, fdog_sigma_r, fdog_tau, fdog_phi); texture_2d cq = color_quantization(bfa, cq_nbins, cq_phi_q, cq_filter); texture_2d cq_rgb = lab2rgb(cq); texture_2d ov = mix_filter(edges, cq_rgb, fdog_color); texture_2d result = fs_type? smooth_filter(tfm, ov, fs_type, fs_sigma) : ov; switch (preview) { case 0: m_dst = result; break; case 1: m_dst = src; break; case 2: m_dst = lic_filter(tfm, m_noise, 5.0); break; case 3: m_dst = lab2rgb(bfe); break; case 4: m_dst = lab2rgb(bfa); break; case 5: m_dst = edges; break; case 6: m_dst = cq_rgb; break; } glUseProgram(0); glPopAttrib(); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); }
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; }