port 7.2 mods: align_edits foreground plugin refresh_frame tweak, rework soundlevel...
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / filedv.h
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2004 Richard Baverstock
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 FILEDV_H
23 #define FILEDV_H
24
25 #ifdef HAVE_DV
26
27 #include "edl.inc"
28 #include "filebase.h"
29 #include "file.inc"
30
31 #ifdef DV_USE_FFMPEG
32 #include <avcodec.h>
33 #endif
34
35 #include <libdv/dv.h>
36
37
38 class FileDV : public FileBase
39 {
40 public:
41         FileDV(Asset *asset, File *file);
42         ~FileDV();
43
44         static void get_parameters(BC_WindowBase *parent_window,
45                 Asset *asset, BC_WindowBase* &format_window,
46                 int audio_options, int video_options, EDL *edl);
47
48         int reset_parameters_derived();
49         int open_file(int rd, int wr);
50
51         static int check_sig(Asset *asset);
52         int close_file_derived();
53
54         int64_t get_video_position();
55         int64_t get_audio_position();
56
57         int set_video_position(int64_t x);
58         int set_audio_position(int64_t x);
59
60         int audio_samples_copy(double **buffer, int64_t len);
61
62         int write_samples(double **buffer, int64_t len);
63         int write_frames(VFrame ***frames, int len);
64
65         int read_compressed_frame(VFrame *buffer);
66         int write_compressed_frame(VFrame *buffers);
67
68         int64_t compressed_frame_size();
69
70         int read_samples(double *buffer, int64_t len);
71         int read_frame(VFrame *frame);
72
73         int colormodel_supported(int colormodel);
74
75         int can_copy_from(Edit *edit, int64_t position);
76
77         static int get_best_colormodel(Asset *asset, int driver);
78
79         int get_audio_frame(int64_t pos);
80         int get_audio_offset(int64_t pos);
81
82 private:
83         FILE *stream;
84
85         Mutex *stream_lock;
86         Mutex *decoder_lock;
87         Mutex *video_position_lock;
88
89         dv_decoder_t *decoder;
90         dv_encoder_t *encoder;
91         dv_encoder_t *audio_encoder;
92
93         int64_t audio_position;
94         int64_t video_position;
95
96         unsigned char *video_buffer;
97         unsigned char *audio_buffer;
98
99         int16_t **audio_sample_buffer;
100         int audio_sample_buffer_start;
101         int audio_sample_buffer_end;
102         int audio_sample_buffer_len;
103         int audio_sample_buffer_maxsize;
104
105         int audio_frames_written;
106
107         int output_size;
108         int isPAL;
109 };
110
111
112 class DVConfigAudio: public BC_Window
113 {
114 public:
115         DVConfigAudio(BC_WindowBase *parent_window, Asset *asset);
116         ~DVConfigAudio();
117
118         void create_objects();
119         int close_event();
120
121 private:
122         Asset *asset;
123         BC_WindowBase *parent_window;
124 };
125
126
127
128 class DVConfigVideo: public BC_Window
129 {
130 public:
131         DVConfigVideo(BC_WindowBase *parent_window, Asset *asset);
132         ~DVConfigVideo();
133
134         void create_objects();
135         int close_event();
136
137 private:
138         Asset *asset;
139         BC_WindowBase *parent_window;
140 };
141
142
143 #endif
144 #endif