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