[gegl] gegl-binary: add simple video filtering
- From: Øyvind Kolås <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] gegl-binary: add simple video filtering
- Date: Fri, 25 Mar 2016 00:31:15 +0000 (UTC)
commit ebe30d5ce0079967b9f34edb50758c4e8da5660f
Author: Øyvind Kolås <pippin gimp org>
Date: Fri Mar 25 00:19:13 2016 +0100
gegl-binary: add simple video filtering
bin/gegl.c | 106 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
bin/ui.c | 36 ++------------------
2 files changed, 110 insertions(+), 32 deletions(-)
---
diff --git a/bin/gegl.c b/bin/gegl.c
index 9638385..e8b4f40 100644
--- a/bin/gegl.c
+++ b/bin/gegl.c
@@ -58,6 +58,9 @@ gegl_enable_fatal_warnings (void)
g_log_set_always_fatal (fatal_mask);
}
+int gegl_str_has_image_suffix (char *path);
+int gegl_str_has_video_suffix (char *path);
+
static gboolean file_is_gegl_xml (const gchar *path)
{
gchar *extension;
@@ -154,6 +157,12 @@ main (gint argc,
{
gchar *file_basename = g_path_get_basename (o->file);
+ if (gegl_str_has_video_suffix (file_basename))
+ script = g_strconcat ("<gegl><gegl:ff-load path='",
+ file_basename,
+ "'/></gegl>",
+ NULL);
+ else
script = g_strconcat ("<gegl><gegl:load path='",
file_basename,
"'/></gegl>",
@@ -224,6 +233,64 @@ main (gint argc,
break;
case GEGL_RUN_MODE_OUTPUT:
+ if (gegl_str_has_video_suffix ((void*)o->output))
+ {
+ GeglNode *output = gegl_node_new_child (gegl,
+ "operation", "gegl:ff-save",
+ "path", o->output,
+ "video-bit-rate", 4000,
+ NULL);
+ {
+ GeglRectangle bounds = gegl_node_get_bounding_box (gegl);
+ GeglBuffer *tempb;
+ GeglNode *n0;
+ GeglNode *iter;
+ int frame_no = 0;
+ guchar *temp;
+
+ bounds.x *= o->scale;
+ bounds.y *= o->scale;
+ bounds.width *= o->scale;
+ bounds.height *= o->scale;
+ temp = gegl_malloc (bounds.width * bounds.height * 4);
+ tempb = gegl_buffer_new (&bounds, babl_format("R'G'B'A u8"));
+
+ n0 = gegl_node_new_child (gegl, "operation", "gegl:buffer-source",
+ "buffer", tempb,
+ NULL);
+ gegl_node_connect_from (output, "input", n0, "output");
+
+ iter = gegl_node_get_output_proxy (gegl, "output");
+
+ while (gegl_node_get_producer (iter, "input", NULL))
+ iter = (gegl_node_get_producer (iter, "input", NULL));
+ {
+ int duration = 0;
+ gegl_node_get (iter, "frames", &duration, NULL);
+
+ while (frame_no < duration)
+ {
+
+ gegl_node_blit (gegl, o->scale, &bounds, babl_format("R'G'B'A u8"), temp, GEGL_AUTO_ROWSTRIDE,
+ GEGL_BLIT_DEFAULT);
+
+ gegl_buffer_set (tempb, &bounds, 0.0, babl_format ("R'G'B'A u8"),
+ temp, GEGL_AUTO_ROWSTRIDE);
+
+ gegl_node_set (iter, "frame", frame_no, NULL);
+ fprintf (stderr, "\r%i/%i", frame_no, duration-1);
+ gegl_node_process (output);
+ frame_no ++;
+ }
+ fprintf (stderr, "\n");
+ }
+ gegl_free (temp);
+ g_object_unref (tempb);
+ g_object_unref (output);
+ }
+
+ }
+ else
{
GeglNode *output = gegl_node_new_child (gegl,
"operation", "gegl:save",
@@ -285,3 +352,42 @@ main (gint argc,
return 0;
}
+int gegl_str_has_image_suffix (char *path)
+{
+ return g_str_has_suffix (path, ".jpg") ||
+ g_str_has_suffix (path, ".png") ||
+ g_str_has_suffix (path, ".JPG") ||
+ g_str_has_suffix (path, ".PNG") ||
+ g_str_has_suffix (path, ".tif") ||
+ g_str_has_suffix (path, ".tiff") ||
+ g_str_has_suffix (path, ".TIF") ||
+ g_str_has_suffix (path, ".TIFF") ||
+ g_str_has_suffix (path, ".jpeg") ||
+ g_str_has_suffix (path, ".JPEG") ||
+ g_str_has_suffix (path, ".CR2") ||
+ g_str_has_suffix (path, ".cr2") ||
+ g_str_has_suffix (path, ".exr");
+}
+
+int gegl_str_has_video_suffix (char *path)
+{
+ return g_str_has_suffix (path, ".avi") ||
+ g_str_has_suffix (path, ".AVI") ||
+ g_str_has_suffix (path, ".mp4") ||
+ g_str_has_suffix (path, ".dv") ||
+ g_str_has_suffix (path, ".DV") ||
+ g_str_has_suffix (path, ".mp3") ||
+ g_str_has_suffix (path, ".MP3") ||
+ g_str_has_suffix (path, ".mpg") ||
+ g_str_has_suffix (path, ".ogv") ||
+ g_str_has_suffix (path, ".MPG") ||
+ g_str_has_suffix (path, ".webm") ||
+ g_str_has_suffix (path, ".MP4") ||
+ g_str_has_suffix (path, ".mkv") ||
+ g_str_has_suffix (path, ".gif") ||
+ g_str_has_suffix (path, ".GIF") ||
+ g_str_has_suffix (path, ".MKV") ||
+ g_str_has_suffix (path, ".mov") ||
+ g_str_has_suffix (path, ".ogg");
+}
+
diff --git a/bin/ui.c b/bin/ui.c
index 4d57534..ab492ed 100644
--- a/bin/ui.c
+++ b/bin/ui.c
@@ -250,40 +250,12 @@ char * gegl_meta_get (const char *path);
static void on_viewer_motion (MrgEvent *e, void *data1, void *data2);
-static int str_has_image_suffix (char *path)
-{
- return g_str_has_suffix (path, ".jpg") ||
- g_str_has_suffix (path, ".png") ||
- g_str_has_suffix (path, ".JPG") ||
- g_str_has_suffix (path, ".PNG") ||
- g_str_has_suffix (path, ".jpeg") ||
- g_str_has_suffix (path, ".JPEG") ||
- g_str_has_suffix (path, ".CR2") ||
- g_str_has_suffix (path, ".exr");
-}
-
-static int str_has_video_suffix (char *path)
-{
- return g_str_has_suffix (path, ".avi") ||
- g_str_has_suffix (path, ".AVI") ||
- g_str_has_suffix (path, ".mp4") ||
- g_str_has_suffix (path, ".mp3") ||
- g_str_has_suffix (path, ".mpg") ||
- g_str_has_suffix (path, ".ogv") ||
- g_str_has_suffix (path, ".MPG") ||
- g_str_has_suffix (path, ".webm") ||
- g_str_has_suffix (path, ".MP4") ||
- g_str_has_suffix (path, ".mkv") ||
- g_str_has_suffix (path, ".gif") ||
- g_str_has_suffix (path, ".GIF") ||
- g_str_has_suffix (path, ".MKV") ||
- g_str_has_suffix (path, ".mov") ||
- g_str_has_suffix (path, ".ogg");
-}
+int gegl_str_has_image_suffix (char *path);
+int gegl_str_has_video_suffix (char *path);
static int str_has_visual_suffix (char *path)
{
- return str_has_image_suffix (path) || str_has_video_suffix (path);
+ return gegl_str_has_image_suffix (path) || gegl_str_has_video_suffix (path);
}
static void populate_path_list (State *o)
@@ -1287,7 +1259,7 @@ static void load_path (State *o)
o->frame_no = 0;
o->prev_frame_played = 0;
- if (str_has_video_suffix (path))
+ if (gegl_str_has_video_suffix (path))
{
o->is_video = 1;
o->gegl = gegl_node_new ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]