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; }
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; }