rework keyframe hide popup, keyframe auto render, textbox set_selection wide text
[goodguy/history.git] / cinelerra-5.1 / cinelerra / vdevicelml.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 VDEVICELML_H
23 #define VDEVICELML_H
24
25 #include "guicast.h"
26 #include "vdevicebase.h"
27
28 #include "jpeg.h"
29
30 #define INPUT_BUFFER_SIZE 65536
31
32 class VDeviceLML : public VDeviceBase
33 {
34 public:
35         VDeviceLML(VideoDevice *device);
36         ~VDeviceLML();
37
38         int open_input();
39         int open_output();
40         int close_all();
41         int read_buffer(VFrame *frame);
42         int write_buffer(VFrame *frame, EDL *edl);
43         int reset_parameters();
44         ArrayList<int>* get_render_strategies();
45
46 private:
47         int reopen_input();
48
49         inline unsigned char get_byte()
50         {
51                 if(!input_buffer) input_buffer = new unsigned char[INPUT_BUFFER_SIZE];
52                 if(input_position >= INPUT_BUFFER_SIZE) refill_input();
53                 return input_buffer[input_position++];
54         };
55
56         inline unsigned long next_bytes(int total)
57         {
58                 unsigned long result = 0;
59                 int i;
60
61                 if(!input_buffer) input_buffer = new unsigned char[INPUT_BUFFER_SIZE];
62                 if(input_position + total > INPUT_BUFFER_SIZE) refill_input();
63
64                 for(i = 0; i < total; i++)
65                 {
66                         result <<= 8;
67                         result |= input_buffer[input_position + i];
68                 }
69                 return result;
70         };
71
72         int refill_input();
73         inline int write_byte(unsigned char byte)
74         {
75                 if(!frame_buffer)
76                 {
77                         frame_buffer = new unsigned char[256000];
78                         frame_allocated = 256000;
79                 }
80
81                 if(frame_size >= frame_allocated)
82                 {
83                         unsigned char *new_frame = new unsigned char[frame_allocated * 2];
84                         memcpy(new_frame, frame_buffer, frame_size);
85                         delete frame_buffer;
86                         frame_buffer = new_frame;
87                         frame_allocated *= 2;
88                 }
89
90                 frame_buffer[frame_size++] = byte;
91                 return 0;
92         };
93
94         int write_fake_marker();
95
96         FILE *jvideo_fd;
97         unsigned char *input_buffer, *frame_buffer;
98         long input_position;
99         long frame_size, frame_allocated;
100         int input_error;
101 //      quicktime_mjpeg_hdr jpeg_header;
102         long last_frame_no;
103         ArrayList<int> render_strategies;
104 };
105
106 #endif