gcut.h 9.14 KB
Newer Older
1
#if TODO
2 3 4 5 6 7 8

  bugs
    huge video files cause (cairo) thumtrack overflow, vertical also has this problem - how to split?
    if the initial frame is not a representative video frame of the comp, audio glitches
    ogv render files are more compatible than generated mp4 files, firefox among few that renders the mp4 in audio sync

  roadmap/missing features
9
    move gcut to gegl git repo
10 11 12 13 14 15 16 17 18 19 20 21 22 23

    engine
      support for configuring the final background render to be as high
      fidelity as GEGL processing allows - rather than sharing tuning for
      preview rendering.

      using edl files as clip sources - hopefully without even needing caches.

      global filters
        overlaying of audio from wav / mp3 files
        operation chains
        subtitles

    ui
24
      selection is offset/inprecise after port to seconds
25
      start using css
26
      port gcut-ui.c to lua
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
      detect locked or crashed ui, kill and respawn
      trimming by mouse / dragging clips around by mouse
      show a modal ui-block when generating proxies/thumbtrack on media import, instead of blocking/being blank
      gaps in timeline (will be implemented as blank clips - but ui could be different)
      insert videos from the commandline
      ui for adding/editing global filters/annotation/sound bits/beeps


#endif

#define CACHE_FORMAT "jpg"
#define GEDL_SAMPLER   GEGL_SAMPLER_NEAREST

#ifndef GEDL_H
#define GEDL_H

#include <gio/gio.h>

typedef struct _GeglEDL GeglEDL;
typedef struct _Clip    Clip;

48
void gcut_set_use_proxies (GeglEDL *edl, int use_proxies);
49
int         gegl_make_thumb_video (GeglEDL *edl, const char *path, const char *thumb_path);
50
char *gcut_make_proxy_path (GeglEDL *edl, const char *clip_path);
51 52 53 54 55 56 57 58 59 60 61 62
const char *compute_cache_path    (const char *path);

#define CACHE_TRY_SIMPLE    (1<<0)
#define CACHE_TRY_MIX       (1<<1)
#define CACHE_TRY_FILTERED  (1<<2)
#define CACHE_TRY_ALL       (CACHE_TRY_SIMPLE | CACHE_TRY_FILTERED | CACHE_TRY_MIX)
#define CACHE_MAKE_FILTERED (1<<3)
#define CACHE_MAKE_SIMPLE   (1<<4)
#define CACHE_MAKE_MIX      (1<<5)
#define CACHE_MAKE_ALL      (CACHE_MAKE_SIMPLE|CACHE_MAKE_MIX|CACHE_MAKE_FILTERED)

enum {
63 64 65
  GEDL_UI_MODE_NONE = 0,
  GEDL_UI_MODE_PART = 1,
  GEDL_UI_MODE_FULL = 2,
66
  GEDL_UI_MODE_TIMELINE = 3,
67 68
};

69
#define GEDL_LAST_UI_MODE  GEDL_UI_MODE_FULL
70

71 72 73
GeglEDL    *gcut_new                (void);
void        gcut_free               (GeglEDL    *edl);
void        gcut_set_fps            (GeglEDL    *edl,
74
                                     double      fps);
75
double      gcut_get_fps            (GeglEDL    *edl);
76
double      gcut_get_duration       (GeglEDL    *edl);
77 78 79 80 81
void        gcut_parse_line         (GeglEDL    *edl, const char *line);
GeglEDL    *gcut_new_from_path      (const char *path);
void        gcut_load_path          (GeglEDL    *edl, const char *path);
void        gcut_save_path          (GeglEDL    *edl, const char *path);
GeglAudioFragment  *gcut_get_audio  (GeglEDL    *edl);
82
Clip       *gcut_get_clip           (GeglEDL *edl, double pos, double *clip_frame_pos);
83

84 85
void        gcut_set_pos            (GeglEDL    *edl, double pos);
double      gcut_get_pos            (GeglEDL    *edl);
86 87
char       *gcut_serialize          (GeglEDL    *edl);

88
void        gcut_set_range          (GeglEDL    *edl, double start, double end);
89
void        gcut_get_range          (GeglEDL    *edl,
90 91
                                     double     *start,
                                     double     *end);
92

93
void        gcut_set_selection      (GeglEDL    *edl, double start, double end);
94
void        gcut_get_selection      (GeglEDL    *edl,
95 96
                                     double     *start,
                                     double     *end);
97 98
char       *gcut_make_thumb_path    (GeglEDL    *edl, const char *clip_path);
guchar     *gcut_get_cache_bitmap   (GeglEDL *edl, int *length_ret);
99 100 101 102


Clip       *clip_new               (GeglEDL *edl);
void        clip_free              (Clip *clip);
103
const char *clip_get_path          (Clip *clip);
104
void        clip_set_path          (Clip *clip, const char *path);
105 106 107 108 109 110
double      clip_get_start         (Clip *clip);
double      clip_get_end           (Clip *clip);
double      clip_get_duration      (Clip *clip);
void        clip_set_start         (Clip *clip, double start);
void        clip_set_end           (Clip *clip, double end);
void        clip_set_range         (Clip *clip, double start, double end);
111
int         clip_is_static_source  (Clip *clip);
112
gchar *     clip_get_pos_hash      (Clip *clip, double clip_frame_pos);
113 114 115
Clip  *     clip_get_next          (Clip *self);
Clip  *     clip_get_prev          (Clip *self);
void        clip_fetch_audio       (Clip *clip);
116 117
void        clip_set_full          (Clip *clip, const char *path, double start, double end);
Clip  *     clip_new_full          (GeglEDL *edl, const char *path, double start, double end);
118 119

