Olive
clip.h
1 /***
2 
3  Olive - Non-Linear Video Editor
4  Copyright (C) 2019 Olive Team
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 3 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, see <http://www.gnu.org/licenses/>.
18 
19 ***/
20 
21 #ifndef CLIP_H
22 #define CLIP_H
23 
24 #include <QWaitCondition>
25 #include <QMutex>
26 #include <QVector>
27 
28 #include "marker.h"
29 
30 class Cacher;
31 class Effect;
32 class Transition;
33 class QOpenGLFramebufferObject;
34 class ComboAction;
35 class Media;
36 struct Sequence;
37 struct Footage;
38 struct FootageStream;
39 
40 struct AVFormatContext;
41 struct AVStream;
42 struct AVCodec;
43 struct AVCodecContext;
44 struct AVFrame;
45 struct AVPacket;
46 struct SwsContext;
47 struct SwrContext;
48 struct AVFilterGraph;
49 struct AVFilterContext;
50 struct AVDictionary;
51 class QOpenGLTexture;
52 
53 class Clip {
54 public:
55  Clip(Sequence* s);
56  ~Clip();
57  Clip* copy(Sequence* s, bool duplicate_transitions = true);
58  void reset_audio();
59  void reset();
60  void refresh();
61  long get_clip_in_with_transition();
62  long get_timeline_in_with_transition();
63  long get_timeline_out_with_transition();
64  long getLength();
65  double getMediaFrameRate();
66  long getMaximumLength();
67  void recalculateMaxLength();
68  int getWidth();
69  int getHeight();
70  void refactor_frame_rate(ComboAction* ca, double multiplier, bool change_timeline_points);
71  Sequence* sequence;
72 
73  // queue functions
74  void queue_clear();
75  void queue_remove_earliest();
76 
77  // timeline variables (should be copied in copy())
78  bool enabled;
79  long clip_in;
80  long timeline_in;
81  long timeline_out;
82  int track;
83  QString name;
84  quint8 color_r;
85  quint8 color_g;
86  quint8 color_b;
87  Media* media;
88  int media_stream;
89  double speed;
90  double cached_fr;
91  bool reverse;
92  bool maintain_audio_pitch;
93  bool autoscale;
94 
95  // markers
96  QVector<Marker>& get_markers();
97 
98  // other variables (should be deep copied/duplicated in copy())
99  QList<Effect*> effects;
100  QVector<int> linked;
101  int opening_transition;
102  Transition* get_opening_transition();
103  int closing_transition;
104  Transition* get_closing_transition();
105 
106  // media handling
107  AVFormatContext* formatCtx;
108  AVStream* stream;
109  AVCodec* codec;
110  AVCodecContext* codecCtx;
111  AVPacket* pkt;
112  AVFrame* frame;
113  AVDictionary* opts;
114  long calculated_length;
115 
116  // temporary variables
117  int load_id;
118  bool undeletable;
119  bool reached_end;
120  bool pkt_written;
121  bool open;
122  bool finished_opening;
123  bool replaced;
124  bool ignore_reverse;
125  int pix_fmt;
126 
127  // caching functions
128  bool use_existing_frame;
129  bool multithreaded;
130  Cacher* cacher;
131  QWaitCondition can_cache;
132  int max_queue_size;
133  QVector<AVFrame*> queue;
134  QMutex queue_lock;
135  QMutex lock;
136  QMutex open_lock;
137  int64_t last_invalid_ts;
138 
139  // converters/filters
140  AVFilterGraph* filter_graph;
141  AVFilterContext* buffersink_ctx;
142  AVFilterContext* buffersrc_ctx;
143 
144  // video playback variables
145  QOpenGLFramebufferObject** fbo;
146  QOpenGLTexture* texture;
147  long texture_frame;
148 
149  // audio playback variables
150  int64_t reverse_target;
151  int frame_sample_index;
152  qint64 audio_buffer_write;
153  bool audio_reset;
154  bool audio_just_reset;
155  long audio_target_frame;
156 private:
157  QVector<Marker> markers;
158 };
159 
160 #endif // CLIP_H
Definition: sequence.h:33
Definition: undo.h:52
Definition: effect.h:166
Definition: cacher.h:29
Definition: media.h:40
Definition: footage.h:45
Definition: clip.h:53
Definition: transition.h:39
Definition: footage.h:66