[gegl] bin: permit start/end times for playlist items
- From: Øyvind "pippin" Kolås <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] bin: permit start/end times for playlist items
- Date: Thu, 9 May 2019 11:17:26 +0000 (UTC)
commit fcd69e2f12bbfce3d6f83c9714a8a3f25a134ad6
Author: Øyvind Kolås <pippin gimp org>
Date: Thu May 9 13:12:13 2019 +0200
bin: permit start/end times for playlist items
bin/lua/init.lua | 3 +++
bin/lua/viewer.lua | 24 ++++++++++++++++++------
bin/ui-core.c | 55 +++++++++++++++++++++++++++++++++++++++++++-----------
bin/ui.h | 2 ++
4 files changed, 67 insertions(+), 17 deletions(-)
---
diff --git a/bin/lua/init.lua b/bin/lua/init.lua
index c1319eb13..900e562b3 100644
--- a/bin/lua/init.lua
+++ b/bin/lua/init.lua
@@ -1,6 +1,7 @@
ffi = require('ffi')
lgi = require 'lgi'
+math = require 'math'
os = require 'os'
GLib = lgi.GLib
@@ -119,6 +120,8 @@ struct _GeState {
int playing;
double pos;
double duration;
+ double start;
+ double end;
int color_managed_display;
int is_video;
diff --git a/bin/lua/viewer.lua b/bin/lua/viewer.lua
index 43e082c71..4349a27be 100644
--- a/bin/lua/viewer.lua
+++ b/bin/lua/viewer.lua
@@ -341,8 +341,19 @@ if 1 ~= 0 then
cr:rectangle(height * .1 , height * .9, width - height * .2, height *.1)
mrg:listen(Mrg.DRAG, function(event)
+
o.pos = (event.x - height *.15) / (width - height * .3) * frames
- sink:set_time(o.pos)
+
+ sink:set_time(o.pos + o.start)
+ if o.is_video ~= 0 then
+ source = GObject.Object(STATE).source
+ local frames = source:get_property('frames').value
+ local pos = (event.x - height *.15) / (width - height * .3)
+ source:set_property('frame',
+ GObject.Value(GObject.Type.INT,
+ math.floor(pos * frames)
+ ))
+ end
event:stop_propagate()
end)
cr:new_path()
@@ -366,7 +377,8 @@ function draw_thumb_bar()
cr:set_source_rgba(1,1,1,.1)
cr:rectangle(0, mrg:height()*0.8, mrg:width(), mrg:height()*0.2)
mrg:listen(Mrg.MOTION, function(e)
- print('a') end)
+ -- print('a')
+ end)
cr:fill()
mrg:print("thumbbar" .. o:item_no() .. '' .. o:item_path())
end
@@ -428,7 +440,7 @@ mrg:add_binding("alt-right", NULL, "next image",
mrg:add_binding("alt-left", NULL, "rev image",
function() ffi.C.argvs_eval ("prev") end)
-mrg:add_binding("control-s", NULL, "toggle playing",
+mrg:add_binding("space", NULL, "toggle playing",
function() ffi.C.argvs_eval ("toggle playing") end)
mrg:add_binding("control-m", NULL, "toggle mipmap",
@@ -488,6 +500,6 @@ end
cr:restore()
-if o.playing ~= 0 then
- print 'o'
-end
+--if o.playing ~= 0 then
+ -- print 'o'
+--end
diff --git a/bin/ui-core.c b/bin/ui-core.c
index 0b4237bf8..31bc95699 100644
--- a/bin/ui-core.c
+++ b/bin/ui-core.c
@@ -1065,6 +1065,8 @@ int mrg_ui_main (int argc, char **argv, char **ops)
}
mrg_main (mrg);
+
+
has_quit = 1;
if (renderer == GEGL_RENDERER_THREAD)
g_thread_join (o->renderer_thread);
@@ -1083,7 +1085,7 @@ cmd_apos (COMMAND_ARGS)
{
GeState *o = global_state;
o->pos = g_strtod (argv[1], NULL);
- gegl_node_set_time (o->sink, o->pos);
+ gegl_node_set_time (o->sink, o->pos + o->start);
return 0;
}
@@ -4334,13 +4336,12 @@ static void iterate_frame (GeState *o)
o->pos += delta/1000.0;
- if (frame_accum > 1000 / 25) // 25fps
+ if (frame_accum > 1000 / 25) // 25fps
{
- gegl_node_set_time (o->sink, o->pos);
+ gegl_node_set_time (o->sink, o->pos + o->start);
frame_accum = 0;
}
- frame_accum += delta;
-
+ frame_accum += delta;
}
if (o->pos > o->duration)
@@ -4349,7 +4350,7 @@ static void iterate_frame (GeState *o)
}
else
{
- fprintf (stderr, "%.3f/%.3f %f%%\n", o->pos, o->duration, 100.0*(o->pos/o->duration ));
+ //fprintf (stderr, "%.3f/%.3f %.3f %f%%\n", o->pos, o->duration, o->end, 100.0*(o->pos/o->duration ));
}
@@ -5586,11 +5587,26 @@ static void load_path_inner (GeState *o,
o->dir_scale = 1.0;
o->rev = 0;
- o->duration = meta_get_attribute_float (o, NULL, o->entry_no, "duration");
+ o->start = o->end = 0.0;
+ o->duration = -1;
+ //if (o->duration < 0)
+ {
+ double start = meta_get_attribute_float (o, NULL, o->entry_no, "start");
+ double end = meta_get_attribute_float (o, NULL, o->entry_no, "end");
+ if (start >= 0 && end >= 0)
+ {
+ o->start = start;
+ o->end = end;
+ o->duration = o->end - o->start;
+ }
+ }
if (o->duration < 0)
- o->duration = o->slide_pause;
+ {
+ o->duration = meta_get_attribute_float (o, NULL, o->entry_no, "duration");
+ o->end = o->duration;
+ }
+ //if (o->duration < 0)
- o->pos = 0.0;
o->is_video = 0;
o->prev_frame_played = 0;
o->thumbbar_pan_x = 0;
@@ -5634,6 +5650,17 @@ static void load_path_inner (GeState *o,
o->source = gegl_node_new_child (o->gegl,
"operation", "gegl:ff-load", "path", path, NULL);
gegl_node_link_many (o->source, o->sink, NULL);
+
+ if (o->duration < 0)
+ {
+ double fps = 0.0;
+ gint frames = 0;
+ gegl_node_process (o->source);
+ gegl_node_get (o->source, "frame-rate", &fps, "frames", &frames, NULL);
+ if (fps > 0.0 && frames > 0)
+ o->duration = frames / fps;
+ }
+
}
else
{
@@ -5663,7 +5690,7 @@ static void load_path_inner (GeState *o,
else
{
o->gegl = gegl_node_new_from_serialized (meta, containing_path);
- gegl_node_set_time (o->gegl, 0.0);
+ gegl_node_set_time (o->gegl, o->start);
}
g_free (containing_path);
o->sink = o->gegl;
@@ -5727,6 +5754,12 @@ static void load_path_inner (GeState *o,
}
}
+ if (o->duration < 0)
+ {
+ o->duration = o->slide_pause;
+ o->end = o->duration;
+ }
+
if (o->ops)
{
GeglNode *ret_sink = NULL;
@@ -5734,7 +5767,6 @@ static void load_path_inner (GeState *o,
char *containing_path = get_path_parent (path);
-
gegl_create_chain_argv (o->ops,
gegl_node_get_producer (o->sink, "input", NULL),
o->sink, 2.1, gegl_node_get_bounding_box (o->sink).height,
@@ -5751,6 +5783,7 @@ static void load_path_inner (GeState *o,
exit(0);
}
}
+ o->pos = 0.0;
activate_sink_producer (o);
diff --git a/bin/ui.h b/bin/ui.h
index dc063b365..819d9f41e 100644
--- a/bin/ui.h
+++ b/bin/ui.h
@@ -148,6 +148,8 @@ struct _GeState {
int playing;
double pos;
double duration;
+ double start;
+ double end;
int color_managed_display;
int is_video;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]