repair default keyframe load, tweak init default histogram threshold
[goodguy/history.git] / cinelerra-5.1 / cinelerra / dcoffset.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 "bcprogressbox.h"
23 #include "dcoffset.h"
24 #include "language.h"
25 #include "mutex.h"
26 #include "recordgui.h"
27
28
29
30 DC_Offset::DC_Offset()
31  : Thread()
32 {
33         getting_dc_offset = 0;
34         for(int i = 0; i < MAXCHANNELS; i++) dc_offset[i] = 0;
35         dc_offset_lock = new Mutex;
36 }
37
38 DC_Offset::~DC_Offset()
39 {
40         delete dc_offset_lock;
41 }
42
43 void DC_Offset::calibrate_dc_offset(int *output, RecordGUIDCOffsetText **dc_offset_text, int input_channels)
44 {
45         this->output = output;
46         this->dc_offset_text = dc_offset_text;
47         this->input_channels = input_channels;
48         start();
49 }
50
51
52 void DC_Offset::run()
53 {
54 // thread out progress box
55         progress = new BC_ProgressBox((int)BC_INFINITY,
56                 (int)BC_INFINITY,
57                 _("DC Offset"),
58                 256000);
59         progress->start();
60
61         dc_offset_lock->lock();
62         dc_offset_count = 0;
63         for(int i = 0; i < input_channels; i++)
64         {
65                 dc_offset_total[i] = 0;
66                 dc_offset[i] = 0;
67         }
68         getting_dc_offset = 1;
69
70         dc_offset_lock->lock();       // wait for result
71         dc_offset_lock->unlock();
72
73 // thread in progress box
74         progress->stop_progress();
75         delete progress;
76
77         char string[256];
78         int i;
79
80 // update interface
81         for(i = 0; i < input_channels; i++) output[i] = dc_offset[i];
82         for(i = 0; i < input_channels; i++)
83         {
84                 sprintf(string, "%d", dc_offset[i]);
85                 dc_offset_text[i]->update(string);
86         }
87 }
88