fix boxblur segv, tweak guicast Makefile for 3rd party includes, fix title drag box...
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / resourcethread.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 RESOURCETHREAD_H
23 #define RESOURCETHREAD_H
24
25 // This thread tries to draw picons into the timeline, asynchronous
26 // of the navigation.
27
28 // TrackCanvas draws the picons which are in the cache and makes a table of
29 // picons and locations which need to be decompressed.  Then ResourceThread
30 // decompresses the picons and draws them one by one, refreshing the
31 // entire trackcanvas in the process.
32
33
34 #include "arraylist.h"
35 #include "bctimer.inc"
36 #include "condition.inc"
37 #include "file.inc"
38 #include "indexable.inc"
39 #include "maxchannels.h"
40 #include "mwindow.inc"
41 #include "renderengine.inc"
42 #include "samples.inc"
43 #include "thread.h"
44 #include "vframe.inc"
45
46
47 class ResourceThreadItem
48 {
49 public:
50         ResourceThreadItem(ResourcePixmap *pixmap,
51                 int pane_number,
52                 Indexable *indexable,
53                 int data_type,
54                 int operation_count);
55         virtual ~ResourceThreadItem();
56
57         ResourcePixmap *pixmap;
58         Indexable *indexable;
59         int data_type;
60         int operation_count;
61         int last;
62         int pane_number;
63 };
64
65
66 class AResourceThreadItem : public ResourceThreadItem
67 {
68 public:
69         AResourceThreadItem(ResourcePixmap *pixmap,
70                 int pane_number,
71                 Indexable *indexable,
72                 int x,
73                 int channel,
74                 int64_t start,
75                 int64_t end,
76                 int operation_count);
77         ~AResourceThreadItem();
78         int x;
79         int channel;
80         int64_t start;
81         int64_t end;
82 };
83
84 class VResourceThreadItem : public ResourceThreadItem
85 {
86 public:
87         VResourceThreadItem(ResourcePixmap *pixmap,
88                 int pane_number,
89                 int picon_x,
90                 int picon_y,
91                 int picon_w,
92                 int picon_h,
93                 double frame_rate,
94                 int64_t position,
95                 int layer,
96                 Indexable *indexable,
97                 int operation_count);
98         ~VResourceThreadItem();
99
100
101
102         int picon_x;
103         int picon_y;
104         int picon_w;
105         int picon_h;
106         double frame_rate;
107         int64_t position;
108         int layer;
109 };
110
111
112 class ResourceThread : public Thread
113 {
114 public:
115         ResourceThread(MWindow *mwindow, MWindowGUI *gui);
116         ~ResourceThread();
117
118
119         void create_objects();
120 // reset - delete all picons.  Used for index building.
121         void stop_draw(int reset);
122         void start_draw();
123
124 // Be sure to stop_draw before changing the asset table,
125 // closing files.
126         void add_picon(ResourcePixmap *pixmap,
127                 int pane_number,
128                 int picon_x,
129                 int picon_y,
130                 int picon_w,
131                 int picon_h,
132                 double frame_rate,
133                 int64_t position,
134                 int layer,
135                 Indexable *indexable);
136
137         void add_wave(ResourcePixmap *pixmap,
138                 int pane_number,
139                 Indexable *indexable,
140                 int x,
141                 int channel,
142 // samples relative to asset rate
143                 int64_t source_start,
144                 int64_t source_end);
145
146         void run();
147         void stop();
148
149         void do_video(VResourceThreadItem *item);
150         void do_audio(AResourceThreadItem *item);
151
152         void open_render_engine(EDL *nested_edl,
153                 int do_audio,
154                 int do_video);
155
156         File *get_video_source(Asset *asset);
157         File *get_audio_source(Asset *asset);
158
159         MWindow *mwindow;
160         MWindowGUI *gui;
161         Condition *draw_lock;
162         Mutex *item_lock;
163         ArrayList<ResourceThreadItem*> items;
164         int interrupted;
165         int done;
166         VFrame *temp_picon;
167         VFrame *temp_picon2;
168 // Render engine for nested EDL
169         RenderEngine *render_engine;
170 // ID of nested EDL being rendered
171         int render_engine_id;
172         Asset *audio_asset;
173         File *audio_source;
174         Asset *video_asset;
175         File *video_source;
176
177 // Current audio buffer for spanning multiple pixels
178         Samples *audio_buffer;
179 // Temporary for nested EDL
180         Samples *temp_buffer[MAX_CHANNELS];
181         int audio_channel;
182         int64_t audio_start;
183         int audio_samples;
184         int audio_asset_id;
185 // Timer for waveform refreshes
186         Timer *timer;
187 // Waveform state
188         int prev_x;
189         double prev_h;
190         double prev_l;
191 // Incremented after every start_draw to prevent overlapping operations
192         int operation_count;
193 };
194
195
196
197 #endif
198