update shuttlerc, fix vwdw lock update_position
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / filescene.h
1 /*
2  * CINELERRA
3  * Copyright (C) 2011 Adam Williams <broadcast at earthling dot net>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18  *
19  */
20
21
22
23 #ifndef FILESCENE_H
24 #define FILESCENE_H
25
26
27 #include "filebase.h"
28 #include "scenegraph.inc"
29
30 // Simple text to movie converter.
31 // Initially we're trying to render the entire movie in the file handler.
32 // Ideally the file handler would just translate the script into scene graphs &
33 // audio with the 3D pipeline integrated into Cinelerra.
34
35
36 class SceneTokens;
37 class FileScene;
38
39
40
41
42 // Parsed script
43
44
45
46
47
48 class SceneChar
49 {
50 public:
51         SceneChar(SceneTokens *script);
52         ~SceneChar();
53
54 // called by renderer to keep track of cameras
55         void increment_camera();
56         int read_model();
57         void dump();
58         int get_memory_usage();
59
60 // Name of character in script
61         char name[BCTEXTLEN];
62 // Festival voice for character
63         char voice[BCTEXTLEN];
64 // Name of model
65         char model[BCTEXTLEN];
66
67
68         SceneTokens *script;
69         SceneNode *body;
70         SceneNode *head;
71         int body_order;
72         int head_order;
73         ArrayList<SceneNode *> mouths;
74         ArrayList<SceneNode *> eyes;
75
76 // the model faces left instead of right
77         int faces_left;
78
79 // automated camera when this character is speaking
80 // increments for each chunk
81         int current_camera;
82         enum
83         {
84                 CAMERA_WIDE,
85                 CAMERA_CU,
86                 CAMERA_TOTAL
87         };
88
89         int is_speeking;
90 // Volume for mouth image
91         double max;
92
93 // Extents are all floating point for 3D
94 // Dimensions of model
95         float w, h;
96         float scale;
97 };
98
99
100 // Dialog from a single character
101 class SceneChunk
102 {
103 public:
104         SceneChunk(SceneTokens *script);
105         ~SceneChunk();
106
107         void dump();
108         void append_text(char *new_chunk);
109 // Render the audio
110         void render();
111         int get_memory_usage();
112
113 // Rendered output
114         unsigned char *audio;
115 // Nonzero if it has been rendered
116 // Units are bytes since we have WAV headers
117         int audio_size;
118         int audio_allocated;
119 // Number of samples to advance dialog playback.
120 // May be shorter than the audio to get characters to talk simultaneously.
121         int advance_samples;
122 // If it was used in the last buffer read
123         int used;
124 // Loudest audio segment
125         double max;
126
127 // Dialogue
128         char *text;
129 // Command
130         int command;
131         enum
132         {
133                 NO_COMMAND,
134                 PAUSE_COMMAND,
135         };
136
137 // Pointer to character
138         SceneChar *character;
139         SceneTokens *script;
140 };
141
142 // Entire script
143 class SceneTokens
144 {
145 public:
146         SceneTokens(FileScene *file, int cpus);
147         ~SceneTokens();
148
149         int read_script(char *path);
150 // Get character or create new one if it doesn't exist
151         SceneChar* get_character(char *name);
152         SceneChar* get_character(int number);
153         int get_char_number(SceneChar *ptr);
154 // Create a new text token & return it
155         SceneChunk* new_chunk();
156         SceneChunk* get_chunk(int number);
157         int get_memory_usage();
158 // Number of text objects
159         int total_chunks();
160 // Number of characters
161         int total_characters();
162         void dump();
163 // Convert asset path to path relatiive to script
164         void convert_path(char *dst, char *src);
165 // Load image with path completion
166         VFrame* load_image(char *path);
167         void render_background(SceneGraph *scene);
168
169         ArrayList<SceneChunk*> chunks;
170         ArrayList<SceneChar*> characters;
171         char background[BCTEXTLEN];
172 // Path the script was read from
173         char path[BCTEXTLEN];
174 // Decompressed assets
175         VFrame *background_image;
176 //      OverlayFrame *overlayer;
177         int64_t timestamp;
178         int cpus;
179         FileScene *file;
180 };
181
182
183 class FileScene : public FileBase
184 {
185 public:
186         FileScene(Asset *asset, File *file);
187         ~FileScene();
188
189         int open_file(int rd, int wr);
190         int close_file();
191         static int check_sig(Asset *asset, char *test);
192
193         int set_video_position(int64_t x);
194         int set_audio_position(int64_t x);
195         int read_frame(VFrame *frame);
196         int read_samples(double *buffer, int64_t len);
197         int64_t get_memory_usage();
198 // Direct copy routines
199         static int get_best_colormodel(Asset *asset, int driver);
200         int colormodel_supported(int colormodel);
201         int can_copy_from(Asset *asset, int64_t position); // This file can copy frames directly from the asset
202         int reset_parameters_derived();
203
204 // Path to all prepackaged assets
205         char exec_path[BCTEXTLEN];
206
207
208 private:
209         int read_script();
210         void render_chunks(int64_t start_position, int64_t len, int all_channels);
211
212 // Temporary buffer for speech output
213         int16_t *audio_temp;
214 // In samples
215         int temp_allocated;
216
217 // Parsed script
218         SceneTokens *script;
219 //      OverlayFrame *overlayer;
220 //      AffineEngine *affine;
221 };
222
223
224
225
226
227
228
229 #endif
230
231
232