//void   clip_set_frame_no      (Clip *clip, int frame_no);
120
void        clip_render_pos     (Clip *clip, double clip_frame_pos);
121

122
Clip *      edl_get_clip_for_pos   (GeglEDL           *edl, double pos);
123
void        gcut_make_proxies      (GeglEDL           *edl);
124
void        gcut_get_video_info    (const char        *path, int *frames, double *duration, double *fps);
125 126 127 128 129
void        gegl_meta_set_audio    (const char        *path,
                                    GeglAudioFragment *audio);
void        gegl_meta_get_audio    (const char        *path,
                                    GeglAudioFragment *audio);

130
#define SPLIT_VER  0.666
131

132
extern char *gcut_binary_path;
133 134 135 136 137 138

/*********/

struct _Clip
{
  char  *path;  /*path to media file */
139
  char  *title;
140 141 142
  double start; /*frame number starting with 0 */
  double end;   /*last frame, inclusive fro single frame, make equal to start */
  double duration;
143 144
  int    editing;
  char  *filter_graph; /* chain of gegl filters */
145
  
146 147 148
  GeglEDL *edl;

  double fps;
149 150 151 152 153
  double fade; /* the control is for the fade in of the clip - potential
                  fade out is controlled by next clip */

  double rate; /* playback rate, 1.0 = realtime */

154 155 156 157
  int    static_source;
  int    is_chain;
  int    is_meta;

158
  double    abs_start;
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181

  const char        *clip_path;
  GeglNode          *gegl;
  GeglAudioFragment *audio;
  GeglNode          *chain_loader;
  GeglNode          *full_loader;
  GeglNode          *proxy_loader;
  GeglNode          *loader; /* nop that one of the prior is linked to */

  GeglNode          *nop_scaled;
  GeglNode          *nop_crop;
  GeglNode          *nop_store_buf;

  GMutex             mutex;
};

struct _GeglEDL
{
  GFileMonitor *monitor;
  char         *path;
  char         *parent_path;
  GList        *clip_db;
  GList        *clips;
182

183 184
  int           frame; /* render thread, frame_no_ui is ui side */
  double        pos;   /* render thread, frame_pos_ui is ui side */
185 186 187 188 189 190 191 192 193 194 195 196
  double        fps;
  GeglBuffer   *buffer;
  GeglBuffer   *buffer_copy_temp;
  GeglBuffer   *buffer_copy;
  GMutex        buffer_copy_mutex;
  GeglNode     *cached_result;
  GeglNode     *gegl;
  int           playing;
  int           width;
  int           height;
  GeglNode     *cache_loader;
  int           cache_flags;
197 198 199 200
  double        selection_start;
  double        selection_end;
  double        range_start;
  double        range_end;
201 202 203 204 205 206 207 208 209 210 211 212 213
  const char   *output_path;
  const char   *video_codec;
  const char   *audio_codec;
  int           proxy_width;
  int           proxy_height;
  int           video_width;
  int           video_height;
  int           video_size_default;
  int           video_bufsize;
  int           video_bitrate;
  int           video_tolerance;
  int           audio_bitrate;
  int           audio_samplerate;
214 215
  double        frame_pos_ui;
  int           source_frame_pos;
216 217 218 219 220
  int           use_proxies;
  int           framedrop;
  int           ui_mode;

  GeglNode     *mix;
221 222 223
  GeglNode     *video_result;
  GeglNode     *final_result;
  GeglNode     *store_final_buf;
224 225 226 227 228 229

  GeglNode     *encode;
  double        scale;
  double        t0;
  Clip         *active_clip;

230 231
  Clip         *active_overlay;

232 233 234 235 236 237 238 239 240 241
  void         *mrg;

  char         *clip_query;
  int           clip_query_edited;
  int           filter_edited;
} _GeglEDL;

void update_size (GeglEDL *edl, Clip *clip);
void remove_in_betweens (GeglNode *nop_scaled, GeglNode *nop_filtered);
int  is_connected (GeglNode *a, GeglNode *b);
242
void gcut_update_buffer (GeglEDL *edl);
243 244 245
void gcut_cache_invalid (GeglEDL *edl);


246
gchar *gcut_get_pos_hash (GeglEDL *edl, double pos);
247

248 249 250 251
gchar *gcut_get_pos_hash_full (GeglEDL *edl, double pos,
                               Clip **clip0, double *clip0_pos,
                               Clip **clip1, double *clip1_pos,
                               double *mix);
252
int gegl_make_thumb_image (GeglEDL *edl, const char *path, const char *icon_path);
253

254 255 256 257 258 259 260 261 262 263
static inline double gcut_snap_pos (double fps, double inpos)
{
  return ((int)(inpos * fps + 0.5)) / fps;
}

static inline void gcut_snap_ui_pos (GeglEDL *edl)
{
  edl->frame_pos_ui = gcut_snap_pos (edl->fps, edl->frame_pos_ui);
}

264 265 266
#ifdef MICRO_RAPTOR_GUI
 /* renderer.h */
void renderer_toggle_playing (MrgEvent *event, void *data1, void *data2);
267
void gcut_cache_invalid (GeglEDL *edl);
268 269
int renderer_done (GeglEDL *edl);
void renderer_start (GeglEDL *edl);
270
gboolean cache_renderer_iteration (Mrg *mrg, gpointer data);
271 272 273 274

#endif

#endif