[gegl] refacor away c99isms
- From: Øyvind Kolås <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] refacor away c99isms
- Date: Fri, 14 Jul 2017 19:23:43 +0000 (UTC)
commit 9e7802fcb9f64dd6f5e3790b7ccad2d18c546e83
Author: Øyvind Kolås <pippin gimp org>
Date: Fri Jul 14 20:19:59 2017 +0200
refacor away c99isms
gcut/clip.c | 14 +++++---------
gcut/gcut-ui.c | 28 ++++++++++++++++------------
gcut/gcut.c | 47 +++++++++++++++++++++++++++--------------------
gcut/gcut.h | 11 +++++++++++
gcut/renderer.c | 9 ++++-----
5 files changed, 63 insertions(+), 46 deletions(-)
---
diff --git a/gcut/clip.c b/gcut/clip.c
index f7fc703..4d78bd2 100644
--- a/gcut/clip.c
+++ b/gcut/clip.c
@@ -48,10 +48,10 @@ Clip *clip_get_prev (Clip *self)
{
GList *l;
GeglEDL *edl;
+ Clip *prev = NULL;
if (!self)
return NULL;
edl = self->edl;
- Clip *prev = NULL;
for (l = edl->clips; l; l = l->next)
{
@@ -226,12 +226,6 @@ Clip *clip_new_full (GeglEDL *edl, const char *path, int start, int end)
return clip;
}
-void clip_fade_set (Clip *clip, int do_fade_out)
-{
- /* should cancel any computations due to fade when cancelling it, and add them when fade is set
- */
-}
-
const char *clip_get_path (Clip *clip)
{
return clip->path;
@@ -263,6 +257,7 @@ static void clip_set_proxied (Clip *clip)
}
}
+void clip_set_frame_no (Clip *clip, int clip_frame_no);
void clip_set_frame_no (Clip *clip, int clip_frame_no)
{
if (clip_frame_no < 0)
@@ -353,7 +348,7 @@ void remove_in_betweens (GeglNode *nop_scaled, GeglNode *nop_filtered)
gegl_node_link_many (nop_scaled, nop_filtered, NULL);
}
-void clip_rig_chain (Clip *clip, int clip_frame_no)
+static void clip_rig_chain (Clip *clip, int clip_frame_no)
{
GeglEDL *edl = clip->edl;
int use_proxies = edl->use_proxies;
@@ -417,6 +412,7 @@ gchar *clip_get_frame_hash (Clip *clip, int clip_frame_no)
{
GeglEDL *edl = clip->edl;
gchar *frame_recipe;
+ char *ret;
GChecksum *hash;
int is_static_source = clip_is_static_source (clip);
@@ -430,7 +426,7 @@ gchar *clip_get_frame_hash (Clip *clip, int clip_frame_no)
hash = g_checksum_new (G_CHECKSUM_MD5);
g_checksum_update (hash, (void*)frame_recipe, -1);
- char *ret = g_strdup (g_checksum_get_string(hash));
+ ret = g_strdup (g_checksum_get_string(hash));
g_checksum_free (hash);
g_free (frame_recipe);
diff --git a/gcut/gcut-ui.c b/gcut/gcut-ui.c
index 3b0f285..1563163 100644
--- a/gcut/gcut-ui.c
+++ b/gcut/gcut-ui.c
@@ -1937,7 +1937,7 @@ static void select_node (MrgEvent *e, void *data1, void *data2)
mrg_queue_draw (e->mrg, NULL);
}
-static void rounded_rectangle (cairo_t *cr, double x, double y, double width, double height, double aspect,
+static inline void rounded_rectangle (cairo_t *cr, double x, double y, double width, double height, double
aspect,
double corner_radius)
{
double radius;
@@ -2242,6 +2242,7 @@ static char **gcut_get_completions (const char *filter_query)
static void complete_filter_query_edit (MrgEvent *e, void *data1, void *data2)
{
+ GeglNode *new = NULL;
GeglEDL *edl = data1;
gchar **completions = gcut_get_completions (filter_query);
if (!selected_node)
@@ -2250,7 +2251,6 @@ static void complete_filter_query_edit (MrgEvent *e, void *data1, void *data2)
if (!completions)
return;
- GeglNode *new = NULL;
new = gegl_node_new_child (edl->gegl, "operation", completions[0], NULL);
if (filter_query)
g_free (filter_query);
@@ -2287,28 +2287,28 @@ static void update_filter_query (const char *new_string, void *user_data)
}
-void gcut_draw (Mrg *mrg,
- GeglEDL *edl,
- double x0,
- double y,
- double fpx,
- double t0)
+static void gcut_draw (Mrg *mrg,
+ GeglEDL *edl,
+ double x0,
+ double y,
+ double fpx,
+ double t0)
{
GList *l;
cairo_t *cr = mrg_cr (mrg);
double t;
+ int clip_frame_no;
+ int scroll_height = mrg_height (mrg) * (1.0 - SPLIT_VER) * 0.2;
int duration = gcut_get_duration (edl); // causes update of abs_start
+ float y2 = y - mrg_em (mrg) * 1.5;
VID_HEIGHT = mrg_height (mrg) * (1.0 - SPLIT_VER) * 0.8;
- int scroll_height = mrg_height (mrg) * (1.0 - SPLIT_VER) * 0.2;
t = 0;
- int clip_frame_no;
if (duration == 0)
return;
- float y2 = y - mrg_em (mrg) * 1.5;
edl->active_clip = gcut_get_clip (edl, edl->frame_no, &clip_frame_no);
@@ -2406,6 +2406,7 @@ void gcut_draw (Mrg *mrg,
t += frames;
}
+ {
int start = 0, end = 0;
gcut_get_range (edl, &start, &end);
cairo_rectangle (cr, start, y, end - start, scroll_height);
@@ -2443,6 +2444,7 @@ void gcut_draw (Mrg *mrg,
cairo_rectangle (cr, t0, y, mrg_width(mrg)*fpx, VID_HEIGHT);
mrg_listen (mrg, MRG_DROP, drag_dropped, edl, edl);
cairo_new_path (cr);
+ }
for (l = edl->clips; l; l = l->next)
{
@@ -2531,6 +2533,7 @@ void gcut_draw (Mrg *mrg,
cairo_fill (cr);
}
+ {
double frame = edl->frame_no;
if (fpx < 1.0)
cairo_rectangle (cr, frame, y-PAD_DIM, 1.0, VID_HEIGHT + PAD_DIM * 2);
@@ -2543,6 +2546,7 @@ void gcut_draw (Mrg *mrg,
cairo_rectangle (cr, 0, y - PAD_DIM, mrg_width (mrg), VID_HEIGHT + PAD_DIM * 4);
mrg_listen (mrg, MRG_SCROLL, zoom_timeline, edl, NULL);
cairo_new_path (cr);
+ }
}
static const char *css =
@@ -2584,7 +2588,7 @@ static void toggle_ui_mode (MrgEvent *event, void *data1, void *data2)
changed++;
}
-void help_ui (Mrg *mrg, GeglEDL *edl)
+static void help_ui (Mrg *mrg, GeglEDL *edl)
{
if (help)
{
diff --git a/gcut/gcut.c b/gcut/gcut.c
index da7923a..0216e3b 100644
--- a/gcut/gcut.c
+++ b/gcut/gcut.c
@@ -285,12 +285,14 @@ gchar *gcut_get_frame_hash_full (GeglEDL *edl, int frame,
char *clip1_hash = clip_get_frame_hash (prev, frame - prev_clip_start + clip_get_start (prev));
double ratio = 0.5 + ((frame-clip_start) * 1.0 / prev_fade_len)/2;
char *str = g_strdup_printf ("%s %s %f", clip1_hash, clip0_hash, ratio);
+ GChecksum *hash = g_checksum_new (G_CHECKSUM_MD5);
+ char *ret;
+
g_free (clip0_hash);
g_free (clip1_hash);
- GChecksum *hash = g_checksum_new (G_CHECKSUM_MD5);
g_checksum_update (hash, (void*)str, -1);
g_free (str);
- char *ret = g_strdup (g_checksum_get_string(hash));
+ ret = g_strdup (g_checksum_get_string(hash));
g_checksum_free (hash);
if (clip0) *clip0 = prev;
if (clip0_frame) *clip0_frame = frame - prev_clip_start + clip_get_start (prev);
@@ -306,13 +308,14 @@ gchar *gcut_get_frame_hash_full (GeglEDL *edl, int frame,
char *clip0_hash = clip_get_frame_hash (clip, clip_frame_no);
char *clip1_hash = clip_get_frame_hash (next, frame - (clip_start + clip_frames) + clip_get_start
(next));
double ratio = (1.0-(clip_frames-(frame-clip_start)) * 1.0 / next_fade_len)/2;
+ GChecksum *hash = g_checksum_new (G_CHECKSUM_MD5);
char *str = g_strdup_printf ("%s %s %f", clip0_hash, clip1_hash, ratio);
+ char *ret;
g_free (clip0_hash);
g_free (clip1_hash);
- GChecksum *hash = g_checksum_new (G_CHECKSUM_MD5);
g_checksum_update (hash, (void*)str, -1);
g_free (str);
- char *ret = g_strdup (g_checksum_get_string(hash));
+ ret = g_strdup (g_checksum_get_string(hash));
g_checksum_free (hash);
if (clip0) *clip0 = clip;
if (clip0_frame) *clip0_frame = clip_frame_no;
@@ -362,19 +365,21 @@ void gcut_update_buffer (GeglEDL *edl)
*/
void gcut_set_frame (GeglEDL *edl, int frame)
{
+ Clip *clip0; int clip0_frame;
+ Clip *clip1; int clip1_frame;
+
if ((edl->frame) == frame && (frame != 0))
{
return;
}
- edl->frame = frame;
+ {
- Clip *clip0; int clip0_frame;
- Clip *clip1; int clip1_frame;
double mix;
char *frame_hash = gcut_get_frame_hash_full (edl, frame, &clip0, &clip0_frame, &clip1, &clip1_frame, &mix);
char *cache_path = g_strdup_printf ("%s.gcut/cache/%s", edl->parent_path, frame_hash);
+ edl->frame = frame;
g_free (frame_hash);
if (g_file_test (cache_path, G_FILE_TEST_IS_REGULAR) &&
(edl->cache_flags & CACHE_TRY_ALL))
@@ -393,8 +398,10 @@ void gcut_set_frame (GeglEDL *edl, int frame)
clip->audio = gegl_audio_fragment_new (44100, 2, 0, 44100);
gegl_meta_get_audio (cache_path, clip->audio);
}
+ {
GeglRectangle ext = gegl_node_get_bounding_box (edl->result);
gegl_buffer_set_extent (edl->buffer, &ext);
+ }
gegl_node_process (edl->store_final_buf);
gcut_update_buffer (edl);
@@ -456,6 +463,7 @@ void gcut_set_frame (GeglEDL *edl, int frame)
}
g_free (cache_path);
+ }
}
void gcut_set_time (GeglEDL *edl, double seconds)
@@ -484,11 +492,6 @@ GeglAudioFragment *gcut_get_audio (GeglEDL *edl)
Clip * clip = edl_get_clip_for_frame (edl, edl->frame);
return clip?clip->audio:NULL;
}
-const char *gcut_get_clip_path (GeglEDL *edl)
-{
- Clip * clip = edl_get_clip_for_frame (edl, edl->frame);
- return clip?clip->clip_path:"";
-}
void gcut_get_video_info (const char *path, int *duration, double *fps)
{
@@ -517,7 +520,7 @@ int gcut_get_duration (GeglEDL *edl)
}
#include <string.h>
-void gcut_parse_clip (GeglEDL *edl, const char *line)
+static void gcut_parse_clip (GeglEDL *edl, const char *line)
{
int start = 0; int end = 0; int duration = 0;
const char *rest = NULL;
@@ -781,13 +784,16 @@ void gcut_save_path (GeglEDL *edl, const char *path)
sprintf (backup_path, "%s.gcut/history/%s-", edl->parent_path, basename(edl->path));
+ {
time_t now = time(NULL);
tim = gmtime(&now);
+ }
strftime(backup_path + strlen(backup_path), sizeof(backup_path)-strlen(backup_path), "%Y%m%d_%H%M%S",
tim);
rename (path, backup_path);
}
+ {
FILE *file = fopen (path, "w");
if (!file)
{
@@ -801,6 +807,7 @@ void gcut_save_path (GeglEDL *edl, const char *path)
g_free (serialized);
}
fclose (file);
+ }
}
void gcut_update_video_size (GeglEDL *edl)
@@ -840,7 +847,7 @@ static GTimer * timer = NULL;
static guint timeout_id = 0;
static gdouble throttle = 4.0;
-void gcut_reread (GeglEDL *edl)
+static void gcut_reread (GeglEDL *edl)
{
GeglEDL *new_edl = gcut_new_from_path (edl->path);
GList *l;
@@ -898,7 +905,7 @@ static void file_changed (GFileMonitor *monitor,
}
}
-void
+static void
gcut_monitor_start (GeglEDL *edl)
{
if (!edl->path)
@@ -1011,13 +1018,13 @@ static void encode_frames (GeglEDL *edl)
fprintf (stdout, "\n");
}
-void nop_handler(int sig)
+static void nop_handler(int sig)
{
}
static int stop_cacher = 0;
-void handler1(int sig)
+static void handler1(int sig)
{
stop_cacher = 1;
}
@@ -1036,12 +1043,12 @@ static void process_frames_cache (GeglEDL *edl)
int frame_no = edl->frame_no;
int frame_start = edl->frame_no;
int duration;
- signal(SIGUSR2, handler1);
- duration = gcut_get_duration (edl);
GList *l;
int clip_start = 0;
+ signal(SIGUSR2, handler1);
+ duration = gcut_get_duration (edl);
// TODO: use bitmap from ui to speed up check
edl->frame_no = frame_start;
@@ -1199,7 +1206,7 @@ void gcut_make_proxies (GeglEDL *edl)
}
}
-void gcut_start_sanity (void)
+static void gcut_start_sanity (void)
{
int fails = 0;
if (system("which ffmpeg > /dev/null") != 0)
diff --git a/gcut/gcut.h b/gcut/gcut.h
index e51c4dc..99938b9 100644
--- a/gcut/gcut.h
+++ b/gcut/gcut.h
@@ -246,6 +246,16 @@ void update_size (GeglEDL *edl, Clip *clip);
void remove_in_betweens (GeglNode *nop_scaled, GeglNode *nop_filtered);
int is_connected (GeglNode *a, GeglNode *b);
void gcut_update_buffer (GeglEDL *edl);
+void gcut_cache_invalid (GeglEDL *edl);
+
+
+gchar *gcut_get_frame_hash (GeglEDL *edl, int frame);
+
+gchar *gcut_get_frame_hash_full (GeglEDL *edl, int frame,
+ Clip **clip0, int *clip0_frame,
+ Clip **clip1, int *clip1_frame,
+ double *mix);
+int gegl_make_thumb_image (GeglEDL *edl, const char *path, const char *icon_path);
#ifdef MICRO_RAPTOR_GUI
/* renderer.h */
@@ -253,6 +263,7 @@ void renderer_toggle_playing (MrgEvent *event, void *data1, void *data2);
void gcut_cache_invalid (GeglEDL *edl);
int renderer_done (GeglEDL *edl);
void renderer_start (GeglEDL *edl);
+gboolean cache_renderer_iteration (Mrg *mrg, gpointer data);
#endif
diff --git a/gcut/renderer.c b/gcut/renderer.c
index 2774a59..f0d54fa 100644
--- a/gcut/renderer.c
+++ b/gcut/renderer.c
@@ -5,8 +5,8 @@
#include <signal.h>
#include <stdio.h>
#include <gegl.h>
-#include "gcut.h"
#include <mrg.h>
+#include "gcut.h"
#include <SDL.h>
#include <gegl-audio-fragment.h>
@@ -83,7 +83,7 @@ static void open_audio (int frequency)
}
}
-void end_audio (void)
+static void end_audio (void)
{
}
@@ -93,7 +93,7 @@ static inline void skipped_frames (int count)
//fprintf (stderr, "[%i]", count);
}
-static inline void wait_for_frame ()
+static inline void wait_for_frame (void)
{
//fprintf (stderr, ".");
}
@@ -228,7 +228,6 @@ void playing_iteration (Mrg *mrg, GeglEDL *edl)
mrg_queue_draw (mrg, NULL);
return;
}
- //delta = 0;
{
#if 0
static int frameskip = -1;
@@ -265,8 +264,8 @@ void playing_iteration (Mrg *mrg, GeglEDL *edl)
if (edl->active_clip)
{
- edl->frame_no += delta;
int start, end;
+ edl->frame_no += delta;
gcut_get_range (edl, &start, &end);
if (edl->frame_no > max_frame (edl))
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]