]> git.sesse.net Git - vlc/blob - modules/video_filter/atmo/AtmoConfig.cpp
1249bebd343ff42b49ba96d81f1da9759ed4a2fd
[vlc] / modules / video_filter / atmo / AtmoConfig.cpp
1 /*
2  * AtmoConfig.cpp: Class for holding all configuration values of AtmoWin - stores
3  * the values and retrieves its values from registry
4  *
5  * See the README.txt file for copyright information and how to reach the author(s).
6  *
7  * $Id$
8  */
9
10 #include <stdio.h>
11 #include <string.h>
12
13 #include "AtmoConfig.h"
14
15 /* Import Hint
16
17    if somebody Adds new config option this has to be done in the following
18    files and includes!
19
20    AtmoConfig.h  -- extend class definition!, and add get... and set... Methods!
21                     so that the real variables are still hidden inside the class!
22    AtmoConfigRegistry.cpp --> SaveToRegistry();
23    AtmoConfigRegistry.cpp --> LoadFromRegistry();
24    AtmoConfig.cpp --> Assign( ... );
25
26 */
27
28 CAtmoConfig::CAtmoConfig()
29 {
30   // setup basic configruation structures...
31   m_IsShowConfigDialog = 0;
32   m_eAtmoConnectionType = actSerialPort;
33   for(int i=0;i<10;i++)
34       m_ChannelAssignments[i] = NULL;
35 #if defined (_ATMO_VLC_PLUGIN_)
36   m_devicename = NULL;
37 #endif
38   // load all config values with there defaults
39   LoadDefaults();
40
41   //   CAtmoZoneDefinition *m_ZoneDefinitions[ATMO_NUM_CHANNELS];
42   // generate default channel parameters which may be loaded later from .bmp files
43   for(int i=0;i<ATMO_NUM_CHANNELS;i++) {
44       m_ZoneDefinitions[i] = new CAtmoZoneDefinition();
45       m_ZoneDefinitions[i]->setZoneNumber(i);
46       switch(i) {
47           case 0:  // summary channel
48               m_ZoneDefinitions[i]->Fill(255);
49               break;
50           case 1: // left channel
51               m_ZoneDefinitions[i]->FillGradientFromLeft();
52               break;
53           case 2: // right channel
54               m_ZoneDefinitions[i]->FillGradientFromRight();
55               break;
56           case 3: // top channel
57               m_ZoneDefinitions[i]->FillGradientFromTop();
58               break;
59           case 4: // bottom channel
60               m_ZoneDefinitions[i]->FillGradientFromBottom();
61               break;
62       }
63   }
64 }
65
66 CAtmoConfig::~CAtmoConfig() {
67    // and finally cleanup...
68    clearAllChannelMappings();
69 #if !defined (WIN32)
70    if(m_devicename)
71       free(m_devicename);
72 #endif
73 }
74
75 void CAtmoConfig::LoadDefaults() {
76     //    m_eAtmoConnectionType = actSerialPort;
77     //    m_Comport
78
79     m_eEffectMode = emDisabled;
80
81     m_WhiteAdjustment_Red    = 255;
82     m_WhiteAdjustment_Green  = 255;
83     m_WhiteAdjustment_Blue   = 255;
84         m_UseSoftwareWhiteAdj    = 1;
85
86         m_ColorChanger_iSteps    = 50;
87         m_ColorChanger_iDelay    = 25;
88
89         m_LrColorChanger_iSteps  = 50;
90         m_LrColorChanger_iDelay  = 25;
91
92     m_IsSetShutdownColor     = 1;
93         m_ShutdownColor_Red      = 0;
94         m_ShutdownColor_Green    = 0;
95         m_ShutdownColor_Blue     = 0;
96
97     m_StaticColor_Red        = 127; // ??
98     m_StaticColor_Green      = 192;
99     m_StaticColor_Blue       = 255;
100
101     m_LiveViewFilterMode         = afmCombined;
102     m_LiveViewFilter_PercentNew  = 50;
103     m_LiveViewFilter_MeanLength  = 300;
104     m_LiveViewFilter_MeanThreshold   = 40;
105
106     m_LiveView_EdgeWeighting  = 8;
107     m_LiveView_BrightCorrect  = 100;
108     m_LiveView_DarknessLimit  = 5;
109     m_LiveView_HueWinSize     = 3;
110     m_LiveView_SatWinSize     = 3;
111     m_LiveView_WidescreenMode = 0;
112
113     m_LiveView_HOverscanBorder  = 0;
114     m_LiveView_VOverscanBorder  = 0;
115     m_LiveView_DisplayNr        = 0;
116     m_LiveView_FrameDelay       = 0;
117
118
119     m_Hardware_global_gamma    = 128;
120     m_Hardware_global_contrast = 100;
121     m_Hardware_contrast_red    = 100;
122     m_Hardware_contrast_green  = 100;
123     m_Hardware_contrast_blue   = 100;
124
125     m_Hardware_gamma_red       = 22;
126     m_Hardware_gamma_green     = 22;
127     m_Hardware_gamma_blue      = 22;
128
129     clearAllChannelMappings();
130     m_CurrentChannelAssignment = 0;
131     tChannelAssignment* temp = new tChannelAssignment;
132     temp->system = true;
133     for(int i=0;i<ATMO_NUM_CHANNELS;i++)
134         temp->mappings[i] = i;
135     strcpy(temp->name,"Standard");
136     this->m_ChannelAssignments[0] =  temp;
137 }
138
139 void CAtmoConfig::Assign(CAtmoConfig *pAtmoConfigSrc) {
140
141 #if defined(_ATMO_VLC_PLUGIN_)
142     this->setSerialDevice(pAtmoConfigSrc->getSerialDevice());
143 #else
144     this->m_Comport                  = pAtmoConfigSrc->m_Comport;
145 #endif
146
147     this->m_eAtmoConnectionType      = pAtmoConfigSrc->m_eAtmoConnectionType;
148     this->m_eEffectMode              = pAtmoConfigSrc->m_eEffectMode;
149
150     this->m_WhiteAdjustment_Red      = pAtmoConfigSrc->m_WhiteAdjustment_Red;
151     this->m_WhiteAdjustment_Green    = pAtmoConfigSrc->m_WhiteAdjustment_Green;
152     this->m_WhiteAdjustment_Blue     = pAtmoConfigSrc->m_WhiteAdjustment_Blue;
153     this->m_UseSoftwareWhiteAdj      = pAtmoConfigSrc->m_UseSoftwareWhiteAdj;
154
155     this->m_IsSetShutdownColor       = pAtmoConfigSrc->m_IsSetShutdownColor;
156     this->m_ShutdownColor_Red        = pAtmoConfigSrc->m_ShutdownColor_Red;
157     this->m_ShutdownColor_Green      = pAtmoConfigSrc->m_ShutdownColor_Green;
158     this->m_ShutdownColor_Blue       = pAtmoConfigSrc->m_ShutdownColor_Blue;
159
160     this->m_ColorChanger_iSteps      = pAtmoConfigSrc->m_ColorChanger_iSteps;
161     this->m_ColorChanger_iDelay      = pAtmoConfigSrc->m_ColorChanger_iDelay;
162
163     this->m_LrColorChanger_iSteps    = pAtmoConfigSrc->m_LrColorChanger_iSteps;
164     this->m_LrColorChanger_iDelay    = pAtmoConfigSrc->m_LrColorChanger_iDelay;
165
166     this->m_StaticColor_Red          = pAtmoConfigSrc->m_StaticColor_Red;
167     this->m_StaticColor_Green        = pAtmoConfigSrc->m_StaticColor_Green;
168     this->m_StaticColor_Blue         = pAtmoConfigSrc->m_StaticColor_Blue;
169
170     this->m_LiveViewFilterMode             = pAtmoConfigSrc->m_LiveViewFilterMode;
171     this->m_LiveViewFilter_PercentNew      = pAtmoConfigSrc->m_LiveViewFilter_PercentNew;
172     this->m_LiveViewFilter_MeanLength      = pAtmoConfigSrc->m_LiveViewFilter_MeanLength;
173     this->m_LiveViewFilter_MeanThreshold   = pAtmoConfigSrc->m_LiveViewFilter_MeanThreshold;
174
175
176     this->m_LiveView_EdgeWeighting  =  pAtmoConfigSrc->m_LiveView_EdgeWeighting;
177     this->m_LiveView_BrightCorrect  =  pAtmoConfigSrc->m_LiveView_BrightCorrect;
178     this->m_LiveView_DarknessLimit  =  pAtmoConfigSrc->m_LiveView_DarknessLimit;
179     this->m_LiveView_HueWinSize     =  pAtmoConfigSrc->m_LiveView_HueWinSize;
180     this->m_LiveView_SatWinSize     =  pAtmoConfigSrc->m_LiveView_SatWinSize;
181     this->m_LiveView_WidescreenMode =  pAtmoConfigSrc->m_LiveView_WidescreenMode;
182
183     this->m_LiveView_HOverscanBorder  = pAtmoConfigSrc->m_LiveView_HOverscanBorder;
184     this->m_LiveView_VOverscanBorder  = pAtmoConfigSrc->m_LiveView_VOverscanBorder;
185     this->m_LiveView_DisplayNr        = pAtmoConfigSrc->m_LiveView_DisplayNr;
186     this->m_LiveView_FrameDelay       = pAtmoConfigSrc->m_LiveView_FrameDelay;
187
188     clearChannelMappings();
189     for(int i=1;i<pAtmoConfigSrc->getNumChannelAssignments();i++) {
190         tChannelAssignment *ta = pAtmoConfigSrc->m_ChannelAssignments[i];
191         if(ta!=NULL) {
192             tChannelAssignment *dest = this->m_ChannelAssignments[i];
193             if(dest == NULL) {
194                dest = new tChannelAssignment;
195                this->m_ChannelAssignments[i] = dest;
196             }
197             memcpy(dest, ta, sizeof(tChannelAssignment));
198         }
199     }
200 }
201
202
203
204 int CAtmoConfig::getNumChannelAssignments() {
205     int z=0;
206     for(int i=0;i<10;i++)
207         if(this->m_ChannelAssignments[i]!=NULL) z++;
208     return z;
209 }
210
211 void CAtmoConfig::clearChannelMappings() {
212     for(int i=1;i<10;i++) {
213         tChannelAssignment *ca = m_ChannelAssignments[i];
214         delete ca;
215         m_ChannelAssignments[i] = NULL;
216     }
217 }
218
219 void CAtmoConfig::clearAllChannelMappings() {
220     for(int i=0;i<10;i++) {
221         tChannelAssignment *ca = m_ChannelAssignments[i];
222         delete ca;
223         m_ChannelAssignments[i] = NULL;
224     }
225 }
226
227 void CAtmoConfig::AddChannelAssignment(tChannelAssignment *ta) {
228     for(int i=0;i<10;i++) {
229         if(m_ChannelAssignments[i] == NULL) {
230            m_ChannelAssignments[i] = ta;
231            break;
232         }
233     }
234 }
235
236 void CAtmoConfig::SetChannelAssignment(int index, tChannelAssignment *ta) {
237      if(m_ChannelAssignments[index]!=NULL)
238         delete m_ChannelAssignments[index];
239      m_ChannelAssignments[index] = ta;
240 }
241
242 CAtmoZoneDefinition *CAtmoConfig::getZoneDefinition(int zoneIndex) {
243     if(zoneIndex < 0)
244        return NULL;
245     if(zoneIndex >= ATMO_NUM_CHANNELS)
246        return NULL;
247     return m_ZoneDefinitions[zoneIndex];
248
249 }
250