no longer need ffmpeg patch0 which was for Termux
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / fileformat.C
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 #include "asset.h"
23 #include "assets.h"
24 #include "bitspopup.h"
25 #include "fileformat.h"
26 #include "language.h"
27 #include "mwindow.h"
28 #include "mwindowgui.h"
29 #include "new.h"
30
31
32
33 FileFormat::FileFormat(MWindow *mwindow)
34  : BC_Window(_(PROGRAM_NAME ": File Format"),
35                 mwindow->gui->get_abs_cursor_x(0),
36                 mwindow->gui->get_abs_cursor_y(0),
37                 xS(375), yS(300), xS(375), yS(300))
38 {
39         this->mwindow = mwindow;
40 // *** CONTEXT_HELP ***
41         context_help_set_keyword("Single File Rendering");
42 }
43
44 FileFormat::~FileFormat()
45 {
46         lock_window("FileFormat::~FileFormat");
47         delete lohi;
48         delete hilo;
49         delete signed_button;
50         delete header_button;
51         delete rate_button;
52         delete channels_button;
53         delete bitspopup;
54         unlock_window();
55 }
56
57 void FileFormat::create_objects(Asset *asset, char *string2)
58 {
59 // ================================= copy values
60         this->asset = asset;
61         create_objects_(string2);
62 }
63
64 void FileFormat::create_objects_(char *string2)
65 {
66         int xs10 = xS(10);
67         int ys20 = yS(20), ys30 = yS(30);
68         char string[1024];
69         int x1 = xs10, x2 = xS(180);
70         int x = x1, y = xs10;
71
72         lock_window("FileFormat::create_objects_");
73         add_subwindow(new BC_Title(x, y, string2));
74         y += ys20;
75         add_subwindow(new BC_Title(x, y, _("Assuming raw PCM:")));
76
77         y += ys30;
78         add_subwindow(new BC_Title(x, y, _("Channels:")));
79         sprintf(string, "%d", asset->channels);
80         channels_button = new FileFormatChannels(x2, y, this, string);
81         channels_button->create_objects();
82
83         y += ys30;
84         add_subwindow(new BC_Title(x, y, _("Sample rate:")));
85         sprintf(string, "%d", asset->sample_rate);
86         add_subwindow(rate_button = new FileFormatRate(x2, y, this, string));
87         add_subwindow(new SampleRatePulldown(mwindow, rate_button, x2 + yS(100), y));
88
89         y += ys30;
90         add_subwindow(new BC_Title(x, y, _("Bits:")));
91         bitspopup = new BitsPopup(this, x2, y,
92                 &asset->bits, 0, 1, 1, 0, 1);
93         bitspopup->create_objects();
94
95         y += ys30;
96         add_subwindow(new BC_Title(x, y, _("Header length:")));
97         sprintf(string, "%d", asset->header);
98         add_subwindow(header_button = new FileFormatHeader(x2, y, this, string));
99
100         y += ys30;
101
102 //printf("FileFormat::create_objects_ 1 %d\n", asset->byte_order);
103         add_subwindow(new BC_Title(x, y, _("Byte order:")));
104         add_subwindow(lohi = new FileFormatByteOrderLOHI(x2, y, this, asset->byte_order));
105         add_subwindow(hilo = new FileFormatByteOrderHILO(x2 + 70, y, this, !asset->byte_order));
106
107         y += ys30;
108         add_subwindow(signed_button = new FileFormatSigned(x, y, this, asset->signed_));
109
110         add_subwindow(new BC_OKButton(this));
111         add_subwindow(new BC_CancelButton(this));
112
113         show_window(1);
114         unlock_window();
115 }
116
117 FileFormatChannels::FileFormatChannels(int x, int y, FileFormat *fwindow, char *text)
118  : BC_TumbleTextBox(fwindow, (int)atol(text), (int)1, (int)MAXCHANNELS, x, y, 50)
119 {
120         this->fwindow = fwindow;
121 }
122
123 int FileFormatChannels::handle_event()
124 {
125         fwindow->asset->channels = atol(get_text());
126         return 0;
127 }
128
129 FileFormatRate::FileFormatRate(int x, int y, FileFormat *fwindow, char *text)
130  : BC_TextBox(x, y, 100, 1, text)
131 {
132         this->fwindow = fwindow;
133 }
134
135 int FileFormatRate::handle_event()
136 {
137         fwindow->asset->sample_rate = atol(get_text());
138         return 0;
139 }
140
141 FileFormatHeader::FileFormatHeader(int x, int y, FileFormat *fwindow, char *text)
142  : BC_TextBox(x, y, 100, 1, text)
143 {
144         this->fwindow = fwindow;
145 }
146
147 int FileFormatHeader::handle_event()
148 {
149         fwindow->asset->header = atol(get_text());
150         return 0;
151 }
152
153 FileFormatByteOrderLOHI::FileFormatByteOrderLOHI(int x, int y, FileFormat *fwindow, int value)
154  : BC_Radial(x, y, value, _("Lo Hi"))
155 {
156         this->fwindow = fwindow;
157 }
158
159 int FileFormatByteOrderLOHI::handle_event()
160 {
161         update(1);
162         fwindow->asset->byte_order = 1;
163         fwindow->hilo->update(0);
164         return 1;
165 }
166
167 FileFormatByteOrderHILO::FileFormatByteOrderHILO(int x, int y, FileFormat *fwindow, int value)
168  : BC_Radial(x, y, value, _("Hi Lo"))
169 {
170         this->fwindow = fwindow;
171 }
172
173 int FileFormatByteOrderHILO::handle_event()
174 {
175         update(1);
176         fwindow->asset->byte_order = 0;
177         fwindow->lohi->update(0);
178         return 1;
179 }
180
181 FileFormatSigned::FileFormatSigned(int x, int y, FileFormat *fwindow, int value)
182  : BC_CheckBox(x, y, value, _("Values are signed"))
183 {
184         this->fwindow = fwindow;
185 }
186
187 int FileFormatSigned::handle_event()
188 {
189         fwindow->asset->signed_ = get_value();
190         return 1;
191 }