]> git.sesse.net Git - vlc/blobdiff - modules/video_filter/atmo/AtmoConfig.cpp
contribs: updated binary package for Darwin including latest libmodplug
[vlc] / modules / video_filter / atmo / AtmoConfig.cpp
index 9c22d8e7aa323d3c50b11fc59ffddb5b777ff9a4..ec6c519587c0c5c6057f6e0493cd65079a4d7195 100644 (file)
@@ -29,55 +29,84 @@ CAtmoConfig::CAtmoConfig()
 {
   // setup basic configruation structures...
   m_IsShowConfigDialog = 0;
-  m_eAtmoConnectionType = actSerialPort;
+  m_eAtmoConnectionType = actClassicAtmo;
   for(int i=0;i<10;i++)
       m_ChannelAssignments[i] = NULL;
+
 #if defined (_ATMO_VLC_PLUGIN_)
   m_devicename = NULL;
+  m_devicenames[0] = NULL;
+  m_devicenames[1] = NULL;
+  m_devicenames[2] = NULL;
 #endif
   // load all config values with there defaults
-  LoadDefaults();
+  m_ZoneDefinitions  = NULL;
+  m_AtmoZoneDefCount = -1;
+  m_DMX_BaseChannels = NULL;
 
-  //   CAtmoZoneDefinition *m_ZoneDefinitions[ATMO_NUM_CHANNELS];
-  // generate default channel parameters which may be loaded later from .bmp files
-  for(int i=0;i<ATMO_NUM_CHANNELS;i++) {
-      m_ZoneDefinitions[i] = new CAtmoZoneDefinition();
-      m_ZoneDefinitions[i]->setZoneNumber(i);
-      switch(i) {
-          case 0:  // summary channel
-              m_ZoneDefinitions[i]->Fill(255);
-              break;
-          case 1: // left channel
-              m_ZoneDefinitions[i]->FillGradientFromLeft();
-              break;
-          case 2: // right channel
-              m_ZoneDefinitions[i]->FillGradientFromRight();
-              break;
-          case 3: // top channel
-              m_ZoneDefinitions[i]->FillGradientFromTop();
-              break;
-          case 4: // bottom channel
-              m_ZoneDefinitions[i]->FillGradientFromBottom();
-              break;
-      }
-  }
+  LoadDefaults();
 }
 
 CAtmoConfig::~CAtmoConfig() {
    // and finally cleanup...
    clearAllChannelMappings();
-#if !defined (WIN32)
-   if(m_devicename)
-      free(m_devicename);
+
+   if(m_ZoneDefinitions)
+   {
+     for(int zone=0; zone<m_AtmoZoneDefCount; zone++)
+         delete m_ZoneDefinitions[zone];
+     delete m_ZoneDefinitions;
+     m_ZoneDefinitions = NULL;
+   }
+
+   free( m_DMX_BaseChannels );
+
+#if defined (_ATMO_VLC_PLUGIN_)
+    free( m_devicename );
+    free( m_devicenames[0] );
+    free( m_devicenames[1] );
+    free( m_devicenames[2] );
 #endif
 }
 
 void CAtmoConfig::LoadDefaults() {
     //    m_eAtmoConnectionType = actSerialPort;
     //    m_Comport
+#if defined (_ATMO_VLC_PLUGIN_)
+
+    free( m_devicename );
+    free( m_devicenames[0] );
+    free( m_devicenames[1] );
+    free( m_devicenames[2] );
+
+    m_devicename = NULL;
+    m_devicenames[0] = NULL;
+    m_devicenames[1] = NULL;
+    m_devicenames[2] = NULL;
+
+#else
+
+    m_Comport     = -1;
+    m_Comports[0] = -1;
+    m_Comports[1] = -1;
+    m_Comports[2] = -1;
+
+#endif
 
     m_eEffectMode = emDisabled;
 
+    m_IgnoreConnectionErrorOnStartup = ATMO_FALSE;
+
+    m_UpdateEdgeWeightningFlag = 0;
+
+
+
+    m_Software_gamma_mode = agcNone;
+    m_Software_gamma_red    = 10;
+    m_Software_gamma_green  = 10;
+    m_Software_gamma_blue   = 10;
+    m_Software_gamma_global = 10;
+
     m_WhiteAdjustment_Red    = 255;
     m_WhiteAdjustment_Green  = 255;
     m_WhiteAdjustment_Blue   = 255;
@@ -102,6 +131,7 @@ void CAtmoConfig::LoadDefaults() {
     m_LiveViewFilter_PercentNew  = 50;
     m_LiveViewFilter_MeanLength  = 300;
     m_LiveViewFilter_MeanThreshold   = 40;
+    m_show_statistics = ATMO_FALSE;
 
     m_LiveView_EdgeWeighting  = 8;
     m_LiveView_BrightCorrect  = 100;
@@ -113,7 +143,8 @@ void CAtmoConfig::LoadDefaults() {
     m_LiveView_HOverscanBorder  = 0;
     m_LiveView_VOverscanBorder  = 0;
     m_LiveView_DisplayNr        = 0;
-    m_LiveView_FrameDelay       = 0;
+    m_LiveView_FrameDelay       = 30;
+    m_LiveView_GDI_FrameRate    = 25;
 
 
     m_Hardware_global_gamma    = 128;
@@ -126,22 +157,40 @@ void CAtmoConfig::LoadDefaults() {
     m_Hardware_gamma_green     = 22;
     m_Hardware_gamma_blue      = 22;
 
+    m_DMX_BaseChannels         = strdup("0");
+    m_DMX_RGB_Channels        = 5; // so wie atmolight
+
+    m_MoMo_Channels           = 3; // default momo, there exists also a 4 ch version!
+
+    m_ZonesTopCount            = 1;
+    m_ZonesBottomCount         = 1;
+    m_ZonesLRCount             = 1;
+    m_ZoneSummary              = ATMO_FALSE;
+    UpdateZoneCount();
+
+
     clearAllChannelMappings();
     m_CurrentChannelAssignment = 0;
-    tChannelAssignment *temp = temp = new tChannelAssignment;
+    CAtmoChannelAssignment *temp = new CAtmoChannelAssignment();
     temp->system = true;
-    for(int i=0;i<ATMO_NUM_CHANNELS;i++)
-        temp->mappings[i] = i;
-    strcpy(temp->name,"Standard");
+    temp->setName( "Standard" );
     this->m_ChannelAssignments[0] =  temp;
+
+    UpdateZoneDefinitionCount();
 }
 
 void CAtmoConfig::Assign(CAtmoConfig *pAtmoConfigSrc) {
 
 #if defined(_ATMO_VLC_PLUGIN_)
-    this->setSerialDevice(pAtmoConfigSrc->getSerialDevice());
+    this->setSerialDevice(0, pAtmoConfigSrc->getSerialDevice(0));
+    this->setSerialDevice(1, pAtmoConfigSrc->getSerialDevice(1));
+    this->setSerialDevice(2, pAtmoConfigSrc->getSerialDevice(2));
+    this->setSerialDevice(3, pAtmoConfigSrc->getSerialDevice(3));
 #else
     this->m_Comport                  = pAtmoConfigSrc->m_Comport;
+    this->m_Comports[0]              = pAtmoConfigSrc->m_Comports[0];
+    this->m_Comports[1]              = pAtmoConfigSrc->m_Comports[1];
+    this->m_Comports[2]              = pAtmoConfigSrc->m_Comports[2];
 #endif
 
     this->m_eAtmoConnectionType      = pAtmoConfigSrc->m_eAtmoConnectionType;
@@ -172,6 +221,8 @@ void CAtmoConfig::Assign(CAtmoConfig *pAtmoConfigSrc) {
     this->m_LiveViewFilter_MeanLength      = pAtmoConfigSrc->m_LiveViewFilter_MeanLength;
     this->m_LiveViewFilter_MeanThreshold   = pAtmoConfigSrc->m_LiveViewFilter_MeanThreshold;
 
+    this->m_show_statistics               = pAtmoConfigSrc->m_show_statistics;
+
 
     this->m_LiveView_EdgeWeighting  =  pAtmoConfigSrc->m_LiveView_EdgeWeighting;
     this->m_LiveView_BrightCorrect  =  pAtmoConfigSrc->m_LiveView_BrightCorrect;
@@ -184,19 +235,47 @@ void CAtmoConfig::Assign(CAtmoConfig *pAtmoConfigSrc) {
     this->m_LiveView_VOverscanBorder  = pAtmoConfigSrc->m_LiveView_VOverscanBorder;
     this->m_LiveView_DisplayNr        = pAtmoConfigSrc->m_LiveView_DisplayNr;
     this->m_LiveView_FrameDelay       = pAtmoConfigSrc->m_LiveView_FrameDelay;
+    this->m_LiveView_GDI_FrameRate    = pAtmoConfigSrc->m_LiveView_GDI_FrameRate;
+
+    this->m_ZonesTopCount             = pAtmoConfigSrc->m_ZonesTopCount;
+    this->m_ZonesBottomCount          = pAtmoConfigSrc->m_ZonesBottomCount;
+    this->m_ZonesLRCount              = pAtmoConfigSrc->m_ZonesLRCount;
+    this->m_ZoneSummary               = pAtmoConfigSrc->m_ZoneSummary;
+    UpdateZoneCount();
+
+    this->m_Software_gamma_mode      =  pAtmoConfigSrc->m_Software_gamma_mode;
+    this->m_Software_gamma_red       =  pAtmoConfigSrc->m_Software_gamma_red;
+    this->m_Software_gamma_green     =  pAtmoConfigSrc->m_Software_gamma_green;
+    this->m_Software_gamma_blue      =  pAtmoConfigSrc->m_Software_gamma_blue;
+    this->m_Software_gamma_global    =  pAtmoConfigSrc->m_Software_gamma_global;
+
+    this->setDMX_BaseChannels( pAtmoConfigSrc->getDMX_BaseChannels() );
+
+    this->m_DMX_RGB_Channels         = pAtmoConfigSrc->m_DMX_RGB_Channels;
+
+    this->m_MoMo_Channels            = pAtmoConfigSrc->m_MoMo_Channels;
+
+    this->m_CurrentChannelAssignment = pAtmoConfigSrc->m_CurrentChannelAssignment;
 
     clearChannelMappings();
     for(int i=1;i<pAtmoConfigSrc->getNumChannelAssignments();i++) {
-        tChannelAssignment *ta = pAtmoConfigSrc->m_ChannelAssignments[i];
+        CAtmoChannelAssignment *ta = pAtmoConfigSrc->m_ChannelAssignments[i];
         if(ta!=NULL) {
-            tChannelAssignment *dest = this->m_ChannelAssignments[i];
+            CAtmoChannelAssignment *dest = this->m_ChannelAssignments[i];
             if(dest == NULL) {
-               dest = new tChannelAssignment;
+               dest = new CAtmoChannelAssignment();
                this->m_ChannelAssignments[i] = dest;
             }
-            memcpy(dest, ta, sizeof(tChannelAssignment));
+            // memcpy(dest, ta, sizeof(tChannelAssignment));
+            dest->setSize(ta->getSize());
+            dest->setName(ta->getName());
+            dest->system = ta->system;
+            for(int c=0;c<dest->getSize();c++)
+                dest->setZoneIndex(c, ta->getZoneIndex(c));
         }
     }
+
+    UpdateZoneDefinitionCount();
 }
 
 
@@ -210,7 +289,7 @@ int CAtmoConfig::getNumChannelAssignments() {
 
 void CAtmoConfig::clearChannelMappings() {
     for(int i=1;i<10;i++) {
-        tChannelAssignment *ca = m_ChannelAssignments[i];
+        CAtmoChannelAssignment *ca = m_ChannelAssignments[i];
         if(ca!=NULL)
            delete ca;
         m_ChannelAssignments[i] = NULL;
@@ -219,14 +298,14 @@ void CAtmoConfig::clearChannelMappings() {
 
 void CAtmoConfig::clearAllChannelMappings() {
     for(int i=0;i<10;i++) {
-        tChannelAssignment *ca = m_ChannelAssignments[i];
+        CAtmoChannelAssignment *ca = m_ChannelAssignments[i];
         if(ca!=NULL)
            delete ca;
         m_ChannelAssignments[i] = NULL;
     }
 }
 
-void CAtmoConfig::AddChannelAssignment(tChannelAssignment *ta) {
+void CAtmoConfig::AddChannelAssignment(CAtmoChannelAssignment *ta) {
     for(int i=0;i<10;i++) {
         if(m_ChannelAssignments[i] == NULL) {
            m_ChannelAssignments[i] = ta;
@@ -235,7 +314,7 @@ void CAtmoConfig::AddChannelAssignment(tChannelAssignment *ta) {
     }
 }
 
-void CAtmoConfig::SetChannelAssignment(int index, tChannelAssignment *ta) {
+void CAtmoConfig::SetChannelAssignment(int index, CAtmoChannelAssignment *ta) {
      if(m_ChannelAssignments[index]!=NULL)
         delete m_ChannelAssignments[index];
      m_ChannelAssignments[index] = ta;
@@ -244,9 +323,103 @@ void CAtmoConfig::SetChannelAssignment(int index, tChannelAssignment *ta) {
 CAtmoZoneDefinition *CAtmoConfig::getZoneDefinition(int zoneIndex) {
     if(zoneIndex < 0)
        return NULL;
-    if(zoneIndex >= ATMO_NUM_CHANNELS)
+    if(zoneIndex >= m_AtmoZoneDefCount)
        return NULL;
     return m_ZoneDefinitions[zoneIndex];
 
 }
 
+void CAtmoConfig::UpdateZoneCount()
+{
+  m_computed_zones_count = m_ZonesTopCount + m_ZonesBottomCount + 2 * m_ZonesLRCount;
+  if(m_ZoneSummary)
+     m_computed_zones_count++;
+}
+
+
+
+int CAtmoConfig::getZoneCount()
+{
+    return(m_computed_zones_count);
+}
+
+void CAtmoConfig::UpdateZoneDefinitionCount()
+{
+   if( getZoneCount() != m_AtmoZoneDefCount)
+   {
+      // okay zonen anzahl hat sich geändert - wir müssen neu rechnen
+      // und allokieren!
+      if(m_ZoneDefinitions)
+      {
+        for(int zone=0; zone<m_AtmoZoneDefCount; zone++)
+            delete m_ZoneDefinitions[zone];
+        delete m_ZoneDefinitions;
+        m_ZoneDefinitions = NULL;
+      }
+      m_AtmoZoneDefCount = getZoneCount();
+      if(m_AtmoZoneDefCount > 0)
+      {
+         m_ZoneDefinitions = new CAtmoZoneDefinition*[m_AtmoZoneDefCount];
+         for(int zone=0; zone< m_AtmoZoneDefCount; zone++) {
+             m_ZoneDefinitions[zone] = new CAtmoZoneDefinition();
+             m_ZoneDefinitions[zone]->Fill(255);
+         }
+      }
+   }
+}
+
+#if defined(_ATMO_VLC_PLUGIN_)
+
+char *CAtmoConfig::getSerialDevice(int i)
+{
+   if(i == 0)
+      return m_devicename;
+   else  {
+       i--;
+       return m_devicenames[i];
+   }
+}
+
+void CAtmoConfig::setSerialDevice(int i,const char *pszNewDevice)
+{
+    if(i == 0)
+       setSerialDevice(pszNewDevice);
+    else {
+       i--;
+       free( m_devicenames[i] );
+       if(pszNewDevice)
+          m_devicenames[i] = strdup(pszNewDevice);
+       else
+          m_devicenames[i] = NULL;
+    }
+}
+
+#else
+
+int CAtmoConfig::getComport(int i)
+{
+  if(i == 0)
+     return this->m_Comport;
+  else {
+     i--;
+     return this->m_Comports[i];
+  }
+}
+
+void CAtmoConfig::setComport(int i, int nr)
+{
+  if(i == 0)
+      this->m_Comport = nr;
+  else {
+    this->m_Comports[i-1] = nr;
+  }
+}
+
+#endif
+
+void CAtmoConfig::setDMX_BaseChannels(char *channels)
+{
+     free(m_DMX_BaseChannels);
+     m_DMX_BaseChannels = strdup(channels);
+}
+