no longer need ffmpeg patch0 which was for Termux
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / edit.h
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  *
20  */
21
22 #ifndef EDIT_H
23 #define EDIT_H
24
25 #include <stdio.h>
26 #include <stdint.h>
27
28 #include "asset.inc"
29 #include "edl.inc"
30 #include "guicast.h"
31 #include "edits.inc"
32 #include "filexml.inc"
33 #include "indexable.inc"
34 #include "mwindow.inc"
35 #include "plugin.inc"
36 #include "track.inc"
37 #include "transition.inc"
38
39 // UNITS ARE SAMPLES FOR AUDIO / FRAMES FOR VIDEO
40 // zoom_units was mwindow->zoom_sample for AEdit
41
42 // Generic edit of something
43
44 class Edit : public ListItem<Edit>
45 {
46 public:
47         Edit(EDL *edl, Edits *edits);
48         Edit(EDL *edl, Track *track);
49         Edit();
50         virtual ~Edit();
51
52         void reset();
53
54         Indexable* get_source();
55 // Copy from different EDL
56         virtual void copy_from(Edit *edit);
57         virtual void clone_from(Edit *edit);
58 // Compare with edit in same EDL
59         virtual int identical(Edit &edit);
60         virtual Edit& operator=(Edit& edit);
61 // Called by Edits and PluginSet.
62 // Compare with edit in different EDL
63         virtual void equivalent_output(Edit *edit, int64_t *result);
64         virtual int operator==(Edit& edit);
65 // When inherited by a plugin need to resample keyframes
66         virtual void synchronize_params(Edit *edit);
67 // Used by Edits::insert_edits to shift plugin keyframes
68         virtual void shift_keyframes(int64_t position) {};
69         virtual int is_plugin() { return 0; }
70         virtual int is_transition() { return 0; }
71
72 // Get size of frame to draw on timeline
73         double picon_w();
74         int picon_h();
75         double frame_w();
76         double frames_per_picon();
77         int copy(int64_t start, int64_t end, FileXML *xml, const char *output_path);
78 // When inherited by a plugin need to resample keyframes
79         virtual void resample(double old_rate, double new_rate) {};
80
81 // Shift in time
82         virtual void shift(int64_t difference);
83
84         void trim(int64_t difference);
85         int shift_start(int edit_mode, int64_t newposition, int64_t oldposition,
86                 int edit_labels, int edit_autos, int edit_plugins, Edits *trim_edits);
87         int shift_end(int edit_mode, int64_t newposition, int64_t oldposition,
88                 int edit_labels, int edit_autos, int edit_plugins, Edits *trim_edits);
89         int follow_edits(int64_t start, int64_t end, int64_t cut_length,
90                 int edits_moved, int rest_moved, int edit_labels, int edit_autos,
91                 int edit_plugins, Edits *trim_edits);
92
93         void insert_transition(char  *title);
94         void detach_transition();
95 // Determine if silence depending on existance of asset or plugin title
96         virtual int silence();
97         void set_selected(int v);
98         void select_affected_edits(int v, int gang);
99
100 // Media edit information
101 // Units are native units for the track.
102 // Start of edit in source file normalized to project sample rate.
103 // Normalized because all the editing operations clip startsource relative
104 // to the project sample rate;
105         int64_t startsource;
106 // Start of edit in project file.
107         int64_t startproject;
108 // # of units in edit.
109         int64_t length;
110 // Channel or layer of source
111         int channel;
112 // ID for resource pixmaps, plugins
113         int id, orig_id;
114 // ID for selection groups
115         int group_id;
116 // User defined title for timeline
117         char user_title[BCTEXTLEN];
118         int is_selected;
119 // edge cannot be optimized
120         int hard_left, hard_right;
121 // title bar color
122         int color;
123 // Transition if one is present at the beginning of this edit
124 // This stores the length of the transition
125         Transition *transition;
126
127         Edits *edits;
128         Track *track;
129
130 // points to an object in edl->assets if set
131         Asset *asset;
132 // points to an object in edl->nested_edls if set
133         EDL *nested_edl;
134 // Asset and nested_edl are 0 if silence
135
136 // Parent EDL of this edit
137         EDL *edl;
138
139         int load_properties(FileXML *xml, int64_t &startproject);
140         virtual int load_properties_derived(FileXML *xml) { return 0; };
141
142         virtual int copy_properties_derived(FileXML *xml,
143                 int64_t length_in_selection) { return 0; }
144
145         int popup_transition(float view_start, float zoom_units, int cursor_x, int cursor_y);
146
147 // Return 1 if the left handle was selected 2 if the right handle was selected
148         int select_handle(float view_start, float zoom_units,
149                 int cursor_x, int cursor_y, int64_t &selection);
150         virtual int get_handle_parameters(int64_t &left, int64_t &right,
151                 int64_t &left_sample, int64_t &right_sample, float view_start,
152                 float zoom_units) { return 0; }
153         virtual int64_t get_source_end(int64_t default_);
154         void get_title(char *title);
155
156         int dump(FILE *fp=stdout);
157         virtual int dump_derived() { return 0; }
158 };
159
160 #endif