/* Perform the specified operation. */ static gboolean process (GeglOperation *operation, GeglBuffer *input, GeglBuffer *output, const GeglRectangle *result, gint level) { GeglProperties *o = GEGL_PROPERTIES (operation); GeglRectangle boundary = gegl_operation_get_bounding_box (operation); GeglRectangle eff_boundary = get_effective_area (operation); const Babl *format = babl_format ("RaGaBaA float"); #ifdef DO_NOT_USE_BUFFER_SAMPLE g_warning ("NOT USING BUFFER SAMPLE!"); #endif apply_mirror (o->m_angle, o->r_angle, o->n_segs, o->c_x * boundary.width, o->c_y * boundary.height, o->o_x * (eff_boundary.width - eff_boundary.x) + eff_boundary.x, o->o_y * (eff_boundary.height - eff_boundary.y) + eff_boundary.y, o->input_scale / 100, o->clip, o->warp, format, input, &eff_boundary, output, &boundary, result, level); return TRUE; }
static gboolean process (GeglOperation *operation, GeglBuffer *input, GeglBuffer *output, const GeglRectangle *result) { GeglChantO *o = GEGL_CHANT_PROPERTIES (operation); GeglOperationAreaFilter *op_area = GEGL_OPERATION_AREA_FILTER (operation); Babl *format = babl_format ("RGBA float"); GeglRectangle rect; GeglRectangle boundary = get_effective_area (operation); gint x, y; gfloat *dst_buf, *src_buf; rect.x = CLAMP (result->x - op_area->left, boundary.x, boundary.x + boundary.width); rect.width = CLAMP (result->width + op_area->left + op_area->right, 0, boundary.width); rect.y = CLAMP (result->y - op_area->top, boundary.y, boundary.y + boundary.width); rect.height = CLAMP (result->height + op_area->top + op_area->bottom, 0, boundary.height); dst_buf = g_new0 (gfloat, result->height * result->width * 4); src_buf = g_new0 (gfloat, rect.height * rect.width * 4); gegl_buffer_get (input, 1.0, result, format, dst_buf, GEGL_AUTO_ROWSTRIDE); gegl_buffer_get (input, 1.0, &rect, format, src_buf, GEGL_AUTO_ROWSTRIDE); if (o->horizontal) { for (y = result->y; y < result->y + result->height; y++) if ((o->even && (y % 2 == 0)) || (!o->even && (y % 2 != 0))) deinterlace_horizontal (src_buf, dst_buf, result, &rect, &boundary, o->even ? 0 : 1, y, o->size); } else { for (x = result->x; x < result->x + result->width; x++) if ((o->even && (x % 2 == 0)) || (!o->even && (x % 2 != 0))) deinterlace_vertical (src_buf, dst_buf, result, &rect, &boundary, o->even ? 0 : 1, x, o->size); } gegl_buffer_set (output, result, format, dst_buf, GEGL_AUTO_ROWSTRIDE); g_free (src_buf); g_free (dst_buf); return TRUE; }
/* Compute the input rectangle required to compute the specified region of interest (roi). */ static GeglRectangle get_required_for_output (GeglOperation *operation, const gchar *input_pad, const GeglRectangle *roi) { GeglRectangle result = get_effective_area (operation); #ifdef TRACE g_warning ("> get_required_for_output src=%dx%d+%d+%d", result.width, result.height, result.x, result.y); if (roi) g_warning (" ROI == %dx%d+%d+%d", roi->width, roi->height, roi->x, roi->y); #endif return result; }
static gboolean process (GeglOperation *operation, GeglBuffer *input, GeglBuffer *output, const GeglRectangle *result, gint level) { GeglChantO *o = GEGL_CHANT_PROPERTIES (operation); GeglOperationAreaFilter *op_area = GEGL_OPERATION_AREA_FILTER (operation); GeglRectangle boundary = get_effective_area (operation); GeglRectangle extended; const Babl *format = babl_format ("RGBA float"); GRand *gr = g_rand_new_with_seed (o->seed); gfloat color[4]; gint cols, rows, num_tiles, count; gint *random_indices; gfloat *dst_buf; Polygon poly; gint i; extended.x = CLAMP (result->x - op_area->left, boundary.x, boundary.x + boundary.width); extended.width = CLAMP (result->width + op_area->left + op_area->right, 0, boundary.width); extended.y = CLAMP (result->y - op_area->top, boundary.y, boundary.y + boundary.width); extended.height = CLAMP (result->height + op_area->top + op_area->bottom, 0, boundary.height); dst_buf = g_new0 (gfloat, extended.width * extended.height * 4); cols = (result->width + o->tile_size - 1) / o->tile_size; rows = (result->height + o->tile_size - 1) / o->tile_size; num_tiles = (rows + 1) * (cols + 1); random_indices = g_new0 (gint, num_tiles); for (i = 0; i < num_tiles; i++) random_indices[i] = i; randomize_indices (num_tiles, random_indices, gr); for (count = 0; count < num_tiles; count++) { gint i, j, ix, iy; gdouble x, y, width, height, theta; i = random_indices[count] / (cols + 1); j = random_indices[count] % (cols + 1); x = j * o->tile_size + (o->tile_size / 4.0) - g_rand_double_range (gr, 0, (o->tile_size /2.0)) + result->x; y = i * o->tile_size + (o->tile_size / 4.0) - g_rand_double_range (gr, 0, (o->tile_size /2.0)) + result->y; width = (o->tile_size + g_rand_double_range (gr, -o->tile_size / 8.0, o->tile_size / 8.0)) * o->tile_saturation; height = (o->tile_size + g_rand_double_range (gr, -o->tile_size / 8.0, o->tile_size / 8.0)) * o->tile_saturation; theta = g_rand_double_range (gr, 0, 2 * G_PI); polygon_reset (&poly); polygon_add_point (&poly, -width / 2.0, -height / 2.0); polygon_add_point (&poly, width / 2.0, -height / 2.0); polygon_add_point (&poly, width / 2.0, height / 2.0); polygon_add_point (&poly, -width / 2.0, height / 2.0); polygon_rotate (&poly, theta); polygon_translate (&poly, x, y); ix = CLAMP (x, boundary.x, boundary.x + boundary.width - 1); iy = CLAMP (y, boundary.y, boundary.y + boundary.height - 1); gegl_buffer_sample (input, ix, iy, NULL, color, format, GEGL_SAMPLER_NEAREST, GEGL_ABYSS_NONE); fill_poly_color (&poly, &extended, &boundary, dst_buf, color); } gegl_buffer_set (output, &extended, 0, format, dst_buf, GEGL_AUTO_ROWSTRIDE); g_free (dst_buf); g_free (random_indices); g_free (gr); return TRUE; }
static gboolean process (GeglOperation *operation, GeglBuffer *input, GeglBuffer *output, const GeglRectangle *result, gint level) { GeglProperties *o = GEGL_PROPERTIES (operation); GeglOperationAreaFilter *op_area = GEGL_OPERATION_AREA_FILTER (operation); const Babl *format = babl_format ("RGBA float"); GeglRectangle rect; GeglRectangle boundary = get_effective_area (operation); gint x, y; gfloat *dst_buf, *src_buf; rect.x = CLAMP (result->x - op_area->left, boundary.x, boundary.x + boundary.width); rect.width = CLAMP (result->width + op_area->left + op_area->right, 0, boundary.width); rect.y = CLAMP (result->y - op_area->top, boundary.y, boundary.y + boundary.width); rect.height = CLAMP (result->height + op_area->top + op_area->bottom, 0, boundary.height); dst_buf = g_new0 (gfloat, result->height * result->width * 4); src_buf = g_new0 (gfloat, rect.height * rect.width * 4); gegl_buffer_get (input, result, 1.0, format, dst_buf, GEGL_AUTO_ROWSTRIDE, GEGL_ABYSS_NONE); gegl_buffer_get (input, &rect, 1.0, format, src_buf, GEGL_AUTO_ROWSTRIDE, GEGL_ABYSS_NONE); if (o->orientation == GEGL_ORIENTATION_HORIZONTAL) { for (y = result->y; y < result->y + result->height; y++) if ((o->keep == GEGL_DEINTERLACE_KEEP_EVEN && (y % 2 == 0)) || (o->keep == GEGL_DEINTERLACE_KEEP_ODD && (y % 2 != 0))) { deinterlace_horizontal (src_buf, dst_buf, result, &rect, &boundary, o->keep, y, o->size); } } else { for (x = result->x; x < result->x + result->width; x++) if ((o->keep == GEGL_DEINTERLACE_KEEP_EVEN && (x % 2 == 0)) || (o->keep == GEGL_DEINTERLACE_KEEP_ODD && (x % 2 != 0))) { deinterlace_vertical (src_buf, dst_buf, result, &rect, &boundary, o->keep, x, o->size); } } gegl_buffer_set (output, result, 0, format, dst_buf, GEGL_AUTO_ROWSTRIDE); g_free (src_buf); g_free (dst_buf); return TRUE; }
static gboolean process (GeglOperation *operation, GeglBuffer *input, GeglBuffer *output, const GeglRectangle *result, gint level) { GeglChantO *o = GEGL_CHANT_PROPERTIES (operation); GeglRectangle boundary = get_effective_area (operation); const Babl *format = babl_format ("RGBA float"); gint x,y; gfloat *src_buf, *dst_buf; gfloat dest[4]; gint i, offset = 0; gboolean inside; gdouble px, py; GeglMatrix2 scale; /* a matrix indicating scaling factors around the current center pixel. */ src_buf = g_new0 (gfloat, result->width * result->height * 4); dst_buf = g_new0 (gfloat, result->width * result->height * 4); gegl_buffer_get (input, result, 1.0, format, src_buf, GEGL_AUTO_ROWSTRIDE, GEGL_ABYSS_NONE); if (o->middle) { o->pole_x = boundary.width / 2; o->pole_y = boundary.height / 2; } for (y = result->y; y < result->y + result->height; y++) for (x = result->x; x < result->x + result->width; x++) { #define gegl_unmap(u,v,ud,vd) { \ gdouble rx, ry; \ inside = calc_undistorted_coords ((gdouble)x, (gdouble)y, \ &rx, &ry, o, boundary); \ ud = rx; \ vd = ry; \ } gegl_sampler_compute_scale (scale, x, y); gegl_unmap(x,y,px,py); #undef gegl_unmap if (inside) gegl_buffer_sample (input, px, py, &scale, dest, format, GEGL_SAMPLER_NOHALO, GEGL_ABYSS_NONE); else for (i=0; i<4; i++) dest[i] = 0.0; for (i=0; i<4; i++) dst_buf[offset++] = dest[i]; } gegl_buffer_set (output, result, 0, format, dst_buf, GEGL_AUTO_ROWSTRIDE); g_free (src_buf); g_free (dst_buf); return TRUE; }
static gboolean process (GeglOperation *operation, GeglBuffer *input, GeglBuffer *output, const GeglRectangle *result, gint level) { GeglChantO *o = GEGL_CHANT_PROPERTIES (operation); GeglOperationAreaFilter *op_area = GEGL_OPERATION_AREA_FILTER (operation); GeglRectangle rect; GeglRectangle boundary = get_effective_area (operation); gfloat *src_buf; gfloat *dst_buf; gdouble **matrix; gchar *type; gint x, y; gdouble matrixsum = 0.0; type = "RGBA float"; matrix = g_new0 (gdouble*, MATRIX_SIZE); for (x=0; x < MATRIX_SIZE ;x++) matrix[x] = g_new0 (gdouble, MATRIX_SIZE); make_matrix (o, matrix); if (o->norm) normalize_o (o, matrix); for (x=0; x < MATRIX_SIZE; x++) for (y=0; y < MATRIX_SIZE; y++) matrixsum += fabs (matrix[x][y]); rect.x = result->x - op_area->left; rect.width = result->width + op_area->left + op_area->right; rect.y = result->y - op_area->top; rect.height = result->height + op_area->top + op_area->bottom; src_buf = g_new0 (gfloat, rect.width * rect.height * 4); dst_buf = g_new0 (gfloat, result->width * result->height * 4); gegl_buffer_get (input, &rect, 1.0, babl_format (type), src_buf, GEGL_AUTO_ROWSTRIDE, GEGL_ABYSS_NONE); /*fill src_buf with wrap pixels if it is the case*/ if (o->div != 0) { for (y=result->y; y < result->height + result->y; y++) for (x=result->x; x < result->width + result->x; x++) convolve_pixel (src_buf, dst_buf, result, &rect, &boundary, matrix, o, input, x, y, matrixsum); gegl_buffer_set (output, result, 0, babl_format (type), dst_buf, GEGL_AUTO_ROWSTRIDE); } else gegl_buffer_set (output, &rect, 0, babl_format (type), src_buf, GEGL_AUTO_ROWSTRIDE); g_free (src_buf); g_free (dst_buf); return TRUE; }